Merge branch 'develop' into release

This commit is contained in:
sk 2024-11-06 10:44:07 +08:00
commit 2bbb23e3c7
9 changed files with 149 additions and 12 deletions

View File

@ -6,9 +6,9 @@ stages:
- unlock - unlock
variables: variables:
ProjectPath: "mongo.games.com/game" ProjectPath: "mongo.games.com/game" # 项目相对于GOPATH的路径
BetaBinPath: "/home/game/" BetaBinPath: "/home/game/" # beta环境部署路径
DevelopBinPath: "/home/game/" DevelopBinPath: "/home/game/" # develop环境部署路径
default: default:
tags: tags:
@ -35,15 +35,19 @@ build-job:
script: script:
- git checkout $CI_COMMIT_REF_NAME - git checkout $CI_COMMIT_REF_NAME
- git pull origin $CI_COMMIT_REF_NAME - git pull origin $CI_COMMIT_REF_NAME
- if [ ! -z "$(git status --porcelain go.mod go.sum)" ]; then
GOMODTIDY=1;
fi
# 拷贝到GOPATH # 拷贝到GOPATH
- echo '拷贝到GOPATH' - echo '拷贝到GOPATH'
- rsync -rvz --delete ./* $GOPATH/src/$ProjectPath - rsync -rvc --no-perms --delete ./* $GOPATH/src/$ProjectPath
# 进入项目目录 # 进入项目目录
- cd $GOPATH/src/$ProjectPath - cd $GOPATH/src/$ProjectPath
# 编译 # 编译
- echo '编译' - echo '编译'
- go env -w GO111MODULE='on' - if [ "$GOMODTIDY" == 1 ]; then
- go mod tidy go mod tidy;
fi
- | - |
while IFS= read -r line || [[ -n $line ]] while IFS= read -r line || [[ -n $line ]]
do do

View File

@ -0,0 +1,47 @@
package svc
import (
"errors"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
"mongo.games.com/game/dbproxy/mongo"
)
var (
LotteryUserLogDBErr = errors.New("log_lotteryuser db open failed.")
)
type LotteryUserLog struct {
Platform string `bson:"-"`
CId int64
SnId int32
StartTs int64
CostCard int64
}
func LotteryUserLogsCollection(plt string) *mongo.Collection {
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, "log")
if s != nil {
c, first := s.DB().C("log_lotteryuser")
if first {
c.EnsureIndex(mgo.Index{Key: []string{"cid"}, Background: true, Sparse: true})
c.EnsureIndex(mgo.Index{Key: []string{"snid"}, Background: true, Sparse: true})
c.EnsureIndex(mgo.Index{Key: []string{"startts"}, Background: true, Sparse: true})
c.EnsureIndex(mgo.Index{Key: []string{"cid", "startts", "snid"}, Background: true, Sparse: true})
}
return c
}
return nil
}
func UpsertLotteryUserLog(log *LotteryUserLog) error {
c := LotteryUserLogsCollection(log.Platform)
if c == nil {
return LotteryUserLogDBErr
}
_, err := c.Upsert(bson.M{"cid": log.CId, "snid": log.SnId, "startts": log.StartTs}, log)
if err != nil {
return err
}
return nil
}

View File

@ -2,6 +2,7 @@ package svc
import ( import (
"errors" "errors"
"mongo.games.com/goserver/core/logger"
"net/rpc" "net/rpc"
"github.com/globalsign/mgo" "github.com/globalsign/mgo"
@ -59,6 +60,16 @@ func UpsertLottery(plt string, item []*model.Lottery) (err error) {
if err != nil { if err != nil {
return return
} }
err = UpsertLotteryUserLog(&LotteryUserLog{
Platform: plt,
CId: v.CId,
SnId: v.SnId,
StartTs: v.StartTs,
CostCard: v.CostCard,
})
if err != nil {
logger.Logger.Warnf("UpsertLotteryUserLog error: %v", err)
}
} }
return return
} }

View File

@ -131,6 +131,7 @@ const (
ActivityLog_PigBank // 购买存钱罐 ActivityLog_PigBank // 购买存钱罐
ActivityLog_Shop //商城购买 ActivityLog_Shop //商城购买
ActivityLog_Exchange //商城兑换 ActivityLog_Exchange //商城兑换
ActivityLog_CoinPigBank //金币存钱罐
) )
type PlayerGameCtrlData struct { type PlayerGameCtrlData struct {

View File

@ -42,6 +42,27 @@ func Close() {
internal.Close(_manager) internal.Close(_manager)
} }
// GetDatabase 获取数据库
// platform: 平台id
// database: 数据库名称
func GetDatabase(platform, database string) (*Database, error) {
if _manager == nil {
return nil, errors.New("mongo manager is nil, please call Init() first")
}
return _manager.GetDatabase(platform, database)
}
// GetGlobalDatabase 获取全局库
// database: 数据库名称
func GetGlobalDatabase(database string) (*Database, error) {
if _manager == nil {
return nil, errors.New("mongo manager is nil, please call Init() first")
}
return _manager.GetDatabase("global", database)
}
// GetGlobalCollection 获取全局库 // GetGlobalCollection 获取全局库
// database: 数据库名称 // database: 数据库名称
// collection: 集合名称 // collection: 集合名称

View File

@ -98,6 +98,14 @@ type Manager struct {
} }
func (m *Manager) GetCollection(key, database, collection string) (*Collection, error) { func (m *Manager) GetCollection(key, database, collection string) (*Collection, error) {
d, err := m.GetDatabase(key, database)
if err != nil {
return nil, err
}
return d.GetCollection(collection)
}
func (m *Manager) GetDatabase(key, database string) (*Database, error) {
switch key { switch key {
case "global": case "global":
v, ok := m.global.Load(database) v, ok := m.global.Load(database)
@ -113,7 +121,7 @@ func (m *Manager) GetCollection(key, database, collection string) (*Collection,
m.global.Store(database, v) m.global.Store(database, v)
} }
d, _ := v.(*Database) d, _ := v.(*Database)
return d.GetCollection(collection) return d, nil
default: default:
var mp *sync.Map var mp *sync.Map
@ -137,7 +145,7 @@ func (m *Manager) GetCollection(key, database, collection string) (*Collection,
mp.Store(database, v) mp.Store(database, v)
} }
d, _ := v.(*Database) d, _ := v.(*Database)
return d.GetCollection(collection) return d, nil
} }
} }

View File

@ -26,6 +26,7 @@ var SceneMgrSingleton = &SceneMgr{
coinSceneAutoId: common.CoinSceneStartId, coinSceneAutoId: common.CoinSceneStartId,
hundredSceneAutoId: common.HundredSceneStartId, hundredSceneAutoId: common.HundredSceneStartId,
password: make(map[string]struct{}), password: make(map[string]struct{}),
pushList: make(map[int]struct{}),
} }
// SceneMgr 房间管理器 // SceneMgr 房间管理器
@ -38,6 +39,8 @@ type SceneMgr struct {
coinSceneAutoId int // 金币场房间号 coinSceneAutoId int // 金币场房间号
hundredSceneAutoId int // 百人场房间号 hundredSceneAutoId int // 百人场房间号
password map[string]struct{} // 密码 password map[string]struct{} // 密码
pushList map[int]struct{} // 已经推荐过的房间列表
lastPushSceneId int // 最后推荐的房间id
} }
// AllocReplayCode 获取回访码 // AllocReplayCode 获取回访码
@ -407,10 +410,10 @@ func (m *SceneMgr) FindCustomInviteRoom(p *Player) *Scene {
return false return false
} }
iN, jN := ret[i].GetMaxPlayerNum()-ret[i].GetPlayerCnt(), ret[j].GetMaxPlayerNum()-ret[j].GetPlayerCnt() iN, jN := ret[i].GetMaxPlayerNum()-ret[i].GetPlayerCnt(), ret[j].GetMaxPlayerNum()-ret[j].GetPlayerCnt()
if iN > jN { if iN < jN {
return true return true
} }
if iN < jN { if iN > jN {
return false return false
} }
if ret[i].RecruitTimes > ret[j].RecruitTimes { if ret[i].RecruitTimes > ret[j].RecruitTimes {
@ -422,7 +425,49 @@ func (m *SceneMgr) FindCustomInviteRoom(p *Player) *Scene {
return ret[i].createTime.Unix() < ret[j].createTime.Unix() return ret[i].createTime.Unix() < ret[j].createTime.Unix()
}) })
// 删除没有的房间
var list []*Scene
var pushList = map[int]struct{}{}
for k := range m.pushList {
var has bool
for _, v := range ret {
if v.sceneId == k {
has = true
break
}
}
if has {
pushList[k] = struct{}{}
}
}
m.pushList = pushList
// 删除推荐过的房间
for _, v := range ret {
if _, ok := m.pushList[v.sceneId]; !ok {
list = append(list, v)
}
}
if len(list) > 0 {
m.pushList[list[0].sceneId] = struct{}{}
return list[0]
}
if len(ret) > 0 { if len(ret) > 0 {
// 全都推荐过了,循环推荐房间
var b bool
for _, v := range ret {
if b {
m.lastPushSceneId = v.sceneId
return v
}
if v.sceneId == m.lastPushSceneId {
b = true
}
}
// 没找到,从头开始
m.lastPushSceneId = ret[0].sceneId
return ret[0] return ret[0]
} }

View File

@ -354,12 +354,12 @@ func SCLogin(s *netlib.Session, sid int64, csLogin *login_proto.CSLogin, acc *mo
ClientParam: string(model.ClinetBuf), ClientParam: string(model.ClinetBuf),
NextDayTs: common.GetDayNextStartTs(time.Now().Unix()), NextDayTs: common.GetDayNextStartTs(time.Now().Unix()),
IsNewUser: isFirstLogin, IsNewUser: isFirstLogin,
SnId: acc.SnId,
} }
if acc != nil { if acc != nil {
now := time.Now() now := time.Now()
sclogin.AccId = proto.String(acc.AccountId.Hex()) sclogin.AccId = proto.String(acc.AccountId.Hex())
sclogin.SrvTs = proto.Int64(now.Unix()) sclogin.SrvTs = proto.Int64(now.Unix())
sclogin.SnId = acc.SnId
if code == login_proto.OpResultCode_OPRC_Sucess { if code == login_proto.OpResultCode_OPRC_Sucess {
acc.LastLoginTime = now acc.LastLoginTime = now
acc.LoginTimes++ acc.LoginTimes++

View File

@ -1856,7 +1856,7 @@ func (this *WelfareMgr) PigbankTakeCoin(p *Player) {
pack.Price = int64(infoData.CoinPrice) pack.Price = int64(infoData.CoinPrice)
logger.Logger.Tracef("PigbankTakeCoin snid: %v pack: %v", p.SnId, pack) logger.Logger.Tracef("PigbankTakeCoin snid: %v pack: %v", p.SnId, pack)
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack) p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack)
mq.Write(model.GenerateActivityLog(p.SnId, p.Platform, model.ActivityLog_CoinPigBank, 1))
} }
} }