This commit is contained in:
邹宗楠
2022-11-24 13:48:52 +08:00
parent 3200ebd799
commit 57d94f82ed
13 changed files with 493 additions and 57 deletions

View File

@@ -686,3 +686,64 @@ func SetOrderStatus(tx orm.TxOrmer, payPrice, payMethod, status int, orderID str
}
return "更新Order状态成功", nil
}
// QueryRechargeRecommend 电话充值记录查询
func QueryRechargeRecommend(userId []string, mobile, orderId string, page, pageSize int, start, end time.Time, rechargeStatus int) ([]*model.RechargeUserModelData, int, error) {
result := make([]*model.RechargeUserModelData, 0, 0)
sql := `SELECT SQL_CALC_FOUND_ROWS o.*,u.name FROM order o `
sqlParams := make([]interface{}, 0, 0)
sql += ` JOIN user u ON o.user_id = u.user_id WHERE 1=1 `
if orderId != "" {
sql += ` AND o.order_id = ? `
sqlParams = append(sqlParams, orderId)
if err := GetRows(GetDB(), &result, sql, sqlParams...); err != nil {
return nil, 0, err
}
return result, 1, nil
}
if userId != nil {
sql += ` AND o.user_id IN (` + GenQuestionMarks(len(userId)) + `)`
sqlParams = append(sqlParams, userId)
}
if !utils.IsTimeZero(start) {
sql += ` AND o.created_at > ?`
sqlParams = append(sqlParams, start)
}
if !utils.IsTimeZero(end) {
sql += ` AND o.created_at < ?`
sqlParams = append(sqlParams, end)
}
if mobile != "" {
sql += ` AND o.mobile = ? `
sqlParams = append(sqlParams, mobile)
}
if rechargeStatus != 0 {
sql += ` AND o.recharge_status = ? `
sqlParams = append(sqlParams, rechargeStatus)
}
sql += " ORDER BY o.created_at DESC LIMIT ? OFFSET ?"
sqlParams = append(sqlParams, jxutils.FormalizePageSize(pageSize), (page-1)*pageSize)
db := GetDB()
tx, _ := Begin(db)
defer func() {
if r := recover(); r != nil {
Rollback(db, tx)
}
}()
if err := GetRowsTx(tx, &result, sql, sqlParams...); err != nil {
Rollback(db, tx)
return nil, 0, err
}
count := GetLastTotalRowCountTx(tx)
return result, count, nil
}