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.
146 lines
4.2 KiB
146 lines
4.2 KiB
package gm |
|
|
|
import ( |
|
"fmt" |
|
"server/call" |
|
"server/common" |
|
"server/db" |
|
"server/modules/backend/models" |
|
"server/modules/backend/values" |
|
"server/modules/customer/app" |
|
uutil "server/util" |
|
"strconv" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
"github.com/olivere/elastic/v7" |
|
) |
|
|
|
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, |
|
} |
|
|
|
// re := call.GetRechargeInfo(uid) |
|
// resp.Recharge = re.TotalRecharge |
|
// resp.Withdraw = re.TotalWithdraw |
|
// resp.NeedBet = call.GetUserNeedBet(uid) |
|
// resp.Cash = call.GetUserCurrency(uid, common.CurrencyINR) |
|
db.Mysql().C().Table("users").Select("id").Where("deviceid = ?", user.DeviceId).Scan(&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.GetConfigGameListByGameID(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 |
|
// }
|
|
|