This commit is contained in:
苏尹岚
2020-12-31 17:29:18 +08:00
parent 3de4615719
commit a561368cf4
5 changed files with 55 additions and 20 deletions

View File

@@ -189,16 +189,40 @@ type GetPayStatisticsResult struct {
CashIncome int `json:"cashIncome"` //提现收益
}
func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile string, fromTime, toTime time.Time, consumeTypes []int) (getPayStatisticsResult *GetPayStatisticsResult, err error) {
func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile string, fromTime, toTime time.Time, orderTypes []int) (getPayStatisticsResult *GetPayStatisticsResult, err error) {
sqlParams := []interface{}{}
sql := `
SELECT a.*
FROM user a
`
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 != "" {
sql += " AND a.user_id = ?"
sqlParams = append(sqlParams, 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)
}
err = GetRow(db, &getPayStatisticsResult, sql, sqlParams)
return getPayStatisticsResult, err
}