休闲平台每局详情功能

This commit is contained in:
DESKTOP-45ANQ2C\unis 2024-12-31 16:09:13 +08:00
parent a64c341e82
commit 4ffdb28075
8 changed files with 117 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package svc
import ( import (
"errors" "errors"
"mongo.games.com/game/common"
"net/rpc" "net/rpc"
"time" "time"
@ -173,6 +174,20 @@ func (svc *CoinLogSvc) UpdateCoinLogRemark(args *model.UpdateCoinLogRemarkArg, r
return return
} }
func (svc *CoinLogSvc) GetCoinLogAllInTime(args *model.GetCoinLogGameReq, ret *model.GetCoinLogGameRet) (err error) {
plt := args.Plt
startts := args.StartTs
endts := args.EndTs
billType := args.BillType // 0金币 1钻石
logtypeConds := [...]int32{common.GainWayPlatformUpScore, common.GainWayPlatformUpScore}
ret.Count, _ = CoinLogsCollection(plt).Find(bson.M{"cointype": billType, "ts": bson.M{"$gte": startts, "$lte": endts}}).Count()
err = CoinLogsCollection(plt).Find(bson.M{"cointype": billType, "logtype": bson.M{"$nin": logtypeConds}, "ts": bson.M{"$gte": startts, "$lte": endts}}).Sort("-time").All(&ret.Logs)
return
}
func init() { func init() {
rpc.Register(new(CoinLogSvc)) rpc.Register(new(CoinLogSvc))
} }

View File

@ -461,6 +461,7 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: this.Platform, Platform: this.Platform,
SnID: this.SnId, SnID: this.SnId,
UserName: this.Username,
Channel: this.Channel, Channel: this.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: num, ChangeNum: num,
@ -544,6 +545,7 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: this.Platform, Platform: this.Platform,
SnID: this.SnId, SnID: this.SnId,
UserName: this.Username,
Channel: this.Channel, Channel: this.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: num, ChangeNum: num,

View File

@ -21,6 +21,7 @@ var COINEX_GLOBAL_SEQ = int64(0)
type CoinLog struct { type CoinLog struct {
LogId bson.ObjectId `bson:"_id"` LogId bson.ObjectId `bson:"_id"`
SnId int32 //玩家id SnId int32 //玩家id
UserName string // 账号
Platform string //平台名称 Platform string //平台名称
Channel string //渠道名称 Channel string //渠道名称
Promoter string //推广员 Promoter string //推广员
@ -48,6 +49,7 @@ type CoinLog struct {
type CoinLogV1 struct { type CoinLogV1 struct {
LogId bson.ObjectId `bson:"_id"` LogId bson.ObjectId `bson:"_id"`
SnId int32 //玩家id SnId int32 //玩家id
UserName string // 账号
Platform string //平台名称 Platform string //平台名称
Channel string //渠道名称 Channel string //渠道名称
Promoter string //推广员 Promoter string //推广员
@ -76,6 +78,7 @@ func NewCoinLog() *CoinLog {
type CoinLogParam struct { type CoinLogParam struct {
Platform string // 平台id Platform string // 平台id
SnID int32 // 玩家id SnID int32 // 玩家id
UserName string // 账号
Channel string // 渠道 Channel string // 渠道
ChangeType int32 // 变化类型 common.BillTypeCoin 金币 common.BillTypeDiamond 钻石 ChangeType int32 // 变化类型 common.BillTypeCoin 金币 common.BillTypeDiamond 钻石
ChangeNum int64 // 变化数量 ChangeNum int64 // 变化数量
@ -94,6 +97,7 @@ func NewCoinLogEx(param *CoinLogParam) *CoinLog {
cl := NewCoinLog() cl := NewCoinLog()
cl.Platform = param.Platform cl.Platform = param.Platform
cl.SnId = param.SnID cl.SnId = param.SnID
cl.UserName = param.UserName
cl.Channel = param.Channel cl.Channel = param.Channel
cl.Count = param.ChangeNum cl.Count = param.ChangeNum
cl.Oper = param.Operator cl.Oper = param.Operator
@ -126,6 +130,7 @@ func NewCoinLogExV1(param *CoinLogParam) *CoinLogV1 {
cl := CoinLogV1{ cl := CoinLogV1{
LogId: bson.NewObjectId(), LogId: bson.NewObjectId(),
SnId: param.SnID, SnId: param.SnID,
UserName: param.UserName,
Platform: param.Platform, Platform: param.Platform,
Channel: "", Channel: "",
Promoter: "", Promoter: "",
@ -332,3 +337,29 @@ func UpdateCoinLogRemark(plt string, id bson.ObjectId, remark string) error {
} }
return err return err
} }
func GetCoinAllLogInTime(plt string, billType int, startts, endts int64, fromIndex, toIndex int) (logs []CoinLog, count int, err error) {
if rpcCli == nil {
logger.Logger.Error("model.GetCoinLogGame rpcCli == nil")
return
}
args := &GetCoinLogGameReq{
Plt: plt,
BillType: billType,
FromIdx: fromIndex,
ToIdx: toIndex,
StartTs: startts,
EndTs: endts,
}
var ret GetCoinLogGameRet
err = rpcCli.CallWithTimeout("CoinLogSvc.GetCoinLogAllInTime", args, &ret, time.Second*30)
if err != nil {
logger.Logger.Warn("GetCoinLogGame error:", err)
return
}
logs = ret.Logs
count = ret.Count
return
}

View File

@ -312,17 +312,30 @@ type PlatfromPlayerStatusRsp struct {
// 查询玩家游戏状态请求 // 查询玩家游戏状态请求
type PlatfromGamedetailReq struct { type PlatfromGamedetailReq struct {
Username string `json:"username"`
Channel string `json:"channel"` Channel string `json:"channel"`
Timestamp string `json:"timestamp"` Timestamp string `json:"timestamp"`
Start string `json:"start"`
End string `json:"end"`
}
type PlatfromPlayerScoreInfo struct {
SnId int32 `json:"snid"` //用户Id
UserName string `json:"username"` // 账号
BeforeCount int64 `json:"beforecount"` //账号变化前数量
Count int64 `json:"count"` //帐变数量
RestCount int64 `json:"resetcount"` //余额
CoinAdd int64 `json:"coinadd"` //金币加成
BaseCoin int64 `json:"basecoin"` //底分
LogType int32 `json:"logtype"` //账变类型
Remark string `json:"remark"` //备注
GameEndTime string `json:"gameendtime"` //游戏结束时间
} }
// 查询游戏状态返回 // 查询游戏状态返回
type PlatfromGamedetaiRsp struct { type PlatfromGamedetaiRsp struct {
Code int `json:"code"` Code int `json:"code"`
Data struct { Data struct {
In int `json:"in"` //当局投入 PlayersInfo []PlatfromPlayerScoreInfo `json:"playersinfo"`
Out int `json:"out"` //当局收入
} `json:"data"` } `json:"data"`
Message string `json:"message"` Message string `json:"message"`
Success bool `json:"success"` Success bool `json:"success"`

View File

@ -1436,6 +1436,7 @@ func (this *CSPlayerRegisterHandler) Process(s *netlib.Session, packetid int, da
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: pi.Platform, Platform: pi.Platform,
SnID: pi.SnId, SnID: pi.SnId,
UserName: pi.Username,
Channel: pi.Channel, Channel: pi.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: int64(model.GameParamData.NewPlayerCoin), ChangeNum: int64(model.GameParamData.NewPlayerCoin),

View File

@ -1414,6 +1414,7 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: this.Platform, Platform: this.Platform,
SnID: this.SnId, SnID: this.SnId,
UserName: this.Username,
Channel: this.Channel, Channel: this.Channel,
ChangeType: common.BillTypeDiamond, ChangeType: common.BillTypeDiamond,
ChangeNum: num, ChangeNum: num,
@ -1469,6 +1470,7 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: this.Platform, Platform: this.Platform,
SnID: this.SnId, SnID: this.SnId,
UserName: this.Username,
Channel: this.Channel, Channel: this.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: num, ChangeNum: num,
@ -1524,6 +1526,7 @@ func (this *Player) AddCoinAsync(num, add int64, gainWay int32, oper, remark str
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: this.Platform, Platform: this.Platform,
SnID: this.SnId, SnID: this.SnId,
UserName: this.Username,
Channel: this.Channel, Channel: this.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: num, ChangeNum: num,

View File

@ -227,6 +227,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: playerData.Platform, Platform: playerData.Platform,
SnID: playerData.SnId, SnID: playerData.SnId,
UserName: playerData.Username,
Channel: playerData.Channel, Channel: playerData.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: int64(model.GameParamData.NewPlayerCoin), ChangeNum: int64(model.GameParamData.NewPlayerCoin),
@ -260,6 +261,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: playerData.Platform, Platform: playerData.Platform,
SnID: playerData.SnId, SnID: playerData.SnId,
UserName: playerData.Username,
Channel: playerData.Channel, Channel: playerData.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: coin, ChangeNum: coin,
@ -287,6 +289,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
log := model.NewCoinLogEx(&model.CoinLogParam{ log := model.NewCoinLogEx(&model.CoinLogParam{
Platform: playerData.Platform, Platform: playerData.Platform,
SnID: playerData.SnId, SnID: playerData.SnId,
UserName: playerData.Username,
Channel: playerData.Channel, Channel: playerData.Channel,
ChangeType: common.BillTypeDiamond, ChangeType: common.BillTypeDiamond,
ChangeNum: diamond, ChangeNum: diamond,

View File

@ -236,6 +236,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: player.Platform, Platform: player.Platform,
SnID: player.SnId, SnID: player.SnId,
UserName: player.Username,
Channel: player.Channel, Channel: player.Channel,
ChangeType: msg.GetLogType(), ChangeType: msg.GetLogType(),
ChangeNum: msg.GetGold(), ChangeNum: msg.GetGold(),
@ -322,6 +323,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: findPlayer.Platform, Platform: findPlayer.Platform,
SnID: findPlayer.SnId, SnID: findPlayer.SnId,
UserName: findPlayer.Username,
Channel: findPlayer.Channel, Channel: findPlayer.Channel,
ChangeType: msg.GetLogType(), ChangeType: msg.GetLogType(),
ChangeNum: msg.GetGold(), ChangeNum: msg.GetGold(),
@ -3022,6 +3024,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: player.Platform, Platform: player.Platform,
SnID: player.SnId, SnID: player.SnId,
UserName: player.Username,
Channel: player.Channel, Channel: player.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: addcoin, ChangeNum: addcoin,
@ -3031,6 +3034,8 @@ func init() {
GameID: 0, GameID: 0,
GameFreeID: 0, GameFreeID: 0,
BaseCoin: 0, BaseCoin: 0,
Operator: "休闲平台",
Remark: "在线平台上分",
}) })
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
@ -3083,6 +3088,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: findPlayer.Platform, Platform: findPlayer.Platform,
SnID: findPlayer.SnId, SnID: findPlayer.SnId,
UserName: msg.Username,
Channel: findPlayer.Channel, Channel: findPlayer.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: addcoin, ChangeNum: addcoin,
@ -3092,6 +3098,8 @@ func init() {
GameID: 0, GameID: 0,
GameFreeID: 0, GameFreeID: 0,
BaseCoin: 0, BaseCoin: 0,
Operator: "休闲平台",
Remark: "不在线平台上分",
}) })
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin, err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin,
@ -3187,6 +3195,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: player.Platform, Platform: player.Platform,
SnID: player.SnId, SnID: player.SnId,
UserName: player.Username,
Channel: player.Channel, Channel: player.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: -player.Coin, ChangeNum: -player.Coin,
@ -3196,6 +3205,8 @@ func init() {
GameID: 0, GameID: 0,
GameFreeID: 0, GameFreeID: 0,
BaseCoin: 0, BaseCoin: 0,
Operator: "休闲平台",
Remark: "在线平台下分",
}) })
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
@ -3251,6 +3262,7 @@ func init() {
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: findPlayer.Platform, Platform: findPlayer.Platform,
SnID: findPlayer.SnId, SnID: findPlayer.SnId,
UserName: msg.Username,
Channel: findPlayer.Channel, Channel: findPlayer.Channel,
ChangeType: common.BillTypeCoin, ChangeType: common.BillTypeCoin,
ChangeNum: addcoin, ChangeNum: addcoin,
@ -3260,6 +3272,8 @@ func init() {
GameID: 0, GameID: 0,
GameFreeID: 0, GameFreeID: 0,
BaseCoin: 0, BaseCoin: 0,
Operator: "休闲平台",
Remark: "不在线平台下分",
}) })
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin, err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin,
@ -3398,12 +3412,41 @@ func init() {
logger.Logger.Tracef("/api/platform/getgamedetailed %v", pack) logger.Logger.Tracef("/api/platform/getgamedetailed %v", pack)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { startTs, err := strconv.ParseInt(msg.Start, 10, 64)
pack.Success = true if err != nil {
pack.Message = "返回成功" logger.Logger.Error("strconv.ParseInt error:", err)
return common.ResponseTag_ParamError, jsonDataRsp
}
endTs, err := strconv.ParseInt(msg.End, 10, 64)
if err != nil {
logger.Logger.Error("strconv.ParseInt error:", err)
return common.ResponseTag_ParamError, jsonDataRsp
}
var logs []model.CoinLog
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
logs, _, err = model.GetCoinAllLogInTime("1", common.BillTypeCoin, startTs, endTs, 0, 0)
return nil return nil
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
for _, v := range logs {
pack.Data.PlayersInfo = append(pack.Data.PlayersInfo, webapi.PlatfromPlayerScoreInfo{
SnId: v.SnId,
UserName: v.UserName,
Count: v.Count,
RestCount: v.RestCount,
CoinAdd: v.CoinAdd,
BaseCoin: v.BaseCoin,
LogType: v.LogType,
Remark: v.Remark,
BeforeCount: v.RestCount + v.Count,
GameEndTime: v.Time.Format(time.DateTime),
})
}
pack.Code = int(webapiproto.TagCode_SUCCESS)
pack.Success = true
pack.Message = "返回成功"
jsonDataRsp, err = json.Marshal(pack) jsonDataRsp, err = json.Marshal(pack)
if err != nil { if err != nil {