|
|
|
|
package guser
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"server/call"
|
|
|
|
|
"server/common"
|
|
|
|
|
"server/db"
|
|
|
|
|
"server/modules/backend/app"
|
|
|
|
|
"server/modules/backend/models"
|
|
|
|
|
"server/modules/backend/values"
|
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/liangdas/mqant/log"
|
|
|
|
|
"github.com/olivere/elastic/v7"
|
|
|
|
|
|
|
|
|
|
uutil "server/util"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func GetGameUserInfo(c *gin.Context) {
|
|
|
|
|
a := app.NewApp(c)
|
|
|
|
|
defer func() {
|
|
|
|
|
a.Response()
|
|
|
|
|
}()
|
|
|
|
|
req := new(values.GetGameUserInfoReq)
|
|
|
|
|
if !a.S(req) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
user := &common.PlayerDBInfo{}
|
|
|
|
|
switch req.Data.(type) {
|
|
|
|
|
case int, int64, float32, float64:
|
|
|
|
|
id := uutil.GetInt(req.Data)
|
|
|
|
|
if id <= 999999999 {
|
|
|
|
|
user.Id = id
|
|
|
|
|
} else {
|
|
|
|
|
user.Mobile = strconv.Itoa(id)
|
|
|
|
|
}
|
|
|
|
|
case string:
|
|
|
|
|
str := req.Data.(string)
|
|
|
|
|
if len(str) == 10 {
|
|
|
|
|
user.Mobile = str
|
|
|
|
|
} else {
|
|
|
|
|
id, err := strconv.Atoi(str)
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.Code = values.CodeParam
|
|
|
|
|
a.Msg = "玩家不存在"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
user.Id = id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
err := db.Mysql().Get(user)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error("err:%v", err)
|
|
|
|
|
a.Code = values.CodeParam
|
|
|
|
|
a.Msg = "玩家不存在"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
uid := user.Id
|
|
|
|
|
ur, _ := call.GetUserXInfo(uid, "online")
|
|
|
|
|
info := &common.RechargeInfo{UID: uid}
|
|
|
|
|
db.Mysql().Get(info)
|
|
|
|
|
lg := &common.LoginRecord{UID: uid}
|
|
|
|
|
db.Mysql().GetLast(lg)
|
|
|
|
|
resp := values.GetGameUserInfoResp{
|
|
|
|
|
UID: user.Id,
|
|
|
|
|
Nick: user.Nick,
|
|
|
|
|
Channel: user.ChannelID,
|
|
|
|
|
Phone: user.Mobile,
|
|
|
|
|
OpenID: *user.Openid,
|
|
|
|
|
Online: ur.Online == common.PlayerOnline,
|
|
|
|
|
Status: user.Status,
|
|
|
|
|
Birth: user.Birth,
|
|
|
|
|
// PlayCount: util.GetGUserPlayCount(uid),
|
|
|
|
|
IP: user.IP,
|
|
|
|
|
LastLogin: lg.Time,
|
|
|
|
|
Tag: user.Tag,
|
|
|
|
|
UserGameData: GetUserGameInfo(user.Id),
|
|
|
|
|
OutputData: models.GetOutputData(0, 0, 0, uid),
|
|
|
|
|
Gpsadid: user.DeviceId,
|
|
|
|
|
SameIPUids: call.GetUserByDeviceIp(user.IP, "", user.Id),
|
|
|
|
|
SameDeviceUids: call.GetUserByDeviceIp("", user.DeviceId, user.Id),
|
|
|
|
|
}
|
|
|
|
|
if len(resp.SameIPUids) > 0 || len(resp.SameDeviceUids) > 0 {
|
|
|
|
|
resp.AllWithdrawPer = call.GetAllWithdrawPer(append(append(resp.SameIPUids, resp.SameDeviceUids...), uid))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currency := &common.PlayerCurrency{UID: uid}
|
|
|
|
|
db.Mysql().Get(currency)
|
|
|
|
|
// currencyRecharge := &common.PlayerCurrency{UID: uid}
|
|
|
|
|
// db.Mysql().C().Table(common.PlayerRechargeTableName).Where("uid = ?", uid).Scan(currencyRecharge)
|
|
|
|
|
// resp.CashBrl = currency.INR + currencyRecharge.INR
|
|
|
|
|
tmp := &common.PlayerProfile{UID: uid}
|
|
|
|
|
db.Mysql().Get(tmp)
|
|
|
|
|
resp.CashBrl = currency.INR
|
|
|
|
|
resp.WithdrawalBrl = tmp.NeedBet
|
|
|
|
|
// resp.CashUsdt = currency.USDT + currencyRecharge.USDT
|
|
|
|
|
// resp.WithdrawalUsdt = currency.USDT
|
|
|
|
|
brlInfo := call.GetRechargeInfo(uid)
|
|
|
|
|
// usdtInfo := call.GetPlayerRechargeInfoByCurrency(uid, common.CurrencyUSDT)
|
|
|
|
|
resp.RechargeBrl = brlInfo.TotalRecharge
|
|
|
|
|
resp.WithdrawBrl = brlInfo.TotalWithdraw
|
|
|
|
|
resp.Rtp = call.GetRtpControlV1(uid, &resp.WithdrawPer)
|
|
|
|
|
// resp.RechargeUsdt = usdtInfo.TotalRecharge
|
|
|
|
|
// resp.WithdrawUsdt = usdtInfo.TotoalWithdraw
|
|
|
|
|
|
|
|
|
|
db.Mysql().C().Table("users").Select("id").Where("deviceid = ?", user.DeviceId).Scan(&resp.SubAccount)
|
|
|
|
|
// db.Mysql().QueryAll(fmt.Sprintf("deviceid = '%s'", user.DeviceId), "", &common.PlayerDBInfo{}, &resp.SubAccount)
|
|
|
|
|
a.Data = resp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取用户游戏信息
|
|
|
|
|
func GetUserGameInfo(uid int) map[string][]values.UserGameInfo {
|
|
|
|
|
q := elastic.NewBoolQuery()
|
|
|
|
|
q.Filter(elastic.NewTermQuery("uid", uid))
|
|
|
|
|
q.Filter(elastic.NewTermsQuery("event", common.GetGameEvents()...))
|
|
|
|
|
buk, err := db.ES().Group2SumBy(common.ESIndexBalance, "exi1", "exi2", "value", q, "", false, 0)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error("err:%v", err)
|
|
|
|
|
}
|
|
|
|
|
ret := map[string][]values.UserGameInfo{}
|
|
|
|
|
var totalCount, totalProfit int64
|
|
|
|
|
for _, v := range buk.Buckets {
|
|
|
|
|
provider := call.GetConfigGameProvider(uutil.GetInt(v.Key))
|
|
|
|
|
if provider == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
games := []values.UserGameInfo{}
|
|
|
|
|
for _, k := range v.Sub1.Buckets {
|
|
|
|
|
thisGame := call.GetConfigGameListByID(provider.ProviderID, uutil.GetInt(k.Key))
|
|
|
|
|
if thisGame == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
count := uutil.GetInt64(k.Doc_count)
|
|
|
|
|
profit := uutil.GetInt64(k.Sub2.Value)
|
|
|
|
|
totalCount += count
|
|
|
|
|
totalProfit += profit
|
|
|
|
|
games = append(games, values.UserGameInfo{
|
|
|
|
|
GameName: thisGame.Name + fmt.Sprintf("(%d)", thisGame.GameID),
|
|
|
|
|
GameCount: count,
|
|
|
|
|
Profit: profit,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
ret[provider.ProviderName] = games
|
|
|
|
|
}
|
|
|
|
|
ret["总计"] = []values.UserGameInfo{{GameCount: totalCount, Profit: totalProfit}}
|
|
|
|
|
return ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// func getUserGameData(uid int, gameId *int, win, lost *bool) values.UserGameInfo {
|
|
|
|
|
// var userGameInfo values.UserGameInfo
|
|
|
|
|
// if gameId == nil {
|
|
|
|
|
// userGameInfo.GameId = 0
|
|
|
|
|
// } else {
|
|
|
|
|
// userGameInfo.GameId = *gameId
|
|
|
|
|
// }
|
|
|
|
|
// userGameInfo.GameCount = models.GetWinGameCountByBalance(nil, nil, &uid, nil, gameId, nil, nil)
|
|
|
|
|
// userGameInfo.WinCount = models.GetWinGameCountByBalance(nil, nil, &uid, nil, gameId, nil, win)
|
|
|
|
|
// userGameInfo.LoseCount = models.GetWinGameCountByBalance(nil, nil, &uid, nil, gameId, nil, lost)
|
|
|
|
|
|
|
|
|
|
// userGameInfo.Profit = models.GetGameProfitByUid(nil, nil, &uid, nil, gameId, nil, nil)
|
|
|
|
|
// userGameInfo.WinProfit = models.GetGameProfitByUid(nil, nil, &uid, nil, gameId, nil, win)
|
|
|
|
|
// userGameInfo.LoseProfit = models.GetGameProfitByUid(nil, nil, &uid, nil, gameId, nil, lost)
|
|
|
|
|
// userGameInfo.WinPer = util.GetPer(userGameInfo.WinCount, userGameInfo.GameCount)
|
|
|
|
|
|
|
|
|
|
// return userGameInfo
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
func ShareData(c *gin.Context) {
|
|
|
|
|
a := app.NewApp(c)
|
|
|
|
|
defer func() {
|
|
|
|
|
a.Response()
|
|
|
|
|
}()
|
|
|
|
|
req := new(values.ShareDataReq)
|
|
|
|
|
if !a.S(req) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
resp := &values.ShareDataResp{}
|
|
|
|
|
a.Data = resp
|
|
|
|
|
for i := 1; i <= 3; i++ {
|
|
|
|
|
resp.List = append(resp.List, values.OneShareData{
|
|
|
|
|
Level: i,
|
|
|
|
|
ShareCount: call.GetUserShares(req.UID, i),
|
|
|
|
|
RechargeCount: call.GetUserShareRecharges(req.UID, i),
|
|
|
|
|
ValidRechargeCount: call.GetUserShareValidRecharges(req.UID, i),
|
|
|
|
|
TotalRecharge: call.GetUserShareRechargeAmount(req.UID, i),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|