703 lines
16 KiB
Go
703 lines
16 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"time"
|
|
|
|
"mongo.games.com/goserver/core/basic"
|
|
"mongo.games.com/goserver/core/logger"
|
|
"mongo.games.com/goserver/core/module"
|
|
"mongo.games.com/goserver/core/task"
|
|
|
|
"mongo.games.com/game/common"
|
|
"mongo.games.com/game/model"
|
|
"mongo.games.com/game/mq"
|
|
"mongo.games.com/game/protocol/webapi"
|
|
"mongo.games.com/game/protocol/welfare"
|
|
)
|
|
|
|
const (
|
|
LotteryRoomCard = 10 // 几张房卡获得一个抽奖码
|
|
)
|
|
|
|
var LotteryMgrInst = &LotteryMgr{
|
|
Data: make(map[string]map[int64]*LotteryData),
|
|
PlatformConfig: make(map[string]*LotteryConfig),
|
|
}
|
|
|
|
func init() {
|
|
module.RegisteModule(LotteryMgrInst, time.Minute, 0)
|
|
common.RegisterClockFunc(&common.ClockFunc{
|
|
OnDayTimerFunc: func() {
|
|
for _, v := range LotteryMgrInst.PlatformConfig {
|
|
if v == nil {
|
|
continue
|
|
}
|
|
if v.IsCycle {
|
|
// 每天重置抽奖数据
|
|
LotteryMgrInst.Reset()
|
|
// 重置抽奖期数
|
|
for _, v := range LotteryMgrInst.PlatformConfig {
|
|
if v != nil {
|
|
v.Num = 0
|
|
}
|
|
}
|
|
// 重置玩家抽奖数据
|
|
for _, v := range PlayerInfoMgrSingle.Players {
|
|
v.Lottery = make(map[int64]*model.Lottery)
|
|
}
|
|
}
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
// LotteryData 抽奖数据
|
|
type LotteryData struct {
|
|
*model.LotteryData
|
|
}
|
|
|
|
// Reset 重置抽奖数据
|
|
func (l *LotteryData) Reset() {
|
|
if l == nil {
|
|
return
|
|
}
|
|
|
|
cfg := PlatformMgrSingleton.GetLotteryConfig(l.Platform, l.CId)
|
|
if cfg == nil {
|
|
return
|
|
}
|
|
|
|
l.StartTs = common.IntToTime(int(cfg.GetStartHMS())).Unix()
|
|
l.EndTs = common.IntToTime(int(cfg.GetEndHMS())).Unix()
|
|
l.WinTs = common.IntToTime(int(cfg.GetWinHMS())).Unix()
|
|
l.Price = cfg.GetPrice()
|
|
l.RobotCodeNum = cfg.GetRobotCode()
|
|
l.TotalCode = cfg.GetTotalCode()
|
|
l.Reward = nil
|
|
for _, v := range cfg.GetReward() {
|
|
l.Reward = append(l.Reward, &model.ItemInfo{
|
|
ItemId: v.GetItemId(),
|
|
ItemNum: v.GetItemNum(),
|
|
})
|
|
}
|
|
long := len(fmt.Sprintf("%d", cfg.GetTotalCode()-1))
|
|
if long < 1 {
|
|
long = 1
|
|
}
|
|
l.Format = "%0" + fmt.Sprintf("%d", long) + "d"
|
|
l.ImageURL = cfg.GetImageURI()
|
|
l.CustomAward = 0
|
|
l.Code = 0
|
|
l.PlayerIndex = 0
|
|
l.RobotIndex = 0
|
|
l.SnId = 0
|
|
l.Name = ""
|
|
l.WinCostCard = 0
|
|
l.WinCode = ""
|
|
l.IsRobot = false
|
|
l.IsSend = false
|
|
l.CostCard = 0
|
|
l.RobotCodeCount = 0
|
|
l.PlayerNum = 0
|
|
}
|
|
|
|
// GetCode 获取抽奖码
|
|
func (l *LotteryData) GetCode() (string, bool) {
|
|
if l == nil {
|
|
return "", false
|
|
}
|
|
if l.Code < int(l.TotalCode) {
|
|
ret := fmt.Sprintf("%d", l.Code)
|
|
l.Code++
|
|
return ret, true
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
func (l *LotteryData) GetPlayerIndex() int {
|
|
l.PlayerIndex++
|
|
return l.PlayerIndex
|
|
}
|
|
|
|
func (l *LotteryData) GetRobotIndex() int {
|
|
l.RobotIndex++
|
|
return l.RobotIndex
|
|
}
|
|
|
|
// GetRemainCode 获取剩余抽奖码数量
|
|
func (l *LotteryData) GetRemainCode() int {
|
|
if l == nil {
|
|
return 0
|
|
}
|
|
return int(l.TotalCode) - l.Code
|
|
}
|
|
|
|
// 发奖
|
|
func (l *LotteryData) sendAward() {
|
|
now := time.Now()
|
|
if l.WinTs <= 0 || l.WinTs >= now.Unix() || l.IsSend || l.WinCode == "" || l.SnId == 0 {
|
|
return
|
|
}
|
|
l.IsSend = true
|
|
if l.IsRobot {
|
|
return
|
|
}
|
|
AddMailLottery(l.SnId, l.Reward)
|
|
// 通知
|
|
if p := PlayerMgrSington.GetPlayerBySnId(l.SnId); p != nil {
|
|
|
|
var lotteryAward []*welfare.PropInfo
|
|
for _, v := range l.Reward {
|
|
lotteryAward = append(lotteryAward, &welfare.PropInfo{
|
|
ItemId: v.ItemId,
|
|
ItemNum: v.ItemNum,
|
|
})
|
|
}
|
|
|
|
var codes []string
|
|
info := PlayerInfoMgrSingle.Players[p.SnId]
|
|
if info != nil {
|
|
if lt := info.Lottery[l.CId]; lt != nil && lt.StartTs == l.StartTs {
|
|
codes = lt.Code
|
|
}
|
|
}
|
|
|
|
pack := &welfare.NotifyLotteryAward{
|
|
Info: &welfare.LotteryInfo{
|
|
Id: l.CId,
|
|
StartTs: l.StartTs,
|
|
EndTs: l.EndTs,
|
|
WinTs: l.WinTs,
|
|
RemainCode: int64(l.GetRemainCode()),
|
|
TotalCode: l.TotalCode,
|
|
Award: lotteryAward,
|
|
State: common.LotteryStateOver,
|
|
WinCode: l.WinCode,
|
|
SnId: l.SnId,
|
|
Name: l.Name,
|
|
Index: int32(l.Num),
|
|
Price: l.Price,
|
|
NeedRoomCard: LotteryRoomCard,
|
|
ImageURL: l.ImageURL,
|
|
CostRoomCard: l.WinCostCard,
|
|
Codes: codes,
|
|
},
|
|
}
|
|
p.SendToClient(int(welfare.SPacketID_PACKET_NotifyLotteryAward), pack)
|
|
logger.Logger.Tracef("NotifyLotteryAward: %v", pack)
|
|
}
|
|
}
|
|
|
|
func (l *LotteryData) sendRobotCode(a, b int) {
|
|
// 随机给机器人发放抽奖码
|
|
now := time.Now()
|
|
if l.StartTs <= now.Unix() && l.EndTs > now.Unix() && l.RobotCodeCount < int(l.RobotCodeNum) && l.GetRemainCode() > 0 {
|
|
n := common.RandInt(a, b)
|
|
for i := 0; i < n; i++ {
|
|
code, b := l.GetCode()
|
|
if b {
|
|
l.RobotCodeCount++
|
|
// 开奖码记录
|
|
mq.Write(&model.LotteryCode{
|
|
Platform: l.Platform,
|
|
SnId: 0,
|
|
CId: l.CId,
|
|
StartTs: l.StartTs,
|
|
Code: code,
|
|
Index: l.GetRobotIndex(),
|
|
})
|
|
if l.RobotCodeCount >= int(l.RobotCodeNum) || l.GetRemainCode() <= 0 {
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Done 抽奖
|
|
func (l *LotteryData) Done() {
|
|
now := time.Now()
|
|
if l.EndTs <= 0 || l.EndTs >= now.Unix() || l.SnId > 0 {
|
|
return
|
|
}
|
|
|
|
sTs := common.GetDayStartTs(now.Unix())
|
|
eTs := sTs + int64(time.Hour.Seconds()*24)
|
|
if l.StartTs < sTs || l.StartTs >= eTs {
|
|
return
|
|
}
|
|
|
|
lotteryLog := &model.LotteryLog{} // 中奖记录
|
|
var err error
|
|
var awardPlayer *Player // 中奖玩家
|
|
var joinNum int // 参与人数
|
|
var code *model.LotteryCode // 开奖码
|
|
var costCard int64 // 消耗房卡
|
|
var isMust bool // 是否必中
|
|
var index int // 开奖码序号
|
|
var tp int // 开奖类型
|
|
|
|
// 先随机一个机器人
|
|
for _, v := range PlayerMgrSington.snidMap {
|
|
if v == nil {
|
|
continue
|
|
}
|
|
if !v.IsRob {
|
|
continue
|
|
}
|
|
awardPlayer = v
|
|
break
|
|
}
|
|
|
|
if awardPlayer == nil {
|
|
awardPlayer = &Player{
|
|
PlayerData: &model.PlayerData{},
|
|
}
|
|
}
|
|
|
|
// 是否必中
|
|
for _, v := range PlatformMgrSingleton.GetConfig(l.Platform).LotteryUser {
|
|
if v.GetOn() != common.On {
|
|
continue
|
|
}
|
|
t, _ := time.Parse(time.DateTime, v.GetTime())
|
|
if common.TsInSameDay(t.Unix(), l.StartTs) && v.GetNum() == int64(l.Num+1) {
|
|
// 必中
|
|
isMust = true
|
|
tp = 1
|
|
index = common.RandInt(1, l.RobotIndex)
|
|
awardPlayer.SnId = v.GetSnId()
|
|
awardPlayer.IsRob = false
|
|
break
|
|
}
|
|
}
|
|
|
|
if !isMust {
|
|
value := float64(l.CostCard*10-l.CustomAward) / float64(l.Price)
|
|
switch {
|
|
case value <= 1.2:
|
|
// 机器人开奖
|
|
tp = 1
|
|
index = common.RandInt(1, l.RobotIndex)
|
|
case value <= 5:
|
|
// 机器人加玩家开奖
|
|
tp = 2
|
|
index = common.RandInt(1, l.Code)
|
|
default:
|
|
// 玩家开奖
|
|
tp = 3
|
|
index = common.RandInt(1, l.PlayerIndex)
|
|
}
|
|
}
|
|
|
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
|
// 查询参与人数
|
|
joinNum, err = model.GetLotteryCodeJoinNum(l.Platform, l.CId, l.StartTs)
|
|
if err != nil {
|
|
logger.Logger.Errorf("GetLotteryCodeJoinNum error:%v", err)
|
|
return err
|
|
}
|
|
// 查询开奖码
|
|
code, err = model.GetLotteryCodeRandom(l.Platform, l.CId, l.StartTs, tp, index)
|
|
if err != nil {
|
|
logger.Logger.Errorf("GetLotteryCodeRandom error:%v", err)
|
|
return err
|
|
}
|
|
if code != nil && isMust {
|
|
code.SnId = awardPlayer.SnId
|
|
}
|
|
// 查询玩家消耗
|
|
if code != nil && code.SnId > 0 {
|
|
list, err := model.GetLottery(l.Platform, code.SnId, l.CId, l.StartTs)
|
|
if err != nil {
|
|
logger.Logger.Errorf("GetLottery error:%v", err)
|
|
return err
|
|
}
|
|
for _, v := range list {
|
|
if v.CId == l.CId && v.StartTs == l.StartTs {
|
|
costCard = v.CostCard
|
|
break
|
|
}
|
|
}
|
|
|
|
p := PlayerMgrSington.GetPlayerBySnId(code.SnId)
|
|
if p == nil {
|
|
playerData := model.GetPlayerBaseInfo(l.Platform, code.SnId)
|
|
if playerData != nil {
|
|
awardPlayer = &Player{
|
|
PlayerData: &model.PlayerData{
|
|
SnId: playerData.SnId,
|
|
Name: playerData.Name,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
|
if code == nil && isMust {
|
|
code = &model.LotteryCode{
|
|
Platform: l.Platform,
|
|
SnId: awardPlayer.SnId,
|
|
CId: l.CId,
|
|
StartTs: l.StartTs,
|
|
Code: fmt.Sprintf("%d", l.TotalCode),
|
|
}
|
|
}
|
|
if code == nil {
|
|
return
|
|
}
|
|
if code.SnId > 0 {
|
|
p := PlayerMgrSington.GetPlayerBySnId(code.SnId)
|
|
if p != nil {
|
|
awardPlayer = p
|
|
if info := PlayerInfoMgrSingle.Players[p.SnId]; info != nil {
|
|
c := info.Lottery[l.CId]
|
|
if c != nil && c.StartTs == l.StartTs {
|
|
costCard = c.CostCard
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
l.PlayerNum = int32(joinNum)
|
|
|
|
// 记录中奖结果
|
|
if awardPlayer != nil {
|
|
l.Num = int(LotteryMgrInst.GetNum(l.Platform))
|
|
l.SnId = awardPlayer.SnId
|
|
l.Name = awardPlayer.Name
|
|
l.WinCostCard = costCard
|
|
l.WinCode = code.Code
|
|
l.IsRobot = awardPlayer.IsRobot()
|
|
|
|
var lotteryAward []*model.LotteryAward
|
|
for _, v := range l.Reward {
|
|
lotteryAward = append(lotteryAward, &model.LotteryAward{
|
|
Id: int64(v.ItemId),
|
|
N: v.ItemNum,
|
|
})
|
|
}
|
|
|
|
lotteryLog = &model.LotteryLog{
|
|
Platform: l.Platform,
|
|
CId: l.CId,
|
|
CTime: time.Unix(l.StartTs, 0),
|
|
Num: int32(l.Num),
|
|
SnId: awardPlayer.SnId,
|
|
Name: awardPlayer.Name,
|
|
PlayerNum: int64(joinNum),
|
|
Code: l.WinCode,
|
|
CostCard: l.CostCard,
|
|
IsRobot: awardPlayer.IsRobot(),
|
|
Award: lotteryAward,
|
|
Price: l.Price,
|
|
IsMust: isMust,
|
|
ImageURL: l.ImageURL,
|
|
Ts: l.WinTs,
|
|
}
|
|
mq.Write(lotteryLog)
|
|
// 开始发奖
|
|
l.sendAward()
|
|
}
|
|
}), "LotterySendAward").Start()
|
|
}
|
|
|
|
type LotteryConfig struct {
|
|
IsCycle bool
|
|
Num int64
|
|
}
|
|
|
|
// LotteryMgr 抽奖管理
|
|
type LotteryMgr struct {
|
|
Data map[string]map[int64]*LotteryData // 平台:抽奖配置id:抽奖数据
|
|
PlatformConfig map[string]*LotteryConfig
|
|
}
|
|
|
|
func (l *LotteryMgr) ModuleName() string {
|
|
return "LotteryMgr"
|
|
}
|
|
|
|
func (l *LotteryMgr) Init() {
|
|
// 加载抽奖活动数据
|
|
for _, v := range PlatformMgrSingleton.GetPlatforms() {
|
|
if v != nil {
|
|
data, err := model.GetLotteryData(v.IdStr)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("GetLotteryData error:%v", err))
|
|
}
|
|
for _, d := range data {
|
|
ld := l.GetData(v.IdStr, d.CId)
|
|
ld.LotteryData = d
|
|
ld.Platform = v.IdStr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func (l *LotteryMgr) Update() {
|
|
for _, v := range l.Data {
|
|
for _, d := range v {
|
|
if d == nil {
|
|
continue
|
|
}
|
|
lc := PlatformMgrSingleton.GetLotteryConfig(d.Platform, d.CId)
|
|
if lc == nil || lc.GetOn() != common.On {
|
|
continue
|
|
}
|
|
// 随机给机器人发放抽奖码
|
|
d.sendRobotCode(1, 5)
|
|
// 活动结束,开始抽奖
|
|
d.Done()
|
|
// 开始发奖
|
|
d.sendAward()
|
|
}
|
|
}
|
|
}
|
|
|
|
func (l *LotteryMgr) Shutdown() {
|
|
for k, v := range l.Data {
|
|
var arr []*model.LotteryData
|
|
for _, d := range v {
|
|
if d.LotteryData == nil {
|
|
continue
|
|
}
|
|
arr = append(arr, d.LotteryData)
|
|
}
|
|
model.UpsertLotteryData(k, arr)
|
|
}
|
|
|
|
module.UnregisteModule(l)
|
|
}
|
|
|
|
func (l *LotteryMgr) Reset() {
|
|
// 重置抽奖数据
|
|
for _, v := range LotteryMgrInst.Data {
|
|
for _, d := range v {
|
|
if d == nil {
|
|
continue
|
|
}
|
|
d.Reset()
|
|
}
|
|
}
|
|
}
|
|
|
|
func (l *LotteryMgr) UpdateConfig(conf *webapi.LotteryConfig) {
|
|
now := time.Now()
|
|
// 删除不存在的活动
|
|
for k, v := range l.Data {
|
|
var id []int64
|
|
for _, d := range v {
|
|
if d == nil {
|
|
continue
|
|
}
|
|
has := false
|
|
for _, vv := range conf.GetList() {
|
|
if vv.GetId() == d.CId {
|
|
has = true
|
|
break
|
|
}
|
|
}
|
|
if !has {
|
|
id = append(id, d.CId)
|
|
}
|
|
}
|
|
for _, i := range id {
|
|
delete(l.Data[k], i)
|
|
}
|
|
}
|
|
// 更新活动配置,已结束,开始中的不能修改
|
|
for _, v := range conf.GetList() {
|
|
if v.GetTotalCode() <= 0 {
|
|
v.TotalCode = 1
|
|
}
|
|
data := l.GetData(conf.GetPlatform(), v.GetId())
|
|
if data.EndTs > 0 && (data.EndTs < now.Unix() || data.StartTs <= now.Unix()) {
|
|
continue
|
|
} else {
|
|
data.Reset()
|
|
}
|
|
}
|
|
l.GetConfig(conf.GetPlatform()).IsCycle = conf.GetCycle() == common.On
|
|
}
|
|
|
|
func (l *LotteryMgr) GetConfig(plt string) *LotteryConfig {
|
|
_, ok := l.PlatformConfig[plt]
|
|
if !ok {
|
|
l.PlatformConfig[plt] = &LotteryConfig{}
|
|
}
|
|
return l.PlatformConfig[plt]
|
|
}
|
|
|
|
func (l *LotteryMgr) GetData(plt string, cid int64) *LotteryData {
|
|
if l.Data[plt] == nil {
|
|
l.Data[plt] = make(map[int64]*LotteryData)
|
|
}
|
|
if l.Data[plt][cid] == nil {
|
|
l.Data[plt][cid] = &LotteryData{
|
|
LotteryData: &model.LotteryData{
|
|
Platform: plt,
|
|
CId: cid,
|
|
},
|
|
}
|
|
}
|
|
return l.Data[plt][cid]
|
|
}
|
|
|
|
// GetNum 获取抽奖第几期
|
|
// 当前抽奖是第几期
|
|
func (l *LotteryMgr) GetNum(plt string) int64 {
|
|
p := l.GetConfig(plt)
|
|
if p.Num == 0 {
|
|
p.Num = 1
|
|
return 1
|
|
}
|
|
p.Num += 1
|
|
return p.Num
|
|
}
|
|
|
|
// GetList 获取抽奖列表
|
|
func (l *LotteryMgr) GetList(plt string) []*welfare.LotteryInfo {
|
|
now := time.Now()
|
|
ret := make([]*welfare.LotteryInfo, 0)
|
|
|
|
for _, d := range l.Data[plt] {
|
|
lc := PlatformMgrSingleton.GetLotteryConfig(d.Platform, d.CId)
|
|
if lc == nil || lc.GetOn() != common.On {
|
|
continue
|
|
}
|
|
|
|
// 是否活动已经结束
|
|
p := l.GetConfig(d.Platform)
|
|
if !p.IsCycle && !common.TsInSameDay(d.StartTs, now.Unix()) {
|
|
continue
|
|
}
|
|
|
|
var award []*welfare.PropInfo
|
|
for _, a := range d.Reward {
|
|
award = append(award, &welfare.PropInfo{
|
|
ItemId: a.ItemId,
|
|
ItemNum: a.ItemNum,
|
|
})
|
|
}
|
|
|
|
state := 1
|
|
switch {
|
|
case d.EndTs < now.Unix():
|
|
state = common.LotteryStateOver // 已结束
|
|
case d.StartTs > now.Unix():
|
|
state = common.LotteryStateNoStart // 未开始
|
|
default:
|
|
state = common.LotteryStateRun // 进行中
|
|
}
|
|
|
|
ret = append(ret, &welfare.LotteryInfo{
|
|
Id: d.CId,
|
|
StartTs: d.StartTs,
|
|
EndTs: d.EndTs,
|
|
WinTs: d.WinTs,
|
|
RemainCode: int64(d.GetRemainCode()),
|
|
TotalCode: d.TotalCode,
|
|
Award: award,
|
|
State: int32(state),
|
|
WinCode: d.WinCode,
|
|
SnId: d.SnId,
|
|
Name: d.Name,
|
|
NeedRoomCard: LotteryRoomCard,
|
|
ImageURL: d.ImageURL,
|
|
})
|
|
}
|
|
|
|
sort.Slice(ret, func(i, j int) bool {
|
|
if ret[i].StartTs == ret[j].StartTs {
|
|
return ret[i].Index < ret[j].Index
|
|
}
|
|
return ret[i].StartTs < ret[j].StartTs
|
|
})
|
|
for k, v := range ret {
|
|
v.Index = int32(k + 1)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
// AddCostRoomCard 添加消耗房卡
|
|
// snid: 玩家ID
|
|
// n: 消耗房卡数量
|
|
// cid: 抽奖配置ID
|
|
func (l *LotteryMgr) AddCostRoomCard(plt string, snid int32, n int64) {
|
|
// 活动总开关
|
|
conf := PlatformMgrSingleton.GetConfig(plt).LotteryConfig
|
|
if conf == nil || conf.GetOn() != common.On {
|
|
return
|
|
}
|
|
|
|
f := func() {
|
|
info := PlayerInfoMgrSingle.Players[snid]
|
|
if info == nil {
|
|
logger.Logger.Errorf("AddCostRoomCard LotteryData snid:%v not found", snid)
|
|
return
|
|
}
|
|
|
|
for _, v := range l.GetList(plt) {
|
|
if v == nil || v.GetState() != common.LotteryStateRun {
|
|
continue
|
|
}
|
|
if v.GetRemainCode() <= 0 {
|
|
continue
|
|
}
|
|
playerLottery := info.Lottery[v.GetId()]
|
|
if playerLottery == nil || playerLottery.StartTs != v.GetStartTs() {
|
|
playerLottery = &model.Lottery{
|
|
SnId: snid,
|
|
CId: v.GetId(),
|
|
Code: nil,
|
|
StartTs: v.GetStartTs(),
|
|
CostCard: 0,
|
|
ReCostCard: 0,
|
|
}
|
|
info.Lottery[v.GetId()] = playerLottery
|
|
}
|
|
lotteryData := l.GetData(plt, v.GetId())
|
|
lotteryData.CostCard += n
|
|
|
|
playerLottery.CostCard += n
|
|
n = int64(int(n) + playerLottery.ReCostCard)
|
|
playerLottery.ReCostCard = int(n % LotteryRoomCard)
|
|
for i := 0; i < int(n)/LotteryRoomCard; i++ {
|
|
code, b := lotteryData.GetCode()
|
|
if b {
|
|
intCode, _ := strconv.Atoi(code)
|
|
playerLottery.Code = append(playerLottery.Code, fmt.Sprintf(lotteryData.Format, intCode))
|
|
// 开奖码记录
|
|
mq.Write(&model.LotteryCode{
|
|
Platform: plt,
|
|
SnId: snid,
|
|
CId: v.GetId(),
|
|
StartTs: v.GetStartTs(),
|
|
Code: code,
|
|
Index: lotteryData.GetPlayerIndex(),
|
|
})
|
|
// 机器人发一个
|
|
lotteryData.sendRobotCode(1, 1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
p := PlayerMgrSington.GetPlayerBySnId(snid)
|
|
if p == nil {
|
|
PlayerCacheMgrSingleton.Get(plt, snid, func(item *PlayerCacheItem, b bool, b2 bool) {
|
|
if item == nil || item.PlayerData == nil {
|
|
logger.Logger.Errorf("AddCostRoomCard snid:%v not found", snid)
|
|
return
|
|
}
|
|
f()
|
|
}, false)
|
|
return
|
|
}
|
|
f()
|
|
}
|