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.
183 lines
5.1 KiB
183 lines
5.1 KiB
package guser |
|
|
|
import ( |
|
"fmt" |
|
"github.com/olivere/elastic/v7" |
|
"server/call" |
|
"server/common" |
|
"server/db" |
|
"server/modules/backend/values" |
|
"server/modules/customer/app" |
|
"strconv" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
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} |
|
err = db.Mysql().Get(info) |
|
if err != nil { |
|
log.Error(err.Error()) |
|
} |
|
// control := &common.PlayerControl{UID: uid} |
|
// err = db.Mysql().Get(control) |
|
// if err != nil { |
|
// log.Error(err.Error()) |
|
// } |
|
// lg := &common.LoginRecord{UID: uid} |
|
// err = db.Mysql().GetLast(lg) |
|
// if err != nil { |
|
// log.Error(err.Error()) |
|
// } |
|
|
|
//pointControl := &common.ConfigPointControl{UID: uid} |
|
//db.Mysql().Get(pointControl) |
|
// per := 0 |
|
// tar := "" |
|
// if control.NewControlFin == 1 { |
|
// if control.NewControlLevel == 0 { |
|
// control.NewControlLevel = 1 |
|
// } |
|
// con := call.GetNewControlConfigByID(control.NewControlLevel) |
|
// if con != nil { |
|
// control.TargetValue = con.ControlNum |
|
// per = con.ControlPer |
|
// tar = fmt.Sprintf("%v", control.TargetValue) |
|
// } |
|
// } else { |
|
// if control.ControlSection > 0 { |
|
// re := &common.RechargeInfo{UID: uid} |
|
// db.Mysql().Get(re) |
|
// con := call.GetSignleControlConfigByRecharge(re.TotalCharge) |
|
// if con != nil { |
|
// rcon := reflect.ValueOf(con).Elem() |
|
// per = int(rcon.FieldByName(fmt.Sprintf("ControlPer%v", control.ControlSection)).Int()) |
|
// } |
|
// } |
|
// tar = uutil.FormatFloat(float64(control.TargetValue)/100, 2) |
|
// } |
|
//black := &common.ConfigMillionBlack{UID: uid} |
|
//db.Mysql().Get(black) |
|
resp := values.GetGameUserInfoResp{ |
|
UID: user.Id, |
|
Nick: user.Nick, |
|
//Recharge: info.TotalCharge, |
|
//Withdraw: info.TotoalWithdraw, |
|
Channel: user.ChannelID, |
|
Phone: user.Mobile, |
|
OpenID: *user.Openid, |
|
//Cash: user.Cash, |
|
//Total: user.BindCash + user.Cash, |
|
Online: ur.Online == common.PlayerOnline, |
|
Status: user.Status, |
|
Birth: user.Birth, |
|
// PlayCount: util.GetGUserPlayCount(uid), |
|
IP: user.IP, |
|
LastLogin: user.LastLogin, |
|
Tag: user.Tag, |
|
// IsFinishNewControl: control.NewControlFin == 2, |
|
// NewControlLevel: control.NewControlLevel, |
|
// ControlLevel: control.ControlLevel, |
|
// ControlSection: control.ControlSection, |
|
// ControlValue: uutil.FormatFloat(float64(control.ControlValue)/100, 2), |
|
// ControlPer: per, |
|
// TargetValue: tar, |
|
// FreeAmount: uutil.FormatFloat(float64(control.FreeAmount)/100, 2), |
|
//PointControlValue: uutil.FormatFloat(float64(pointControl.CurControlNum)/100, 2), |
|
//PointControlTargetValue: uutil.FormatFloat(float64(pointControl.ControlNum), 2), |
|
//PointControlPer: pointControl.ControlPer, |
|
UserGameData: GetUserGameInfo(user.Id), |
|
//Gpsadid: user.DeviceId, |
|
//Black: black, |
|
} |
|
|
|
var tmpUser []common.PlayerDBInfo |
|
_, err = db.Mysql().QueryAll(fmt.Sprintf("deviceid = '%s'", user.DeviceId), "", &common.PlayerDBInfo{}, &tmpUser) |
|
if err != nil { |
|
log.Error(err.Error()) |
|
} |
|
for _, v := range tmpUser { |
|
resp.SubAccount = append(resp.SubAccount, v.Id) |
|
} |
|
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 |
|
}
|
|
|