Compare commits
No commits in common. "d044890e2648dcd88ad1a255636ee7db7c818714" and "f10e70317c950798748091231aa5b370d384ed01" have entirely different histories.
d044890e26
...
f10e70317c
|
@ -14,13 +14,6 @@ default:
|
||||||
tags:
|
tags:
|
||||||
- gitlab
|
- gitlab
|
||||||
|
|
||||||
cache:
|
|
||||||
key: "$CI_COMMIT_REF_NAME-$(md5sum go.mod go.sum)"
|
|
||||||
paths:
|
|
||||||
- .cache/go-build/
|
|
||||||
- $GOPATH/pkg/mod/
|
|
||||||
policy: pull-push
|
|
||||||
|
|
||||||
# 锁定作业,防止并发流水线执行
|
# 锁定作业,防止并发流水线执行
|
||||||
lock_job:
|
lock_job:
|
||||||
stage: lock
|
stage: lock
|
||||||
|
@ -42,9 +35,6 @@ 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 -rvz --delete ./* $GOPATH/src/$ProjectPath
|
||||||
|
@ -53,15 +43,13 @@ build-job:
|
||||||
# 编译
|
# 编译
|
||||||
- echo '编译'
|
- echo '编译'
|
||||||
- go env -w GO111MODULE='on'
|
- 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
|
||||||
cd $line
|
cd $line
|
||||||
echo "编译 $line"
|
echo "编译 $line"
|
||||||
go build
|
go build -v
|
||||||
cd ..
|
cd ..
|
||||||
done < shell/programs.txt
|
done < shell/programs.txt
|
||||||
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
|
|
||||||
"github.com/globalsign/mgo"
|
"github.com/globalsign/mgo"
|
||||||
|
@ -60,16 +59,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,27 +42,6 @@ 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: 集合名称
|
||||||
|
|
|
@ -98,14 +98,6 @@ 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)
|
||||||
|
@ -121,7 +113,7 @@ func (m *Manager) GetDatabase(key, database string) (*Database, error) {
|
||||||
m.global.Store(database, v)
|
m.global.Store(database, v)
|
||||||
}
|
}
|
||||||
d, _ := v.(*Database)
|
d, _ := v.(*Database)
|
||||||
return d, nil
|
return d.GetCollection(collection)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
var mp *sync.Map
|
var mp *sync.Map
|
||||||
|
@ -145,7 +137,7 @@ func (m *Manager) GetDatabase(key, database string) (*Database, error) {
|
||||||
mp.Store(database, v)
|
mp.Store(database, v)
|
||||||
}
|
}
|
||||||
d, _ := v.(*Database)
|
d, _ := v.(*Database)
|
||||||
return d, nil
|
return d.GetCollection(collection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ 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 房间管理器
|
||||||
|
@ -39,8 +38,6 @@ 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 获取回访码
|
||||||
|
@ -410,10 +407,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 {
|
||||||
|
@ -425,49 +422,7 @@ 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]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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++
|
||||||
|
|
Loading…
Reference in New Issue