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.
107 lines
2.8 KiB
107 lines
2.8 KiB
|
1 year ago
|
package guser
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
"server/modules/backend/app"
|
||
|
|
"server/modules/backend/models"
|
||
|
|
utils "server/modules/backend/util"
|
||
|
|
"server/modules/backend/values"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
func BigRUserData(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.BigRUserDataReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
resp := values.BigRUserDataResp{}
|
||
|
|
su, eu := utils.GetQueryUnix(req.Start, req.End)
|
||
|
|
|
||
|
|
totalRecharge := req.TotalRecharge
|
||
|
|
|
||
|
|
queryUser := " SELECT DISTINCT(a.id), a.nick, a.birth, a.bind_cash, a.cash, a.mobile FROM users AS a " +
|
||
|
|
" LEFT JOIN (SELECT uid, total_recharge FROM recharge_info WHERE total_recharge >= %d) AS b ON a.id = b.uid " +
|
||
|
|
" WHERE a.id = b.uid AND "
|
||
|
|
queryCount := " SELECT COUNT(DISTINCT(a.id)) FROM users AS a " +
|
||
|
|
" LEFT JOIN (SELECT uid, total_recharge FROM recharge_info WHERE total_recharge >= %d) AS b ON a.id = b.uid " +
|
||
|
|
" WHERE a.id = b.uid AND "
|
||
|
|
|
||
|
|
str := fmt.Sprintf(" a.birth >= %d AND a.birth < %d ", su, eu)
|
||
|
|
|
||
|
|
if req.Channel != nil {
|
||
|
|
str += fmt.Sprintf(" AND a.channel_id = %d ", *req.Channel)
|
||
|
|
}
|
||
|
|
|
||
|
|
var count int64
|
||
|
|
err := db.Mysql().QueryBySql(fmt.Sprintf(queryCount+str, totalRecharge), &count)
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
}
|
||
|
|
|
||
|
|
switch req.Sort {
|
||
|
|
case 1:
|
||
|
|
str += " ORDER BY a.birth DESC "
|
||
|
|
case 2:
|
||
|
|
str += " ORDER BY b.total_recharge DESC "
|
||
|
|
case 3:
|
||
|
|
str += " ORDER BY c.time DESC "
|
||
|
|
default:
|
||
|
|
str += " ORDER BY a.birth DESC "
|
||
|
|
}
|
||
|
|
|
||
|
|
str += fmt.Sprintf(" LIMIT %d, %d ", (req.Page-1)*req.Num, req.Num)
|
||
|
|
|
||
|
|
var users []common.PlayerDBInfo
|
||
|
|
err = db.Mysql().QueryBySql(fmt.Sprintf(queryUser+str, totalRecharge), &users)
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
}
|
||
|
|
|
||
|
|
for i := 0; i < len(users); i++ {
|
||
|
|
var bigRUserData values.BigRUserData
|
||
|
|
bigRUserData.Nick = users[i].Nick
|
||
|
|
bigRUserData.Uid = users[i].Id
|
||
|
|
bigRUserData.Birth = users[i].Birth
|
||
|
|
|
||
|
|
var record common.LoginRecord
|
||
|
|
err = db.Mysql().C().Model(&common.LoginRecord{}).Where(" uid = ?", users[i].Id).Last(&record).Error
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
}
|
||
|
|
bigRUserData.LastLogin = record.Time
|
||
|
|
|
||
|
|
// 玩家充值金额
|
||
|
|
bigRUserData.RechargeAmount = models.GetRechargeTotalByUid(&users[i].Id)
|
||
|
|
|
||
|
|
// 充值成功率
|
||
|
|
bigRUserData.RechargePer = utils.GetPer(models.GetOneRechargeSuccessCountBySql(users[i].Id), models.GetOneRechargeCountBySql(users[i].Id))
|
||
|
|
|
||
|
|
// 玩家退出金额
|
||
|
|
bigRUserData.WithDrawAmount = models.GetWithdrawTotalByUid(&users[i].Id)
|
||
|
|
|
||
|
|
// 玩家游戏局数
|
||
|
|
gameCount := make(map[string]int64)
|
||
|
|
bigRUserData.GameCount = gameCount
|
||
|
|
|
||
|
|
// 充提比
|
||
|
|
bigRUserData.RechargeAndWithDrawRate = utils.GetPer(bigRUserData.WithDrawAmount, bigRUserData.RechargeAmount)
|
||
|
|
|
||
|
|
// 手机号
|
||
|
|
bigRUserData.Phone = users[i].Mobile
|
||
|
|
|
||
|
|
resp.List = append(resp.List, bigRUserData)
|
||
|
|
}
|
||
|
|
|
||
|
|
resp.Count = count
|
||
|
|
a.Data = resp
|
||
|
|
}
|