Merge remote-tracking branch 'origin/develop' into dev_slots

This commit is contained in:
tomas 2024-12-23 13:22:33 +08:00
commit 4b8093d09e
19 changed files with 784 additions and 720 deletions

View File

@ -231,6 +231,7 @@ type LabaLog struct {
PlayerListLog *SaveGamePlayerListLogCopy
GameDetailLog *SaveGameDetailedCopy
CacheTime time.Time // 缓存时间
noEmpty bool
}
// Cache 临时缓存
@ -238,17 +239,30 @@ func (l *LabaLog) Cache(s *Scene, detailLog *SaveGameDetailedParam, playerListLo
if s == nil {
return
}
l.Save(2) // 如果没有收到结束消息算2秒游戏时长
detailLog.OnlyLog = true
playerListLog.OnlyLog = true
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
l.CacheTime = time.Now()
l.noEmpty = true
}
// Save 保存
// second 为0时自动计算时间,从开始转动计时
func (l *LabaLog) Save(second int32) {
if !l.noEmpty {
return
}
if second <= 0 {
second = int32(time.Now().Sub(l.CacheTime).Seconds())
sub := time.Now().Sub(l.CacheTime).Milliseconds()
if sub <= 1000 {
second = 1
} else {
second = int32(sub / 1000)
}
}
if l.PlayerListLog != nil {
@ -272,6 +286,7 @@ func (l *LabaLog) Save(second int32) {
// Clear 清空
func (l *LabaLog) Clear() {
l.noEmpty = false
l.PlayerListLog = nil
l.GameDetailLog = nil
l.CacheTime = time.Time{}

View File

@ -8,6 +8,7 @@ import (
type FortuneDragonPlayerData struct {
*base.Player
base.LabaLog
leaveTime int32 //离开时间
SlotsSession *base.SlotsSession
@ -31,6 +32,7 @@ func (p *FortuneDragonPlayerData) Clear() {
p.taxCoin = 0
p.winCoin = 0
p.currentLogId = ""
p.LabaLog.Clear()
}
// 需要带到world上进行数据处理

View File

@ -112,6 +112,7 @@ func (this *ScenePolicyFortuneDragon) OnPlayerLeave(s *base.Scene, p *base.Playe
}
logger.Logger.Trace("(this *ScenePolicyFortuneDragon) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
if playerEx, ok := p.ExtraData.(*FortuneDragonPlayerData); ok {
playerEx.Save(2)
m := playerEx.PushPlayer()
if m != nil && len(m) > 0 {
b, err := json.Marshal(m)
@ -476,6 +477,8 @@ func (this *SceneStateStartFortuneDragon) OnPlayerOp(s *base.Scene, p *base.Play
// 记录本次操作
FortuneDragonAndSaveLog(sceneEx, playerEx, data)
case 1000:
playerEx.Save(0)
}
}
}
@ -520,11 +523,6 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
if err == nil {
logid, _ := model.AutoIncGameLogId()
playerEx.currentLogId = logid
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
GameTime: 2,
})
var totalin, totalout int64
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
totalin = playerEx.totalBet
@ -532,7 +530,10 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
totalout = int64(data.RoundReward) + playerEx.taxCoin
}
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
}, &base.SaveGamePlayerListLogParam{
LogId: logid,
Platform: playerEx.Platform,
Snid: playerEx.SnId,
@ -544,7 +545,6 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
IsFree: playerEx.isFree,
GameTime: 2,
})
}
}

View File

@ -8,6 +8,7 @@ import (
type FortuneMousePlayerData struct {
*base.Player
base.LabaLog
leaveTime int32 //离开时间
SlotsSession *base.SlotsSession
@ -37,6 +38,7 @@ func (p *FortuneMousePlayerData) Clear() {
p.taxCoin = 0
p.winCoin = 0
p.currentLogId = ""
p.LabaLog.Clear()
}
// 需要带到world上进行数据处理

View File

@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneMouse) OnPlayerLeave(s *base.Scene, p *base.Player
}
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
if playerEx, ok := p.ExtraData.(*FortuneMousePlayerData); ok {
playerEx.Save(2)
m := playerEx.PushPlayer()
if m != nil && len(m) > 0 {
b, err := json.Marshal(m)
@ -480,6 +481,8 @@ func (this *SceneStateStartFortuneMouse) OnPlayerOp(s *base.Scene, p *base.Playe
// 记录本次操作
FortuneMouseAndSaveLog(sceneEx, playerEx, data)
case 1000:
playerEx.Save(0)
}
}
}
@ -531,11 +534,6 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
if err == nil {
logid, _ := model.AutoIncGameLogId()
playerEx.currentLogId = logid
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
GameTime: 2,
})
var totalin, totalout int64
if respinStatus == 0 || respinStatus == 1 {
totalin = playerEx.totalBet
@ -543,7 +541,10 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
if respinStatus == 0 || respinStatus == 3 {
totalout = int64(data.RoundReward) + playerEx.taxCoin
}
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
}, &base.SaveGamePlayerListLogParam{
LogId: logid,
Platform: playerEx.Platform,
Snid: playerEx.SnId,
@ -551,11 +552,10 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
TotalIn: totalin,
TotalOut: totalout,
TaxCoin: playerEx.taxCoin,
BetAmount: playerEx.totalBet,
BetAmount: totalin,
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
IsFree: totalin == 0,
GameTime: 2,
})
}
}

