You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.9 KiB
97 lines
2.9 KiB
|
1 year ago
|
package guser
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
"server/call"
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
utils "server/modules/backend/util"
|
||
|
|
"server/modules/backend/values"
|
||
|
|
"server/modules/customer/app"
|
||
|
|
)
|
||
|
|
|
||
|
|
// 充值排行榜
|
||
|
|
func RechargeRank(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.RechargeRankReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
su, eu := utils.GetQueryUnix(req.Start, req.End)
|
||
|
|
resp := values.RechargeRankResp{}
|
||
|
|
|
||
|
|
var num int64 = 100
|
||
|
|
if req.Num != nil {
|
||
|
|
num = *req.Num
|
||
|
|
}
|
||
|
|
|
||
|
|
var str string
|
||
|
|
|
||
|
|
if req.Status == 1 {
|
||
|
|
str = fmt.Sprintf("SELECT uid, SUM(amount) AS amount, COUNT(amount) as event FROM recharge_order WHERE event = %d AND status = %d AND callback_time >= %d AND callback_time < %d GROUP BY uid ORDER BY amount DESC LIMIT 0, %d",
|
||
|
|
common.CurrencyEventReCharge,
|
||
|
|
common.StatusROrderPay,
|
||
|
|
su,
|
||
|
|
eu,
|
||
|
|
num)
|
||
|
|
} else {
|
||
|
|
str = fmt.Sprintf("SELECT uid, SUM(amount) AS amount, COUNT(amount) as event FROM recharge_order WHERE event = %d AND status = %d AND callback_time >= %d AND callback_time < %d GROUP BY uid ORDER BY amount DESC LIMIT 0, %d",
|
||
|
|
common.CurrencyEventWithDraw,
|
||
|
|
common.StatusROrderFinish,
|
||
|
|
su,
|
||
|
|
eu,
|
||
|
|
num)
|
||
|
|
}
|
||
|
|
|
||
|
|
var users []common.RechargeOrder
|
||
|
|
|
||
|
|
err := db.Mysql().QueryBySql(str, &users)
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
for i := 0; i < len(users); i++ {
|
||
|
|
var temp values.RechargeRank
|
||
|
|
temp.Date = su
|
||
|
|
temp.Uid = users[i].UID
|
||
|
|
if req.Status == 1 {
|
||
|
|
temp.TodayRechargeAmount = users[i].Amount
|
||
|
|
temp.TodayRechargeOrderCount = int64(users[i].Event)
|
||
|
|
|
||
|
|
sql := fmt.Sprintf("event = %v and status = %v and callback_time >= '%v' and callback_time < '%v' and uid = %v", common.CurrencyEventWithDraw, common.StatusROrderFinish, su, eu, users[i].UID)
|
||
|
|
temp.TodayWithDrawAmount = db.Mysql().Sum(&common.RechargeOrder{}, sql, "amount")
|
||
|
|
temp.TodayWithDrawOrderCount = db.Mysql().Count(&common.RechargeOrder{}, sql)
|
||
|
|
} else {
|
||
|
|
temp.TodayWithDrawAmount = users[i].Amount
|
||
|
|
temp.TodayWithDrawOrderCount = int64(users[i].Event)
|
||
|
|
|
||
|
|
sql := fmt.Sprintf("event = %v and status = %v and callback_time >= '%v' and callback_time < '%v' and uid = %v", common.CurrencyEventReCharge, common.StatusROrderPay, su, eu, users[i].UID)
|
||
|
|
temp.TodayRechargeAmount = db.Mysql().Sum(&common.RechargeOrder{}, sql, "amount")
|
||
|
|
temp.TodayRechargeOrderCount = db.Mysql().Count(&common.RechargeOrder{}, sql)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 玩家总提现金额
|
||
|
|
temp.WithDrawAmount = getPlayerAmountBySql(users[i].UID, int(common.CurrencyEventWithDraw), common.StatusROrderFinish)
|
||
|
|
// 玩家总充值金额
|
||
|
|
temp.RechargeAmount = getPlayerAmountBySql(users[i].UID, int(common.CurrencyEventReCharge), common.StatusROrderPay)
|
||
|
|
// 玩家生日
|
||
|
|
res, _ := call.GetUserInfo(users[i].UID)
|
||
|
|
temp.Birth = res.Birth
|
||
|
|
|
||
|
|
// 用户渠道
|
||
|
|
temp.Channel = users[i].ChannelID
|
||
|
|
|
||
|
|
resp.List = append(resp.List, &temp)
|
||
|
|
}
|
||
|
|
resp.Count = int64(len(users))
|
||
|
|
|
||
|
|
a.Data = resp
|
||
|
|
}
|