From edb3e786509ead705295c48a737fde2b5ec9b653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Jan 2021 14:31:56 +0800 Subject: [PATCH] aa --- business/model/dao/dao_order.go | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 50150d87e..689e22849 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -244,12 +244,45 @@ func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile sql += `) ` + alies return sql } - sql := `SELECT t1.total_pay, t2.total_pay submit_cash, t3.total_pay cashed + sql := `SELECT t1.total_pay, t2.total_pay submit_cash, t3.total_pay cashed, t4.account_balance, t4.account_balance + t2.total_pay can_cash, t3.total_pay / 10 cash_income FROM ` sql += getFromSql(sqlParams, model.OrderTypePay, model.OrderStatusFinished, "t1") + "," sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusWait4Pay, "t2") + "," sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusFinished, "t3") + "," - sql += " user_bill " + sql += `(SELECT SUM(IFNULL(b.account_balance,0)) account_balacne + FROM user a + JOIN user_bill b ON a.user_id = b.user_id + ` + if mobile != "" { + if pop == 1 { + sql += " JOIN user e ON e.moblie = ? AND a.pop_user = e.user_id" + sqlParams = append(sqlParams, mobile) + } + } + sql += ` + WHERE 1 = 1 + ` + if userID != "" { + if pop == 1 { + sql += " AND a.pop_user = ?" + sqlParams = append(sqlParams, userID) + } else { + sql += " AND a.user_id = ?" + sqlParams = append(sqlParams, userID) + } + } + if mobile != "" { + if pop == 0 { + sql += " AND a.mobile = ?" + sqlParams = append(sqlParams, mobile) + } + } + if len(cityCodes) > 0 { + sql += ` AND a.city_code IN ` + GenQuestionMarks(len(cityCodes)) + `)` + sqlParams = append(sqlParams, cityCodes) + } + sql += ` + ) t4` err = GetRow(db, &getPayStatisticsResult, sql, sqlParams) sqlParams2 := []interface{}{} getPayStatisticsResult1 := &GetPayStatisticsResult{}