View File

@ -8,6 +8,7 @@ import (
type FortuneOxPlayerData struct {
*base.Player
base.LabaLog
leaveTime int32 //离开时间
SlotsSession *base.SlotsSession
@ -37,6 +38,7 @@ func (p *FortuneOxPlayerData) Clear() {
p.taxCoin = 0
p.winCoin = 0
p.currentLogId = ""
p.LabaLog.Clear()
}
// 需要带到world上进行数据处理

View File

@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneOx) OnPlayerLeave(s *base.Scene, p *base.Player, r
}
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
if playerEx, ok := p.ExtraData.(*FortuneOxPlayerData); ok {
playerEx.Save(2)
m := playerEx.PushPlayer()
if m != nil && len(m) > 0 {
b, err := json.Marshal(m)
@ -480,6 +481,8 @@ func (this *SceneStateStartFortuneOx) OnPlayerOp(s *base.Scene, p *base.Player,
// 记录本次操作
FortuneOxAndSaveLog(sceneEx, playerEx, data)
case 1000:
playerEx.Save(0)
}
}
}
@ -531,11 +534,6 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
if err == nil {
logid, _ := model.AutoIncGameLogId()
playerEx.currentLogId = logid
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
GameTime: 2,
})
var totalin, totalout int64
if respinStatus == 0 || respinStatus == 1 {
totalin = playerEx.totalBet
@ -543,7 +541,10 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
if respinStatus == 0 || respinStatus == 3 {
totalout = int64(data.RoundReward) + playerEx.taxCoin
}
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
}, &base.SaveGamePlayerListLogParam{
LogId: logid,
Platform: playerEx.Platform,
Snid: playerEx.SnId,
@ -555,7 +556,6 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
IsFree: totalin == 0,
GameTime: 2,
})
}
}

View File

@ -8,6 +8,7 @@ import (
type FortuneRabbitPlayerData struct {
*base.Player
base.LabaLog
leaveTime int32 //离开时间
SlotsSession *base.SlotsSession
@ -31,6 +32,7 @@ func (p *FortuneRabbitPlayerData) Clear() {
p.taxCoin = 0
p.winCoin = 0
p.currentLogId = ""
p.LabaLog.Clear()
}
// 需要带到world上进行数据处理

View File

@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneRabbit) OnPlayerLeave(s *base.Scene, p *base.Playe
}
logger.Logger.Trace("(this *ScenePolicyFortuneRabbit) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
if playerEx, ok := p.ExtraData.(*FortuneRabbitPlayerData); ok {
playerEx.LabaLog.Save(2) // 没有收到结束消息算2秒游戏时长
m := playerEx.PushPlayer()
if m != nil && len(m) > 0 {
b, err := json.Marshal(m)
@ -474,6 +475,9 @@ func (this *SceneStateStartFortuneRabbit) OnPlayerOp(s *base.Scene, p *base.Play
// 记录本次操作
FortuneRabbitAndSaveLog(sceneEx, playerEx, data)
case 1000:
playerEx.Save(0)
}
}
}
@ -518,11 +522,6 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
if err == nil {
logid, _ := model.AutoIncGameLogId()
playerEx.currentLogId = logid
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
GameTime: 2,
})
var totalin, totalout int64
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
totalin = playerEx.totalBet
@ -530,7 +529,10 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
totalout = int64(data.RoundReward) + playerEx.taxCoin
}
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
}, &base.SaveGamePlayerListLogParam{
LogId: logid,
Platform: playerEx.Platform,
Snid: playerEx.SnId,
@ -542,7 +544,6 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
IsFree: playerEx.isFree,
GameTime: 2,
})
}
}

