休闲平台每局详情功能
This commit is contained in:
parent
a64c341e82
commit
4ffdb28075
|
@ -2,6 +2,7 @@ package svc
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"mongo.games.com/game/common"
|
||||
"net/rpc"
|
||||
"time"
|
||||
|
||||
|
@ -173,6 +174,20 @@ func (svc *CoinLogSvc) UpdateCoinLogRemark(args *model.UpdateCoinLogRemarkArg, r
|
|||
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() {
|
||||
rpc.Register(new(CoinLogSvc))
|
||||
}
|
||||
|
|
|
@ -461,6 +461,7 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
UserName: this.Username,
|
||||
Channel: this.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: num,
|
||||
|
@ -544,6 +545,7 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
UserName: this.Username,
|
||||
Channel: this.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: num,
|
||||
|
|
|
@ -21,6 +21,7 @@ var COINEX_GLOBAL_SEQ = int64(0)
|
|||
type CoinLog struct {
|
||||
LogId bson.ObjectId `bson:"_id"`
|
||||
SnId int32 //玩家id
|
||||
UserName string // 账号
|
||||
Platform string //平台名称
|
||||
Channel string //渠道名称
|
||||
Promoter string //推广员
|
||||
|
@ -48,6 +49,7 @@ type CoinLog struct {
|
|||
type CoinLogV1 struct {
|
||||
LogId bson.ObjectId `bson:"_id"`
|
||||
SnId int32 //玩家id
|
||||
UserName string // 账号
|
||||
Platform string //平台名称
|
||||
Channel string //渠道名称
|
||||
Promoter string //推广员
|
||||
|
@ -76,6 +78,7 @@ func NewCoinLog() *CoinLog {
|
|||
type CoinLogParam struct {
|
||||
Platform string // 平台id
|
||||
SnID int32 // 玩家id
|
||||
UserName string // 账号
|
||||
Channel string // 渠道
|
||||
ChangeType int32 // 变化类型 common.BillTypeCoin 金币 common.BillTypeDiamond 钻石
|
||||
ChangeNum int64 // 变化数量
|
||||
|
@ -94,6 +97,7 @@ func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
|||
cl := NewCoinLog()
|
||||
cl.Platform = param.Platform
|
||||
cl.SnId = param.SnID
|
||||
cl.UserName = param.UserName
|
||||
cl.Channel = param.Channel
|
||||
cl.Count = param.ChangeNum
|
||||
cl.Oper = param.Operator
|
||||
|
@ -126,6 +130,7 @@ func NewCoinLogExV1(param *CoinLogParam) *CoinLogV1 {
|
|||
cl := CoinLogV1{
|
||||
LogId: bson.NewObjectId(),
|
||||
SnId: param.SnID,
|
||||
UserName: param.UserName,
|
||||
Platform: param.Platform,
|
||||
Channel: "",
|
||||
Promoter: "",
|
||||
|
@ -332,3 +337,29 @@ func UpdateCoinLogRemark(plt string, id bson.ObjectId, remark string) error {
|
|||
}
|
||||
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
|
||||
}
|
||||
|
|
|
@ -312,17 +312,30 @@ type PlatfromPlayerStatusRsp struct {
|
|||
|
||||
// 查询玩家游戏状态请求
|
||||
type PlatfromGamedetailReq struct {
|
||||
Username string `json:"username"`
|
||||
Channel string `json:"channel"`
|
||||
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 {
|
||||
Code int `json:"code"`
|
||||
Data struct {
|
||||
In int `json:"in"` //当局投入
|
||||
Out int `json:"out"` //当局收入
|
||||
PlayersInfo []PlatfromPlayerScoreInfo `json:"playersinfo"`
|
||||
} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
|
|
|
@ -1436,6 +1436,7 @@ func (this *CSPlayerRegisterHandler) Process(s *netlib.Session, packetid int, da
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: pi.Platform,
|
||||
SnID: pi.SnId,
|
||||
UserName: pi.Username,
|
||||
Channel: pi.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: int64(model.GameParamData.NewPlayerCoin),
|
||||
|
|
|
@ -1414,6 +1414,7 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
UserName: this.Username,
|
||||
Channel: this.Channel,
|
||||
ChangeType: common.BillTypeDiamond,
|
||||
ChangeNum: num,
|
||||
|
@ -1469,6 +1470,7 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
UserName: this.Username,
|
||||
Channel: this.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: num,
|
||||
|
@ -1524,6 +1526,7 @@ func (this *Player) AddCoinAsync(num, add int64, gainWay int32, oper, remark str
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
UserName: this.Username,
|
||||
Channel: this.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: num,
|
||||
|
|
|
@ -227,6 +227,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: playerData.Platform,
|
||||
SnID: playerData.SnId,
|
||||
UserName: playerData.Username,
|
||||
Channel: playerData.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: int64(model.GameParamData.NewPlayerCoin),
|
||||
|
@ -260,6 +261,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: playerData.Platform,
|
||||
SnID: playerData.SnId,
|
||||
UserName: playerData.Username,
|
||||
Channel: playerData.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: coin,
|
||||
|
@ -287,6 +289,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} {
|
|||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: playerData.Platform,
|
||||
SnID: playerData.SnId,
|
||||
UserName: playerData.Username,
|
||||
Channel: playerData.Channel,
|
||||
ChangeType: common.BillTypeDiamond,
|
||||
ChangeNum: diamond,
|
||||
|
|
|
@ -236,6 +236,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: player.Platform,
|
||||
SnID: player.SnId,
|
||||
UserName: player.Username,
|
||||
Channel: player.Channel,
|
||||
ChangeType: msg.GetLogType(),
|
||||
ChangeNum: msg.GetGold(),
|
||||
|
@ -322,6 +323,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: findPlayer.Platform,
|
||||
SnID: findPlayer.SnId,
|
||||
UserName: findPlayer.Username,
|
||||
Channel: findPlayer.Channel,
|
||||
ChangeType: msg.GetLogType(),
|
||||
ChangeNum: msg.GetGold(),
|
||||
|
@ -3022,6 +3024,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: player.Platform,
|
||||
SnID: player.SnId,
|
||||
UserName: player.Username,
|
||||
Channel: player.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: addcoin,
|
||||
|
@ -3031,6 +3034,8 @@ func init() {
|
|||
GameID: 0,
|
||||
GameFreeID: 0,
|
||||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "在线平台上分",
|
||||
})
|
||||
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
|
@ -3083,6 +3088,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: findPlayer.Platform,
|
||||
SnID: findPlayer.SnId,
|
||||
UserName: msg.Username,
|
||||
Channel: findPlayer.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: addcoin,
|
||||
|
@ -3092,6 +3098,8 @@ func init() {
|
|||
GameID: 0,
|
||||
GameFreeID: 0,
|
||||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "不在线平台上分",
|
||||
})
|
||||
|
||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin,
|
||||
|
@ -3187,6 +3195,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: player.Platform,
|
||||
SnID: player.SnId,
|
||||
UserName: player.Username,
|
||||
Channel: player.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: -player.Coin,
|
||||
|
@ -3196,6 +3205,8 @@ func init() {
|
|||
GameID: 0,
|
||||
GameFreeID: 0,
|
||||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "在线平台下分",
|
||||
})
|
||||
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
|
@ -3251,6 +3262,7 @@ func init() {
|
|||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: findPlayer.Platform,
|
||||
SnID: findPlayer.SnId,
|
||||
UserName: msg.Username,
|
||||
Channel: findPlayer.Channel,
|
||||
ChangeType: common.BillTypeCoin,
|
||||
ChangeNum: addcoin,
|
||||
|
@ -3260,6 +3272,8 @@ func init() {
|
|||
GameID: 0,
|
||||
GameFreeID: 0,
|
||||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "不在线平台下分",
|
||||
})
|
||||
|
||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin,
|
||||
|
@ -3398,12 +3412,41 @@ func init() {
|
|||
|
||||
logger.Logger.Tracef("/api/platform/getgamedetailed %v", pack)
|
||||
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
pack.Success = true
|
||||
pack.Message = "返回成功"
|
||||
startTs, err := strconv.ParseInt(msg.Start, 10, 64)
|
||||
if err != nil {
|
||||
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
|
||||
}), 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)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue