This commit is contained in:
苏尹岚
2021-01-04 14:31:56 +08:00
parent 3359662363
commit edb3e78650

View File

@@ -244,12 +244,45 @@ func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile
sql += `) ` + alies sql += `) ` + alies
return sql 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 ` FROM `
sql += getFromSql(sqlParams, model.OrderTypePay, model.OrderStatusFinished, "t1") + "," sql += getFromSql(sqlParams, model.OrderTypePay, model.OrderStatusFinished, "t1") + ","
sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusWait4Pay, "t2") + "," sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusWait4Pay, "t2") + ","
sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusFinished, "t3") + "," 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) err = GetRow(db, &getPayStatisticsResult, sql, sqlParams)
sqlParams2 := []interface{}{} sqlParams2 := []interface{}{}
getPayStatisticsResult1 := &GetPayStatisticsResult{} getPayStatisticsResult1 := &GetPayStatisticsResult{}