diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 79c0368e2..fe2a7896f 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -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)