Compare commits

...

4 Commits

8 changed files with 20 additions and 18 deletions

View File

@ -899,6 +899,6 @@ var GuideIdToGainWay = map[int]int{
GuideIdCustom: GainWayGuide2,
}
func GetGameDifKey(gamedif string) string {
func GetKeyGameDif(gamedif string) string {
return fmt.Sprintf("gamedif-%v", gamedif)
}

View File

@ -653,7 +653,7 @@ func (this *Player) ReportGameEvent(param *ReportGameEventParam) *ReportGameEven
gameTimes = dataGame.Statics.GameTimes
}
dataGameDif, ok := this.GDatas[common.GetGameDifKey(this.scene.GetDBGameFree().GetGameDif())]
dataGameDif, ok := this.GDatas[common.GetKeyGameDif(this.scene.GetDBGameFree().GetGameDif())]
if ok {
gamedifFirstTime = dataGameDif.FirstTime
gamedifTimes = dataGameDif.Statics.GameTimes

View File

@ -2111,7 +2111,7 @@ func (this *Scene) Statistics(param *StaticParam) {
var statics []*model.PlayerGameStatics
keyGameId := strconv.Itoa(this.GetGameId())
keyGameFreeId := strconv.Itoa(int(this.GetGameFreeId()))
keyGameDif := common.GetGameDifKey(this.GetDBGameFree().GetGameDif())
keyGameDif := common.GetKeyGameDif(this.GetDBGameFree().GetGameDif())
// 当天数据统计
// 按场次分
if data, ok := p.TodayGameData.CtrlData[keyGameFreeId]; ok {
@ -2350,7 +2350,7 @@ func (this *Scene) StaticsLaba(param *StaticLabaParam) {
var statics []*model.PlayerGameStatics
keyGameId := strconv.Itoa(this.GetGameId())
keyGameFreeId := strconv.Itoa(int(this.GetGameFreeId()))
keyGameDif := common.GetGameDifKey(this.GetDBGameFree().GetGameDif())
keyGameDif := common.GetKeyGameDif(this.GetDBGameFree().GetGameDif())
// 当天数据统计
// 按场次分
if data, ok := p.TodayGameData.CtrlData[keyGameFreeId]; ok {

View File

@ -8,9 +8,11 @@ type BankruptLog struct {
LogId bson.ObjectId `bson:"_id"`
SnId int32 //玩家id
Channel string // 渠道
ChannelId string // 推广渠道
Platform string //平台名称
GameId int //游戏id
GameFreeID int32 //房间id
GameDif string // 游戏分组
CreateTime int64 // 注册时间
UseCoin int64 // 消耗金币
@ -22,12 +24,14 @@ func NewBankruptLog() *BankruptLog {
return log
}
func NewBankruptLogEx(snid int32, gamefreeid int32, createtime, usecoin int64, platform, channel string, gameId int) *BankruptLog {
func NewBankruptLogEx(snid int32, gamefreeid int32, createtime, usecoin int64, platform, channel, channelId, gamedif string, gameId int) *BankruptLog {
cl := NewBankruptLog()
cl.SnId = snid
cl.Platform = platform
cl.Channel = channel
cl.ChannelId = channelId
cl.GameId = gameId
cl.GameDif = gamedif
cl.GameFreeID = gamefreeid
cl.CreateTime = createtime

View File

@ -45,7 +45,7 @@ func GetNewPayerIds(plt string, startTime, endTime string) ([]int, error) {
return ret, nil
}
func GetPayerIds(plt string, startTime, endTime string) ([]int, error) {
func GetPayerIds(plt string, startTime, endTime string, gamefreeid int) ([]int, error) {
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
c, err := mymongo.GetLogCollection(plt, mongomodel.LogGamePlayerListLog)
if err != nil {
@ -54,7 +54,7 @@ func GetPayerIds(plt string, startTime, endTime string) ([]int, error) {
var res []struct{ Snid int }
dd, err := c.Aggregate(context.TODO(), bson.A{
bson.M{"$match": bson.M{"time": bson.M{"$gte": s, "$lt": e}}},
bson.M{"$match": bson.M{"time": bson.M{"$gte": s, "$lt": e}, "gamefreeid": gamefreeid}},
bson.M{"$group": bson.M{"_id": "$snid", "snid": bson.M{"$first": "$snid"}}},
})
if err != nil {

View File

@ -36,7 +36,10 @@ func NewPlayerGameTime(plt string, ids []int, startTime, endTime string, gamefre
if gamefreeid > 0 {
where["gamefreeid"] = gamefreeid
}
cur, err := c.Find(context.TODO(), where, options.Find().SetProjection(bson.M{"gamedetailedlogid": 1}))
cur, err := c.Aggregate(context.Background(), bson.A{
bson.M{"$match": where},
bson.M{"$group": bson.M{"_id": "$gamedetailedlogid", "gamedetailedlogid": bson.M{"$first": "$gamedetailedlogid"}}},
})
if err != nil {
logger.Logger.Errorf("find player gamedetailedlogid get err: %v", err)
return 0, 0, err
@ -108,7 +111,7 @@ func PlayerGameTimeAvg(plt string, startTime, endTime string, gamefreeid int) (i
if s.IsZero() || e.IsZero() {
return 0, 0, fmt.Errorf("time format error")
}
ids, err := GetPayerIds(plt, startTime, endTime)
ids, err := GetPayerIds(plt, startTime, endTime, gamefreeid)
if err != nil {
return 0, 0, err
}
@ -123,12 +126,5 @@ func PlayerGameTimeAvg(plt string, startTime, endTime string, gamefreeid int) (i
return 0, 0, nil
}
b, err := PlayingGameCount(plt, ids, startTime, endTime, gamefreeid)
if err != nil {
return 0, 0, err
}
if b == 0 {
return 0, 0, nil
}
return b, a, err
return len(ids), a, err
}

View File

@ -134,7 +134,8 @@ func init() {
CostCoin := p.takeCoin - msg.GetReturnCoin()
logger.Logger.Infof("NewBankruptLogEx: snid:%v GetReturnCoin:%v coin:%v CostCoin:%v", p.SnId, msg.GetReturnCoin(), p.takeCoin, CostCoin)
log := model.NewBankruptLogEx(p.SnId, scene.dbGameFree.GetId(), p.CreateTime.Unix(), CostCoin, p.Platform, p.Channel, scene.gameId)
log := model.NewBankruptLogEx(p.SnId, scene.dbGameFree.GetId(), p.CreateTime.Unix(), CostCoin,
p.Platform, p.Channel, p.ChannelId, scene.dbGameFree.GetGameDif(), scene.gameId)
if log != nil {
mq.Write(log)
}

View File

@ -1260,6 +1260,7 @@ func (this *Player) UnmarshalData(data []byte, scene *Scene) {
strconv.Itoa(int(scene.dbGameFree.GetGameId())),
common.GetKeyNoviceGameId(int(scene.dbGameFree.GetGameId())),
common.GetKeyGameType(int(scene.dbGameFree.GetGameType())),
common.GetKeyGameDif(scene.dbGameFree.GetGameDif()),
} {
if d, ok := pd.GDatas[v]; ok {
this.GDatas[v] = d