View File

@ -8,6 +8,7 @@ import (
type FortuneTigerPlayerData struct {
*base.Player
base.LabaLog
leaveTime int32 //离开时间
SlotsSession *base.SlotsSession
@ -40,6 +41,7 @@ func (p *FortuneTigerPlayerData) Clear() {
p.taxCoin = 0
p.winCoin = 0
p.currentLogId = ""
p.LabaLog.Clear()
}
// 需要带到world上进行数据处理

View File

@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneTiger) OnPlayerLeave(s *base.Scene, p *base.Player
}
logger.Logger.Trace("(this *ScenePolicyFortuneTiger) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
if playerEx, ok := p.ExtraData.(*FortuneTigerPlayerData); ok {
playerEx.LabaLog.Save(2) // 没有收到结束消息算2秒游戏时长
m := playerEx.PushPlayer()
if m != nil && len(m) > 0 {
b, err := json.Marshal(m)
@ -480,6 +481,9 @@ func (this *SceneStateStartFortuneTiger) OnPlayerOp(s *base.Scene, p *base.Playe
// 记录本次操作
FortuneTigerAndSaveLog(sceneEx, playerEx, data)
case 1000:
playerEx.Save(0)
}
}
}
@ -531,11 +535,6 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
if err == nil {
logid, _ := model.AutoIncGameLogId()
playerEx.currentLogId = logid
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
GameTime: 2,
})
var totalin, totalout int64
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
totalin = playerEx.totalBet
@ -543,7 +542,10 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
totalout = int64(data.RoundReward) + playerEx.taxCoin
}
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
LogId: logid,
Detail: info,
}, &base.SaveGamePlayerListLogParam{
LogId: logid,
Platform: playerEx.Platform,
Snid: playerEx.SnId,
@ -555,7 +557,6 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
IsFree: totalin == 0,
GameTime: 2,
})
}
}

File diff suppressed because it is too large Load Diff

View File

