This commit is contained in:
苏尹岚
2021-01-04 11:30:52 +08:00
parent 18af6c92f3
commit f7d1abc91b

View File

@@ -253,7 +253,7 @@ func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile
fmt.Println(utils.Format4Output(getPayStatisticsResult, false))
sqlParams2 := []interface{}{}
sql2 := `
SELECT SUM(b.pay_price) + SUM(d.expend_price) member_income
SELECT SUM(IFNULL(d.expend_price,0)) member_income
FROM user a`
if mobile != "" {
if pop == 1 {
@@ -277,21 +277,12 @@ func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile
sqlParams2 = append(sqlParams2, userID)
}
}
sql2 += ` LEFT JOIN ` + "`order b`" + ` ON b.type = ? AND b.status = ? AND b.order_type = ?`
sqlParams2 = append(sqlParams2, model.OrderTypePay, model.OrderStatusFinished, model.OrderTpyeMember)
if fromTime != utils.ZeroTimeValue {
sql += ` AND b.created_at > ?`
sqlParams2 = append(sqlParams2, fromTime)
}
if toTime != utils.ZeroTimeValue {
sql += ` AND b.created_at < ?`
sqlParams2 = append(sqlParams2, toTime)
}
sql2 += `
LEFT JOIN user_bill c
LEFT JOIN bill_expend d ON d.bill_id = c.bill_id AND d.type = ?
WHERE a.status = ? AND a.deleted_at = ?
`
sqlParams2 = append(sqlParams2, model.BillTypeMember)
sqlParams2 = append(sqlParams2, model.BillTypeMember, model.UserStatusNormal, utils.DefaultTimeValue)
if fromTime != utils.ZeroTimeValue {
sql2 += ` AND d.created_at > ?`
sqlParams2 = append(sqlParams2, fromTime)