aa
This commit is contained in:
@@ -1575,7 +1575,6 @@ func UpdateJob(ctx *jxcontext.Context, payload map[string]interface{}) (err erro
|
||||
job.ID = jobExt.ID
|
||||
dao.GetEntity(db, job)
|
||||
valid := dao.StrictMakeMapByStructObject(payload, job, ctx.GetUserName())
|
||||
fmt.Println("valid,,,,,,,,,,,,,,,,,,,,,,,,,,", utils.Format4Output(valid, false))
|
||||
if len(valid) > 0 {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
|
||||
@@ -190,66 +190,68 @@ type GetPayStatisticsResult struct {
|
||||
MemberIncome int `json:"memberIncome"` //会员收益
|
||||
}
|
||||
|
||||
func getWhereSql(sqlP []interface{}, fromTime, toTime time.Time, orderTypes []int) (sql string) {
|
||||
if len(orderTypes) > 0 {
|
||||
sql += ` AND b.order_type IN ` + GenQuestionMarks(len(orderTypes)) + `)`
|
||||
sqlP = append(sqlP, orderTypes)
|
||||
}
|
||||
if fromTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at > ?`
|
||||
sqlP = append(sqlP, fromTime)
|
||||
}
|
||||
if toTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at < ?`
|
||||
sqlP = append(sqlP, toTime)
|
||||
}
|
||||
return sql
|
||||
}
|
||||
|
||||
func getFromSql(sqlP []interface{}, orderType, status int, alies string, userID string, pop int, cityCodes []int, mobile string, fromTime, toTime time.Time, orderTypes []int) (sql string) {
|
||||
sql += `
|
||||
(SELECT SUM(IFNULL(b.pay_price,0)) total_pay
|
||||
FROM user a
|
||||
JOIN ` + "`order` b " + `ON b.user_id = a.user_id AND b.type = ? AND b.status = ? ` + getWhereSql(sqlP, fromTime, toTime, orderTypes) + `
|
||||
`
|
||||
sqlP = append(sqlP, orderType, status)
|
||||
if mobile != "" {
|
||||
if pop == 1 {
|
||||
sql += " JOIN user e ON e.moblie = ? AND a.pop_user = e.user_id"
|
||||
sqlP = append(sqlP, mobile)
|
||||
}
|
||||
}
|
||||
sql += `
|
||||
WHERE 1 = 1
|
||||
`
|
||||
if userID != "" {
|
||||
if pop == 1 {
|
||||
sql += " AND a.pop_user = ?"
|
||||
sqlP = append(sqlP, userID)
|
||||
} else {
|
||||
sql += " AND a.user_id = ?"
|
||||
sqlP = append(sqlP, userID)
|
||||
}
|
||||
}
|
||||
if mobile != "" {
|
||||
if pop == 0 {
|
||||
sql += " AND a.mobile = ?"
|
||||
sqlP = append(sqlP, mobile)
|
||||
}
|
||||
}
|
||||
if len(cityCodes) > 0 {
|
||||
sql += ` AND a.city_code IN ` + GenQuestionMarks(len(cityCodes)) + `)`
|
||||
sqlP = append(sqlP, cityCodes)
|
||||
}
|
||||
sql += `) ` + alies
|
||||
return sql
|
||||
}
|
||||
|
||||
func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile string, fromTime, toTime time.Time, orderTypes []int) (getPayStatisticsResult *GetPayStatisticsResult, err error) {
|
||||
var sqlParams []interface{}
|
||||
getWhereSql := func(sqlP []interface{}) (sql string) {
|
||||
if len(orderTypes) > 0 {
|
||||
sql += ` AND b.order_type IN ` + GenQuestionMarks(len(orderTypes)) + `)`
|
||||
sqlP = append(sqlP, orderTypes)
|
||||
}
|
||||
if fromTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at > ?`
|
||||
sqlP = append(sqlP, fromTime)
|
||||
}
|
||||
if toTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at < ?`
|
||||
sqlP = append(sqlP, toTime)
|
||||
}
|
||||
return sql
|
||||
}
|
||||
getFromSql := func(sqlP []interface{}, orderType, status int, alies string) (sql string) {
|
||||
sql += `
|
||||
(SELECT SUM(IFNULL(b.pay_price,0)) total_pay
|
||||
FROM user a
|
||||
JOIN ` + "`order` b " + `ON b.user_id = a.user_id AND b.type = ? AND b.status = ? ` + getWhereSql(sqlP) + `
|
||||
`
|
||||
sqlP = append(sqlP, orderType, status)
|
||||
if mobile != "" {
|
||||
if pop == 1 {
|
||||
sql += " JOIN user e ON e.moblie = ? AND a.pop_user = e.user_id"
|
||||
sqlP = append(sqlP, mobile)
|
||||
}
|
||||
}
|
||||
sql += `
|
||||
WHERE 1 = 1
|
||||
`
|
||||
if userID != "" {
|
||||
if pop == 1 {
|
||||
sql += " AND a.pop_user = ?"
|
||||
sqlP = append(sqlP, userID)
|
||||
} else {
|
||||
sql += " AND a.user_id = ?"
|
||||
sqlP = append(sqlP, userID)
|
||||
}
|
||||
}
|
||||
if mobile != "" {
|
||||
if pop == 0 {
|
||||
sql += " AND a.mobile = ?"
|
||||
sqlP = append(sqlP, mobile)
|
||||
}
|
||||
}
|
||||
if len(cityCodes) > 0 {
|
||||
sql += ` AND a.city_code IN ` + GenQuestionMarks(len(cityCodes)) + `)`
|
||||
sqlP = append(sqlP, cityCodes)
|
||||
}
|
||||
sql += `) ` + alies
|
||||
return sql
|
||||
}
|
||||
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 += getFromSql(sqlParams, model.OrderTypePay, model.OrderStatusFinished, "t1", userID, pop, cityCodes, mobile, fromTime, toTime, orderTypes) + ","
|
||||
sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusWait4Pay, "t2", userID, pop, cityCodes, mobile, fromTime, toTime, orderTypes) + ","
|
||||
sql += getFromSql(sqlParams, model.OrderTypeCash, model.OrderStatusFinished, "t3", userID, pop, cityCodes, mobile, fromTime, toTime, orderTypes) + ","
|
||||
sql += `(SELECT SUM(IFNULL(b.account_balance,0)) account_balacne
|
||||
FROM user a
|
||||
JOIN user_bill b ON a.user_id = b.user_id
|
||||
|
||||
Reference in New Issue
Block a user