@ -513,6 +513,8 @@ message ASQueryOnlineReportList{
int32 OrderType = 6;// 0, 1
int32 GameFreeId = 7;
string Channel = 8;
string GameDif = 9; //
string ChannelId = 10; // 广ID
}
message SAQueryOnlineReportList{
TagCode Tag = 1; //

View File

@ -9,13 +9,13 @@ const (
)
type LogLogin struct {
ID uint `gorm:"primaryKey"`
Snid int `gorm:"index"`
OnlineType int `gorm:"index"`
//OnlineTs int `gorm:"index"`
ID uint `gorm:"primaryKey"`
Snid int `gorm:"index"`
OnlineType int `gorm:"index"`
OnlineTs int64 `gorm:"index"`
OnlineTime time.Time `gorm:"index"`
OfflineType int `gorm:"index"`
//OfflineTs int `gorm:"index"`
OfflineTs int64 `gorm:"index"`
OfflineTime time.Time `gorm:"index"`
ChannelId string `gorm:"index"` // 推广渠道

View File

@ -8,8 +8,8 @@ var Tables = []interface{}{
&LogLogin{},
&LogLoginMid{},
&UserAccount{},
&UserLogin{},
&UserID{},
//&UserLogin{},
//&UserID{},
&LogInviteScoreMid{},
&LogInviteScore{},
&LogInviteUser{},

View File

@ -8,6 +8,7 @@ type UserAccount struct {
Snid int `gorm:"index"`
//RegisterTs int `gorm:"index"`
RegisterTime time.Time `gorm:"index"`
RegisterTs int64 `gorm:"index"`
ChannelId string `gorm:"index"` // 推广渠道
DeviceName string `gorm:"index"`

View File

@ -91,12 +91,12 @@ func LogLogin(platform string, batchSize int) ([]*mysqlmodel.LogLogin, error) {
if n == 0 {
e = &mysqlmodel.LogLogin{
Snid: int(v.SnId),
OnlineType: onlineType,
//OnlineTs: int(v.Ts),
OnlineTime: v.Time,
OfflineType: 0,
//OfflineTs: 0,
Snid: int(v.SnId),
OnlineType: onlineType,
OnlineTs: v.Time.Unix(),
OnlineTime: v.Time,
OfflineType: 0,
OfflineTs: 0,
OfflineTime: v.Time,
DeviceName: v.DeviceName,
AppVersion: v.AppVersion,
@ -132,7 +132,7 @@ func LogLogin(platform string, batchSize int) ([]*mysqlmodel.LogLogin, error) {
}
e.OfflineType = mysqlmodel.LogTypeOffline
//e.OfflineTs = int(v.Ts)
e.OfflineTs = v.Time.Unix()
e.OfflineTime = v.Time
if err = db.Model(e).Select("OfflineType", "OfflineTime").Updates(e).Error; err != nil {
logger.Logger.Errorf("mysql: SyncLogLogin failed to update log_login: %v", err)

View File

@ -68,9 +68,9 @@ func UserAccount(platform string, batchSize int) ([]*mysqlmodel.UserAccount, err
for _, v := range accounts {
logger.Logger.Tracef("mongo account: %+v", *v)
a := &mysqlmodel.UserAccount{
MID: v.AccountId.Hex(),
Snid: int(v.SnId),
//RegisterTs: int(v.RegisterTs),
MID: v.AccountId.Hex(),
Snid: int(v.SnId),
RegisterTs: v.RegisteTime.Unix(),
RegisterTime: v.RegisteTime,
Tel: v.Tel,
ChannelId: v.ChannelId,
@ -81,17 +81,17 @@ func UserAccount(platform string, batchSize int) ([]*mysqlmodel.UserAccount, err
return err
}
if err = tx.First(&mysqlmodel.UserID{}, "snid = ?", v.SnId).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
logger.Logger.Errorf("mysql: UserAccount failed to find user_id: %v", err)
return err
}
if errors.Is(err, gorm.ErrRecordNotFound) {
if err = tx.Create(&mysqlmodel.UserID{Snid: int(v.SnId)}).Error; err != nil {
logger.Logger.Errorf("mysql: UserAccount failed to create user_id: %v", err)
return err
}
}
//if err = tx.First(&mysqlmodel.UserID{}, "snid = ?", v.SnId).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
// logger.Logger.Errorf("mysql: UserAccount failed to find user_id: %v", err)
// return err
//}
//
//if errors.Is(err, gorm.ErrRecordNotFound) {
// if err = tx.Create(&mysqlmodel.UserID{Snid: int(v.SnId)}).Error; err != nil {
// logger.Logger.Errorf("mysql: UserAccount failed to create user_id: %v", err)
// return err
// }
//}
as = append(as, a)
}

View File

@ -1113,12 +1113,10 @@ func init() {
pack.Msg = "数据序列化失败" + err.Error()
return common.ResponseTag_ParamError, pack
}
platform := msg.Platform
pageNo := msg.PageNo
pageSize := msg.PageSize
orderColumn := msg.OrderColumn
orderType := msg.OrderType
channel := msg.Channel
start := (pageNo - 1) * pageSize
end := pageNo * pageSize
@ -1132,21 +1130,37 @@ func init() {
if !p.IsOnLine() {
continue
}
if msg.GameFreeId == 0 {
if msg.GameId != 0 && (p.scene == nil || p.scene.gameId != int(msg.GameId)) {
continue
}
} else {
if p.scene == nil || p.scene.dbGameFree.GetId() != msg.GameFreeId {
if msg.GameDif != "" {
if p.scene == nil || p.scene.dbGameFree.GetGameDif() != msg.GameDif {
continue
}
}
if platform != DefaultPlatform && p.Platform != platform {
continue
}
if channel != "" && p.Channel != channel {
if msg.ChannelId != "" {
if p.ChannelId != msg.ChannelId {
continue
}
}
if msg.GameFreeId > 0 {
if p.scene == nil || p.scene.GetGameFreeId() != msg.GameFreeId {
continue
}
}
if msg.GameId > 0 {
if p.scene == nil || p.scene.gameId != int(msg.GameId) {
continue
}
}
if msg.Platform != DefaultPlatform && msg.Platform != "" {
if p.Platform != msg.Platform {
continue
}
}
if msg.Channel != "" && p.Channel != msg.Channel {
continue
}
players = append(players, p)
}
// 排序