2030 lines
65 KiB
Go
2030 lines
65 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"math"
|
||
"time"
|
||
|
||
"mongo.games.com/goserver/core/logger"
|
||
"mongo.games.com/goserver/core/module"
|
||
|
||
"mongo.games.com/game/common"
|
||
"mongo.games.com/game/model"
|
||
"mongo.games.com/game/mq"
|
||
hall_proto "mongo.games.com/game/protocol/gamehall"
|
||
player_proto "mongo.games.com/game/protocol/player"
|
||
"mongo.games.com/game/protocol/shop"
|
||
webapi_proto "mongo.games.com/game/protocol/webapi"
|
||
"mongo.games.com/game/protocol/welfare"
|
||
"mongo.games.com/game/srvdata"
|
||
)
|
||
|
||
const (
|
||
GameSubsidyid = 1 //救济金id
|
||
)
|
||
|
||
var WelfareMgrSington = &WelfareMgr{
|
||
ConfigMgr: model.NewConfigMgr(),
|
||
}
|
||
|
||
type WelfareMgr struct {
|
||
common.BaseClockSinker
|
||
*model.ConfigMgr
|
||
}
|
||
|
||
func (this *WelfareMgr) Init() {
|
||
|
||
}
|
||
|
||
func (this *WelfareMgr) ModuleName() string {
|
||
return "WelfareMgr"
|
||
}
|
||
|
||
// SetWelfData 设置救济金领取次数
|
||
func (this *WelfareMgr) SetWelfData(p *Player, n int32) {
|
||
if n > 0 {
|
||
p.WelfData.ReliefFundTimes += n
|
||
}
|
||
p.dirty = true
|
||
}
|
||
|
||
// GetReliefFund 获取救济金
|
||
func (this *WelfareMgr) GetReliefFund(p *Player, isVideo bool) {
|
||
sdata := srvdata.PBDB_GameSubsidyMgr.GetData(GameSubsidyid)
|
||
pack := &welfare.SCGetReliefFund{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
if sdata != nil {
|
||
if p.WelfData.ReliefFundTimes >= sdata.Times {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETRELIEFFUND), pack)
|
||
|
||
} else if p.Coin >= int64(sdata.LimitNum) {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_CoinTooMore
|
||
} else {
|
||
var rate int = 1
|
||
var gainWay int32 = common.GainWay_ReliefFund
|
||
var add int64
|
||
coin := int64(sdata.Get) // 增加金币
|
||
p.WelfData.ReliefFundTimes += 1
|
||
award := ModelMgrSingleton.GetAwardPetByWelf(p)
|
||
if award > 0 {
|
||
if isVideo { // 双倍领取,蝶女视频加成
|
||
gainWay = common.GainWay_ReliefFund2
|
||
rate = 2
|
||
add = int64(float64(coin*award*2) / 100.0)
|
||
roleGirl := ModelMgrSingleton.GetRoleInfo(p, 2000001)
|
||
if roleGirl != nil && roleGirl.Level > 0 {
|
||
//蝶女加成
|
||
add += int64(float64(coin*int64(roleGirl.Award)*2) / 100.0)
|
||
}
|
||
coin = coin*2 + add
|
||
TaskSubjectSingleton.Touch(common.TaskTypeAdv, &TaskData{
|
||
SnId: p.SnId,
|
||
Num: 1,
|
||
})
|
||
} else {
|
||
add = int64(float64(coin*award) / 100.0)
|
||
coin = coin + add
|
||
}
|
||
}
|
||
//周卡加成
|
||
if p.GetWeekCardPrivilege(1) {
|
||
coin = coin * 2
|
||
}
|
||
p.AddCoin(coin, add, gainWay, "ReliefFund",
|
||
fmt.Sprintf("领取救济金-%v-%v倍", coin, rate))
|
||
|
||
//LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, model.SystemFreeGive_GiveType_ReliefFund, model.SystemFreeGive_CoinType_Coin, int64(coin)))
|
||
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.Coin = coin
|
||
pack.Times = p.WelfData.ReliefFundTimes
|
||
|
||
logger.Logger.Tracef("NewReliefFundLogEx snid: %v Coin:%v", p.SnId, pack.Coin)
|
||
getType := model.SystemFreeGive_GiveType_ReliefFund
|
||
if isVideo {
|
||
getType = model.SystemFreeGive_GiveType_ShopAd
|
||
}
|
||
|
||
log := model.NewReliefFundLogEx(p.SnId, getType, model.SystemFreeGive_CoinType_Coin, coin, p.CreateTime.Unix(), p.Platform, p.Channel)
|
||
if log != nil {
|
||
mq.Write(log)
|
||
logger.Logger.Tracef("NewReliefFundLogEx WriteLog snid: %v Coin:%v", p.SnId, pack.Coin)
|
||
}
|
||
}
|
||
}
|
||
logger.Logger.Tracef("GetReliefFund snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETRELIEFFUND), pack)
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateSign7(cfg *webapi_proto.Welfare7SignDateList) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
this.GetConfig(cfg.Platform).Welfare7SignDateList = cfg
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateTurnplate(cfg *webapi_proto.WelfareTurnplateDateList) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfareTurnplateDateList != nil {
|
||
s = info.WelfareTurnplateDateList.Switch
|
||
}
|
||
info.WelfareTurnplateDateList = cfg
|
||
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpTurnplate)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateBlindBox(cfg *webapi_proto.WelfareBlindBoxDataList) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfareBlindBoxDataList != nil {
|
||
s = info.WelfareBlindBoxDataList.Switch
|
||
}
|
||
info.WelfareBlindBoxDataList = cfg
|
||
if cfg.Cycle == model.WelfareOpen {
|
||
info.BlindBoxCycle = 1
|
||
}
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpBlindBox)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateFirstPay(cfg *webapi_proto.WelfareFirstPayDataList) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfareFirstPayDataList != nil {
|
||
s = info.WelfareFirstPayDataList.Switch
|
||
}
|
||
info.WelfareFirstPayDataList = cfg
|
||
if cfg.Cycle == model.WelfareOpen {
|
||
info.FirstPayCycle = 1
|
||
}
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpFirstPay)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateContinuousPay(cfg *webapi_proto.WelfareContinuousPayDataList) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfareContinuousPayDataList != nil {
|
||
s = info.WelfareContinuousPayDataList.Switch
|
||
}
|
||
info.WelfareContinuousPayDataList = cfg
|
||
if cfg.Cycle == model.WelfareOpen {
|
||
info.ContinuousPayCycle = 1
|
||
}
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpContinuousPay)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneLotteryStatus) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfarePhoneLotteryStatus != nil {
|
||
s = info.WelfarePhoneLotteryStatus.Switch
|
||
}
|
||
info.WelfarePhoneLotteryStatus = cfg
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpPhoneLottery)
|
||
}
|
||
}
|
||
|
||
// 更新钻石抽奖配置
|
||
func (this *WelfareMgr) UpdateDiamondLotteryConfig(cfg *webapi_proto.DiamondLotteryConfig) {
|
||
info := this.GetConfig(cfg.Platform)
|
||
info.DiamondLotteryConfig = cfg
|
||
for _, v := range info.DiamondLotteryConfig.GetLotteryData() {
|
||
v.MaxScore *= 100
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) GetPhoneLotteryStatus(platform string) int32 {
|
||
info := this.GetConfig(platform)
|
||
if info.WelfarePhoneLotteryStatus != nil {
|
||
return info.WelfarePhoneLotteryStatus.Switch
|
||
}
|
||
return model.WelfareClose
|
||
}
|
||
|
||
func (this *WelfareMgr) UpdateCollectConfig(cfg *webapi_proto.WelfareCollectConfig) {
|
||
if model.GameParamData.TestActSwitch {
|
||
cfg.Switch = model.WelfareOpen
|
||
}
|
||
s := int32(0)
|
||
info := this.GetConfig(cfg.Platform)
|
||
if info.WelfareCollectConfig != nil {
|
||
s = info.WelfareCollectConfig.Switch
|
||
}
|
||
info.WelfareCollectConfig = cfg
|
||
// 打开关闭要广播给客户端
|
||
if s != 0 && s != cfg.Switch {
|
||
this.WelfareSwitch(nil, cfg.Platform, model.OpCollect)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) GetCollectSwitch(platform string) int32 {
|
||
info := this.GetConfig(platform)
|
||
if info.WelfareCollectConfig != nil {
|
||
return info.WelfareCollectConfig.Switch
|
||
}
|
||
return model.WelfareClose
|
||
}
|
||
|
||
func (this *WelfareMgr) OnDayChanged(player *Player) error {
|
||
if player.WelfData == nil {
|
||
return nil
|
||
}
|
||
|
||
player.WelfData.ReliefFundTimes = 0
|
||
blindBox := this.GetConfig(player.Platform).WelfareBlindBoxDataList
|
||
if blindBox != nil { // 关闭循环重置为-1
|
||
if blindBox.Cycle == model.WelfareClose && player.WelfData.BlindBoxId != 0 {
|
||
player.WelfData.BlindBoxId = -1
|
||
} else { // 循环
|
||
player.WelfData.BlindBoxId = 0
|
||
}
|
||
}
|
||
|
||
if !this.Welfareturnplate(player, 0) {
|
||
player.SendShowRed(hall_proto.ShowRedCode_Welfare, 0, 1) // 0 轮盘红点
|
||
}
|
||
|
||
// 同步救济金次数
|
||
pack := &welfare.SCGetReliefFund{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Sucess,
|
||
Times: player.WelfData.ReliefFundTimes,
|
||
Coin: -1, // 更新剩余次数
|
||
}
|
||
player.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETRELIEFFUND), pack)
|
||
logger.Logger.Tracef("OnDayChanged SCGetReliefFund snid: %v pack: %v", player.SnId, pack)
|
||
|
||
// 重置存钱罐
|
||
this.DayResetPigrank(player)
|
||
return nil
|
||
}
|
||
|
||
func (this *WelfareMgr) MonitorWelfData(player *Player) {
|
||
if player.WelfData == nil {
|
||
player.WelfData = model.NewWelfareData()
|
||
} else if player.WelfData.Sign7 == nil {
|
||
player.WelfData.Sign7 = &model.NewSignData{}
|
||
} else if player.WelfData.VIPBag == nil {
|
||
player.WelfData.VIPBag = make(map[int32]map[int32]int32)
|
||
} else if player.WelfData.PigBank == nil {
|
||
player.WelfData.PigBank = &model.PigBankData{}
|
||
} else if player.WelfData.DiamondBank == nil {
|
||
player.WelfData.DiamondBank = &model.DiamondBankData{}
|
||
}
|
||
|
||
}
|
||
|
||
// GetTurnplate 获取转盘奖励
|
||
func (this *WelfareMgr) GetTurnplate(p *Player) {
|
||
pack := &welfare.SCGetTurnplate{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
turnplate := info.WelfareTurnplateDateList
|
||
sign7 := info.Welfare7SignDateList
|
||
if turnplate != nil && sign7 != nil {
|
||
if turnplate.Switch != model.WelfareOpen {
|
||
logger.Logger.Tracef("GetTurnplate Switch err p.SnId = %v %v", p.SnId, turnplate.Switch)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
if len(turnplate.RateList) != len(sign7.List) || len(turnplate.List) == 0 {
|
||
logger.Logger.Tracef("GetTurnplate turnplate.List err p.SnId = %v %v %v", p.SnId, len(turnplate.List), len(turnplate.RateList))
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
} else {
|
||
for _, v := range turnplate.RateList {
|
||
if len(turnplate.List) != len(v.Rate) { // 概率和转盘奖励不等
|
||
logger.Logger.Tracef("GetTurnplate turnplate.RateList err p.SnId = %v %v", p.SnId, len(turnplate.List))
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
diff := p.WelfData.Sign7.SignIndex % int32(len(turnplate.RateList))
|
||
|
||
if diff >= int32(len(turnplate.RateList)) {
|
||
logger.Logger.Tracef("GetTurnplate turnplate.List err p.SnId = %v %v %v", p.SnId, len(turnplate.List), len(turnplate.RateList))
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
ts := time.Now().Unix()
|
||
|
||
// 查看是否已经领取
|
||
dif := common.DiffDaybyTs(ts, p.WelfData.Sign7.SignTickets)
|
||
if dif == 0 { // 当天已经领取
|
||
logger.Logger.Tracef("GetTurnplate LastTickets is repeat p.SnId = %v %v %v", p.SnId, p.WelfData.Sign7.SignTickets, diff)
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
var drawdates []*webapi_proto.WelfareDate
|
||
for _, v := range sign7.List {
|
||
if v.Day == diff+1 { // 找到对应天数
|
||
drawdates = append(drawdates, v.Date...) // 领取原始奖励
|
||
|
||
rand := turnplate.RateList[diff].Rate // 找到对应天数概率
|
||
idx := common.RandSliceIndexByWight31N(rand) // 获取奖励下标
|
||
datas := turnplate.List[idx]
|
||
|
||
drawdates = append(drawdates, datas.Date...) // 领取转盘奖励
|
||
|
||
p.WelfData.Sign7.SignTickets = ts // 签到
|
||
if len(p.WelfData.Sign7.TurnplateIdx) >= len(turnplate.RateList) {
|
||
p.WelfData.Sign7.TurnplateIdx = nil
|
||
p.WelfData.Sign7.Addup2Data = make(map[int32]map[int32]int64)
|
||
p.WelfData.Sign7.AddupIndex = []int32{}
|
||
}
|
||
p.WelfData.Sign7.TurnplateIdx = append(p.WelfData.Sign7.TurnplateIdx, int32(idx)) // 获取领取转盘下标
|
||
p.WelfData.Sign7.SignIndex += 1
|
||
// 转盘
|
||
gainWay := int32(common.GainWay_ActTurnplate)
|
||
oper, remark := "system", "轮盘奖励"
|
||
DrawWelfareDate(datas.Date, p, gainWay, oper, remark, false) // 领取奖励
|
||
// 签到
|
||
gainWay = int32(common.GainWay_ActSignNew)
|
||
oper, remark = "system", "新七日签到"
|
||
DrawWelfareDate(v.Date, p, gainWay, oper, remark, false) // 领取奖励
|
||
|
||
for _, d := range drawdates {
|
||
pack.Date = append(pack.Date, &welfare.WelfareDate{
|
||
Grade: d.Grade,
|
||
Type: d.Type,
|
||
Name: d.Name,
|
||
Item_Id: d.Item_Id,
|
||
})
|
||
}
|
||
pack.Idx = int32(idx)
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
hadSign := p.WelfData.Sign7.SignIndex % int32(len(turnplate.RateList))
|
||
if hadSign == 0 {
|
||
hadSign = int32(len(turnplate.RateList))
|
||
}
|
||
pack.SignDay = hadSign // 已签到天数
|
||
TaskSubjectSingleton.Touch(common.TaskTypeTurnplate, &TaskData{SnId: p.SnId, Num: 1})
|
||
break
|
||
}
|
||
}
|
||
|
||
}
|
||
logger.Logger.Tracef("GetTurnplate snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
}
|
||
|
||
// GetTurnplteVideo 转盘视频奖励
|
||
func (this *WelfareMgr) GetTurnplteVideo(p *Player) {
|
||
pack := &welfare.SCGetTurnplate{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
IsVideo: true,
|
||
}
|
||
|
||
send := func() {
|
||
logger.Logger.Tracef("GetTurnplate snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
}
|
||
|
||
info := this.GetConfig(p.Platform)
|
||
turn := info.WelfareTurnplateDateList // 转盘
|
||
sign7 := info.Welfare7SignDateList // 签到
|
||
if turn == nil || sign7 == nil {
|
||
send()
|
||
return
|
||
}
|
||
|
||
if turn.Switch != model.WelfareOpen {
|
||
logger.Logger.Tracef("GetTurnplate Switch err p.SnId = %v %v", p.SnId, turn.Switch)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
if len(turn.RateList) != len(sign7.List) || len(turn.List) == 0 {
|
||
logger.Logger.Tracef("GetTurnplate turn.List err p.SnId = %v %v %v", p.SnId, len(turn.List), len(turn.RateList))
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
} else {
|
||
for _, v := range turn.RateList {
|
||
if len(turn.List) != len(v.Rate) { // 概率和转盘奖励不等
|
||
logger.Logger.Tracef("GetTurnplate turn.RateList err p.SnId = %v %v", p.SnId, len(turn.List))
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
// 看视频奖励只能当天领,在签到之后
|
||
ts := time.Now().Unix()
|
||
// 查看是否已经领取
|
||
diff := common.DiffDaybyTs(ts, p.WelfData.Sign7.SignTickets)
|
||
if diff != 0 { // 当天没签到,需要先签到
|
||
logger.Logger.Tracef("GetTurnplate LastTickets is repeat p.SnId = %v %v %v", p.SnId, p.WelfData.Sign7.SignTickets, diff)
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
// 判断是否已经领取过
|
||
diff = common.DiffDaybyTs(ts, p.WelfData.Sign7.VideoTicket)
|
||
if diff == 0 { // 已经领取过了
|
||
logger.Logger.Tracef("GetTurnplate VideoTicket is repeat p.SnId = %v %v %v", p.SnId, p.WelfData.Sign7.VideoTicket, diff)
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
return
|
||
}
|
||
|
||
// 可以领取
|
||
p.WelfData.Sign7.VideoTicket = ts
|
||
index := p.WelfData.Sign7.SignIndex % int32(len(turn.RateList))
|
||
if index == 0 {
|
||
index = 7
|
||
}
|
||
var drawdates []*webapi_proto.WelfareDate
|
||
for _, v := range sign7.List {
|
||
if v.Day == index { // 找到对应天数
|
||
idx := p.WelfData.Sign7.TurnplateIdx[len(p.WelfData.Sign7.TurnplateIdx)-1]
|
||
drawdates = append(drawdates, v.Date...) // 签到奖励
|
||
datas := turn.List[idx]
|
||
drawdates = append(drawdates, datas.Date...) // 转盘奖励
|
||
|
||
// 转盘
|
||
gainWay := int32(common.GainWay_ActTurnplate2)
|
||
oper, remark := "system", "轮盘奖励"
|
||
DrawWelfareDate(datas.Date, p, gainWay, oper, remark, true) // 领取奖励
|
||
// 签到
|
||
gainWay = int32(common.GainWay_ActSignNew2)
|
||
oper, remark = "system", "新七日签到"
|
||
DrawWelfareDate(v.Date, p, gainWay, oper, remark, true) // 领取奖励
|
||
|
||
for _, d := range drawdates {
|
||
coin := d.Grade * 2
|
||
if d.Type == 1 { // 蝶女金币加成
|
||
roleGirl := ModelMgrSingleton.GetRoleInfo(p, 2000001)
|
||
if roleGirl != nil && roleGirl.Level > 0 {
|
||
coin = int32(float64(coin) * float64(100+roleGirl.Award) / 100.0)
|
||
}
|
||
}
|
||
pack.Date = append(pack.Date, &welfare.WelfareDate{
|
||
Grade: coin,
|
||
Type: d.Type,
|
||
Name: d.Name,
|
||
Item_Id: d.Item_Id,
|
||
})
|
||
}
|
||
pack.Idx = idx
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
hadSign := p.WelfData.Sign7.SignIndex % int32(len(turn.RateList))
|
||
if hadSign == 0 {
|
||
hadSign = int32(len(turn.RateList))
|
||
}
|
||
pack.SignDay = hadSign // 已签到天数
|
||
TaskSubjectSingleton.Touch(common.TaskTypeAdv, &TaskData{
|
||
SnId: p.SnId,
|
||
Num: 1,
|
||
})
|
||
break
|
||
}
|
||
}
|
||
|
||
logger.Logger.Tracef("GetTurnplate snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||
}
|
||
|
||
// isVideo 看视频了,计算看视频加成
|
||
func DrawWelfareDate(dates []*webapi_proto.WelfareDate, p *Player, gainWay int32, oper, remark string, isVideo bool) {
|
||
// 注意dates只能读,不能写
|
||
giveType := int32(-1)
|
||
switch gainWay {
|
||
case common.GainWay_VIPGift:
|
||
giveType = model.SystemFreeGive_GiveType_VipGift
|
||
case common.GainWay_ActTurnplate:
|
||
giveType = model.SystemFreeGive_GiveType_ActTurnplate
|
||
case common.GainWay_ActSignNew:
|
||
if remark == "新七日签到" {
|
||
giveType = model.SystemFreeGive_GiveType_ActSign
|
||
} else { //累签
|
||
giveType = model.SystemFreeGive_GiveType_ActContinuousSign
|
||
gainWay = common.GainWayContinueSign
|
||
}
|
||
}
|
||
for _, v := range dates {
|
||
switch v.Type {
|
||
case 1: //金币
|
||
coin := int64(v.Grade)
|
||
add := int64(0)
|
||
if isVideo {
|
||
roleGirl := ModelMgrSingleton.GetRoleInfo(p, 2000001)
|
||
if roleGirl != nil && roleGirl.Level > 0 /*|| !role.IsUsing*/ {
|
||
//蝶女加成
|
||
add = int64(float64(coin) * float64(roleGirl.Award) * 2 / 100.0)
|
||
}
|
||
coin = coin*2 + add
|
||
}
|
||
|
||
p.AddCoin(coin, add, gainWay, oper, remark)
|
||
if giveType != -1 {
|
||
if !p.IsRob {
|
||
mq.Write(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, giveType, model.SystemFreeGive_CoinType_Coin, int64(coin)))
|
||
}
|
||
}
|
||
case 2: //钻石
|
||
p.AddDiamond(int64(v.Grade), 0, gainWay, oper, remark)
|
||
if giveType != -1 {
|
||
if !p.IsRob {
|
||
mq.Write(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, giveType, model.SystemFreeGive_CoinType_Diamond, int64(v.Grade)))
|
||
}
|
||
}
|
||
case 3: //道具
|
||
if v.Grade > 0 {
|
||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||
Platform: p.Platform,
|
||
SnId: p.SnId,
|
||
Change: []*model.Item{
|
||
{
|
||
ItemId: v.Item_Id,
|
||
ItemNum: int64(v.Grade),
|
||
},
|
||
},
|
||
Add: 0,
|
||
GainWay: gainWay,
|
||
Operator: oper,
|
||
Remark: remark,
|
||
})
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// GetAddupSign 累计签到
|
||
func (this *WelfareMgr) GetAddupSign(p *Player, addupday int32) {
|
||
pack := &welfare.SCGetAddupSign{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
turnplate := info.WelfareTurnplateDateList
|
||
sign7 := info.Welfare7SignDateList
|
||
if turnplate != nil && sign7 != nil {
|
||
if turnplate.Switch != model.WelfareOpen {
|
||
logger.Logger.Tracef("Get7Sign Switch err p.SnId = %v %v", p.SnId, turnplate.Switch)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETADDUPSIGN), pack)
|
||
return
|
||
}
|
||
signIndex := p.WelfData.Sign7.SignIndex
|
||
|
||
if addupday > signIndex || addupday > int32(len(sign7.List)) || addupday < 1 { // 累计签到不够 或者超过签到上限 或者非法输入
|
||
logger.Logger.Tracef("Get7Sign Sign7.SignIndex is repeat p.SnId = %v %v %v", p.SnId, signIndex, addupday)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETADDUPSIGN), pack)
|
||
return
|
||
}
|
||
|
||
for _, v := range p.WelfData.Sign7.AddupIndex {
|
||
if v == addupday { // 已经领取
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
logger.Logger.Tracef("Get7Sign Sign7.AddupIndex is repeat p.SnId = %v %v", p.SnId, addupday)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETADDUPSIGN), pack)
|
||
return
|
||
}
|
||
}
|
||
flag := false
|
||
for _, v := range sign7.List {
|
||
for _, d := range v.AddUpDate { // 累计奖励
|
||
if d.AddUpDay != addupday {
|
||
continue
|
||
}
|
||
p.WelfData.Sign7.AddupIndex = append(p.WelfData.Sign7.AddupIndex, addupday) // 签到
|
||
ad := &welfare.AddUpWelfareDate{
|
||
AddUpDay: d.AddUpDay,
|
||
}
|
||
for _, d1 := range d.AddUpDate {
|
||
ad.AddUpDate = append(ad.AddUpDate, &welfare.WelfareDate{
|
||
Grade: d1.Grade,
|
||
Type: d1.Type,
|
||
Name: d1.Name,
|
||
Item_Id: d1.Item_Id,
|
||
})
|
||
}
|
||
pack.Date = append(pack.Date, ad)
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.AddUpSignDay = append(pack.AddUpSignDay, p.WelfData.Sign7.AddupIndex...)
|
||
gainWay := int32(common.GainWay_ActSignNew)
|
||
oper, remark := "system", fmt.Sprintf("累计%v天签到", addupday)
|
||
DrawWelfareDate(d.AddUpDate, p, gainWay, oper, remark, false) // 领取奖励
|
||
flag = true
|
||
break
|
||
}
|
||
if flag {
|
||
break
|
||
}
|
||
}
|
||
}
|
||
logger.Logger.Tracef("GetAddupSign snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETADDUPSIGN), pack)
|
||
}
|
||
|
||
// WelfaredInfo 转盘签到活动信息
|
||
func (this *WelfareMgr) WelfaredInfo(p *Player) {
|
||
pack := &welfare.SCWelfaredInfo{}
|
||
diff := 0
|
||
ts := time.Now().Unix()
|
||
info := this.GetConfig(p.Platform)
|
||
turnplate := info.WelfareTurnplateDateList
|
||
sign7 := info.Welfare7SignDateList
|
||
//第8天 清除数据
|
||
|
||
if p.WelfData.Sign7.SignIndex%int32(len(turnplate.RateList)) == 0 && (time.Now().Unix()-p.WelfData.Sign7.SignTickets)/86400 >= 1 {
|
||
p.WelfData.Sign7.Addup2Data = make(map[int32]map[int32]int64)
|
||
p.WelfData.Sign7.AddupIndex = []int32{}
|
||
}
|
||
|
||
if turnplate != nil && sign7 != nil {
|
||
pack.Switch = turnplate.Switch
|
||
if turnplate.Switch != model.WelfareClose {
|
||
pack.DrawTurnplate = 2
|
||
signIndex := p.WelfData.Sign7.SignIndex % int32(len(turnplate.RateList))
|
||
|
||
diff = common.DiffDaybyTs(ts, p.WelfData.Sign7.SignTickets)
|
||
if diff == 0 || signIndex >= int32(len(turnplate.RateList)) { // 已经领取 或者全部领取
|
||
pack.DrawTurnplate = 1
|
||
}
|
||
|
||
for _, v := range turnplate.List {
|
||
data := &welfare.WelfareTurnplateDate{
|
||
Id: v.Id,
|
||
}
|
||
for _, d := range v.Date {
|
||
data.Date = append(data.Date, &welfare.WelfareDate{
|
||
Grade: d.Grade,
|
||
Type: d.Type,
|
||
Name: d.Name,
|
||
Item_Id: d.Item_Id,
|
||
})
|
||
}
|
||
pack.Tlist = append(pack.Tlist, data)
|
||
}
|
||
|
||
for _, v := range sign7.List {
|
||
data := &welfare.Welfare7SignDate{
|
||
Day: v.Day,
|
||
}
|
||
ad := &welfare.AddUpWelfareDate{}
|
||
for _, d := range v.Date {
|
||
data.Date = append(data.Date, &welfare.WelfareDate{
|
||
Grade: d.Grade,
|
||
Type: d.Type,
|
||
Name: d.Name,
|
||
Item_Id: d.Item_Id,
|
||
})
|
||
}
|
||
for _, d := range v.AddUpDate { // 累计奖励
|
||
ad.AddUpDay = d.AddUpDay
|
||
for _, d1 := range d.AddUpDate {
|
||
ad.AddUpDate = append(ad.AddUpDate, &welfare.WelfareDate{
|
||
Grade: d1.Grade,
|
||
Type: d1.Type,
|
||
Name: d1.Name,
|
||
Item_Id: d1.Item_Id,
|
||
})
|
||
}
|
||
}
|
||
//进阶数据
|
||
if p.AppChannel == common.ChannelGooglePlay {
|
||
for _, d2 := range v.AddUpDate2Google {
|
||
for _, value := range d2.AddUpDate {
|
||
ad.AddUp2Date = append(ad.AddUp2Date, &welfare.WelfareDate{
|
||
Grade: value.Grade,
|
||
Type: value.Type,
|
||
Name: value.Name,
|
||
Item_Id: value.Item_Id,
|
||
})
|
||
}
|
||
|
||
}
|
||
} else {
|
||
for _, d2 := range v.AddUpDate2 {
|
||
for _, value := range d2.AddUpDate {
|
||
ad.AddUp2Date = append(ad.AddUp2Date, &welfare.WelfareDate{
|
||
Grade: value.Grade,
|
||
Type: value.Type,
|
||
Name: value.Name,
|
||
Item_Id: value.Item_Id,
|
||
})
|
||
}
|
||
|
||
}
|
||
}
|
||
//进阶奖励领取条件
|
||
for _, value := range v.AddUpDate2Type {
|
||
ad.AddUp2Type = append(ad.AddUp2Type, &welfare.AddUp2TypeDate{
|
||
Day: value.Day,
|
||
Id: value.Id,
|
||
Num: value.Num,
|
||
})
|
||
}
|
||
data.AddUpDate = append(data.AddUpDate, ad)
|
||
pack.Slist = append(pack.Slist, data)
|
||
}
|
||
pack.TurnplateIdx = append(pack.TurnplateIdx, p.WelfData.Sign7.TurnplateIdx...)
|
||
//需要判断是要显示7 还是显示0
|
||
if signIndex == 0 {
|
||
if pack.DrawTurnplate == 1 {
|
||
signIndex = int32(len(turnplate.RateList))
|
||
}
|
||
}
|
||
pack.SignDay = signIndex
|
||
pack.AddUpSignDay = append(pack.AddUpSignDay, p.WelfData.Sign7.AddupIndex...)
|
||
}
|
||
//七日签到进阶奖励数据
|
||
// 进阶奖励key1 - day key2-次数 value-结束领取时间戳(-1代表已领取)
|
||
for day, value := range p.WelfData.Sign7.Addup2Data {
|
||
addUp2 := &welfare.Addup2Data{}
|
||
addUp2.Day = day
|
||
for num, endTime := range value {
|
||
addUp2.Num = num
|
||
addUp2.EndTime = endTime
|
||
}
|
||
pack.Addup2 = append(pack.Addup2, addUp2)
|
||
}
|
||
}
|
||
logger.Logger.Tracef("WelfaredInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_WELFAREINFO), pack)
|
||
}
|
||
|
||
// 更新进阶奖励时间
|
||
func (this *WelfareMgr) UpdateAddUp2Date(p *Player, count, day int32, endTime int64) {
|
||
if p.WelfData.Sign7.Addup2Data == nil {
|
||
p.WelfData.Sign7.Addup2Data = make(map[int32]map[int32]int64)
|
||
}
|
||
//p.WelfData.Sign7.Addup2Data[day][1] = time.Now().Unix() + 3600
|
||
info := this.GetConfig(p.Platform)
|
||
if info == nil {
|
||
return
|
||
}
|
||
sign7 := info.Welfare7SignDateList
|
||
if sign7 == nil {
|
||
return
|
||
}
|
||
list := sign7.List
|
||
if list == nil {
|
||
return
|
||
}
|
||
addUpDate2Type := list[day-1].AddUpDate2Type
|
||
if addUpDate2Type == nil {
|
||
return
|
||
}
|
||
p.WelfData.Sign7.Addup2Data[day] = make(map[int32]int64)
|
||
p.WelfData.Sign7.Addup2Data[day][count] = endTime
|
||
//通知客户端
|
||
pack := &welfare.SCSignDayAddup2Award{}
|
||
pack.Day = day
|
||
pack.Num = count
|
||
pack.EndTime = p.WelfData.Sign7.Addup2Data[day][count]
|
||
logger.Logger.Trace("通知客户端更新进阶奖励时间!!!!!!!!")
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_SignDay_Addup2Award), pack)
|
||
if !this.Welfareturnplate(p, 0) {
|
||
p.SendShowRed(hall_proto.ShowRedCode_Welfare, 0, 1) // 0 轮盘红点
|
||
}
|
||
}
|
||
|
||
// 领取进阶奖励
|
||
func (this *WelfareMgr) GetAddUp2Award(p *Player, day int32) {
|
||
// 判断是否已经领取
|
||
Num := int32(0)
|
||
EndTime := int64(0)
|
||
if p.WelfData.Sign7.Addup2Data[day] == nil {
|
||
return
|
||
}
|
||
for num, endTime := range p.WelfData.Sign7.Addup2Data[day] {
|
||
if endTime == -1 {
|
||
return
|
||
}
|
||
if endTime < time.Now().Unix() {
|
||
return
|
||
}
|
||
Num = num
|
||
EndTime = endTime
|
||
}
|
||
//获取配置
|
||
info := this.GetConfig(p.Platform)
|
||
if info == nil {
|
||
return
|
||
}
|
||
sign7 := info.Welfare7SignDateList
|
||
if sign7 == nil {
|
||
return
|
||
}
|
||
list := sign7.List
|
||
if list == nil {
|
||
return
|
||
}
|
||
addUpDate2 := list[day-1].AddUpDate2
|
||
if p.AppChannel == common.ChannelGooglePlay {
|
||
addUpDate2 = list[day-1].AddUpDate2Google
|
||
}
|
||
addUpDate2Type := list[day-1].AddUpDate2Type
|
||
if addUpDate2Type == nil {
|
||
return
|
||
}
|
||
typeId := addUpDate2Type[0].Id
|
||
addUpDate2Num := addUpDate2Type[0].Num
|
||
var cost []*model.Item
|
||
if typeId == 1 {
|
||
Num += 1
|
||
//看广告任务
|
||
TaskSubjectSingleton.Touch(common.TaskTypeAdv, &TaskData{
|
||
SnId: p.SnId,
|
||
Num: 1,
|
||
})
|
||
} else {
|
||
//扣除钻石
|
||
if p.Diamond < int64(addUpDate2Num) {
|
||
return
|
||
}
|
||
p.AddDiamond(int64(-addUpDate2Num), 0, common.GainWaySign7Con, "system", "累计签到进阶奖励钻石消耗")
|
||
logger.Logger.Trace("累计签到进阶奖励,扣除钻石uid = ", p.SnId)
|
||
EndTime = -1
|
||
cost = append(cost, &model.Item{
|
||
ItemId: common.ItemIDDiamond,
|
||
ItemNum: int64(addUpDate2Num),
|
||
})
|
||
}
|
||
p.WelfData.Sign7.Addup2Data[day] = make(map[int32]int64)
|
||
p.WelfData.Sign7.Addup2Data[day][Num+1] = EndTime
|
||
if typeId == 1 && Num >= addUpDate2Num {
|
||
EndTime = -1
|
||
}
|
||
if EndTime == -1 {
|
||
//发奖
|
||
var items []*model.Item
|
||
for _, d2 := range addUpDate2 {
|
||
for _, value := range d2.AddUpDate {
|
||
item := &model.Item{
|
||
ItemId: value.Item_Id,
|
||
ItemNum: int64(value.Grade),
|
||
}
|
||
items = append(items, item)
|
||
}
|
||
}
|
||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||
Platform: p.Platform,
|
||
SnId: p.SnId,
|
||
Change: items,
|
||
Cost: cost,
|
||
Add: 0,
|
||
GainWay: common.GainWaySign7Add,
|
||
Operator: "system",
|
||
Remark: "累计签到进阶奖励获得",
|
||
GameId: 0,
|
||
GameFreeId: 0,
|
||
})
|
||
}
|
||
//通知客户端
|
||
this.UpdateAddUp2Date(p, Num, day, EndTime)
|
||
|
||
}
|
||
|
||
// WelfareSwitch 通知活动开关状态
|
||
func (this *WelfareMgr) WelfareSwitch(p *Player, platform string, op int) {
|
||
pack := &player_proto.SCEasyWelfaredInfo{}
|
||
// 0转盘1盲盒2首冲3连续充值
|
||
info := this.GetConfig(platform)
|
||
|
||
// 转盘
|
||
turnplate := info.WelfareTurnplateDateList
|
||
if turnplate != nil {
|
||
if op == model.OpAll || op == model.OpTurnplate {
|
||
if turnplate.Switch == model.WelfareOpen && p != nil && this.Welfareturnplate(p, 1) { // 没有关闭且所有奖励已经领取
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) //关闭
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, turnplate.Switch)
|
||
}
|
||
} else { // 不更新
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareNil)
|
||
}
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) // 配置nil就是关闭
|
||
}
|
||
// 盲盒
|
||
blindBox := info.WelfareBlindBoxDataList
|
||
if blindBox != nil {
|
||
if op == model.OpAll || op == model.OpBlindBox {
|
||
if blindBox.Switch == model.WelfareOpen && blindBox.Cycle == model.WelfareClose && p != nil && p.WelfData.BlindBoxId != 0 { // 没有关闭且所有奖励已经领取
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) //关闭
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, blindBox.Switch)
|
||
}
|
||
} else { // 不更新
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareNil)
|
||
}
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) // 配置nil就是关闭
|
||
}
|
||
// 首充
|
||
firstPay := info.WelfareFirstPayDataList
|
||
if firstPay != nil {
|
||
if op == model.OpAll || op == model.OpFirstPay {
|
||
ln := len(firstPay.List)
|
||
max := firstPay.List[ln-1].Day // 正序
|
||
if firstPay.Switch == model.WelfareOpen && firstPay.Cycle == model.WelfareClose && p != nil && p.WelfData.FirstPayDay >= max { // 没有关闭且所有奖励已经领取
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) //关闭
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, firstPay.Switch)
|
||
}
|
||
} else { // 不更新
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareNil)
|
||
}
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) // 配置nil就是关闭
|
||
}
|
||
// 连充
|
||
continuousPay := info.WelfareContinuousPayDataList
|
||
if continuousPay != nil {
|
||
if op == model.OpAll || op == model.OpContinuousPay {
|
||
ln := len(continuousPay.List)
|
||
max := continuousPay.List[ln-1].Day // 正序
|
||
if continuousPay.Switch == model.WelfareOpen && continuousPay.Cycle == model.WelfareClose && p != nil && p.WelfData.ContinuousPayDay >= max { // 没有关闭且所有奖励已经领取
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) //关闭
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, continuousPay.Switch)
|
||
}
|
||
} else { // 不更新
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareNil)
|
||
}
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose) // 配置nil就是关闭
|
||
}
|
||
// 抽手机活动开关
|
||
phoneConfig := info.WelfarePhoneLotteryStatus
|
||
if phoneConfig != nil {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, phoneConfig.Switch) //抽手机活动开关
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose)
|
||
}
|
||
// 集卡活动
|
||
collectConfig := info.WelfareCollectConfig
|
||
if collectConfig != nil {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, collectConfig.Switch) //集卡活动开关
|
||
} else {
|
||
pack.WelfareSwitch = append(pack.WelfareSwitch, model.WelfareClose)
|
||
}
|
||
|
||
if model.GameParamData.TestActSwitch {
|
||
for k := range pack.WelfareSwitch {
|
||
pack.WelfareSwitch[k] = model.WelfareOpen
|
||
}
|
||
}
|
||
|
||
if p != nil {
|
||
logger.Logger.Tracef("WelfareSwitch snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_SWELFAREINFO), pack)
|
||
} else {
|
||
logger.Logger.Tracef("WelfareSwitch to Platform pack: %v", pack)
|
||
PlayerMgrSington.BroadcastMessageToPlatform(platform, int(player_proto.PlayerPacketID_PACKET_SC_SWELFAREINFO), pack)
|
||
}
|
||
}
|
||
|
||
// Welfareturnplate 转盘红点
|
||
func (this *WelfareMgr) Welfareturnplate(p *Player, op int32) bool { // 0 红点提示 1全部领取
|
||
var isShow bool
|
||
info := this.GetConfig(p.Platform)
|
||
turnplate := info.WelfareTurnplateDateList
|
||
sign7 := info.Welfare7SignDateList
|
||
if turnplate != nil && sign7 != nil {
|
||
if turnplate.Switch == model.WelfareClose {
|
||
return true
|
||
}
|
||
diff := 0
|
||
ts := time.Now().Unix()
|
||
signIndex := p.WelfData.Sign7.SignIndex % int32(len(turnplate.RateList))
|
||
|
||
diff = common.DiffDaybyTs(ts, p.WelfData.Sign7.SignTickets)
|
||
if diff == 0 || signIndex >= int32(len(turnplate.RateList)) { // 已经领取 或者全部领取
|
||
isShow = true
|
||
if op == 1 && signIndex < int32(len(turnplate.RateList)) { // 没有领完
|
||
isShow = false
|
||
}
|
||
}
|
||
|
||
if isShow { // 当日已经领取 查看累计奖励是否领取
|
||
var addUpDate []int32
|
||
for _, v := range sign7.List {
|
||
for _, d := range v.AddUpDate { // 累计奖励
|
||
addUpDate = append(addUpDate, d.AddUpDay)
|
||
}
|
||
}
|
||
signIndex = p.WelfData.Sign7.SignIndex % int32(len(turnplate.RateList))
|
||
for _, addupday := range addUpDate {
|
||
if addupday <= signIndex {
|
||
falg := false
|
||
for _, v := range p.WelfData.Sign7.AddupIndex {
|
||
if v == addupday { // 已经领取
|
||
falg = true
|
||
break
|
||
}
|
||
}
|
||
if !falg {
|
||
isShow = false // 有未领取每日奖励
|
||
break
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
//进阶奖励key1 - day key2-次数 value-结束领取时间戳(-1代表已领取)
|
||
for _, data := range p.WelfData.Sign7.Addup2Data {
|
||
for _, endTime := range data {
|
||
if time.Now().Unix() < endTime && endTime != -1 {
|
||
isShow = false // 有未领取进阶奖励
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return isShow
|
||
}
|
||
|
||
func (this *WelfareMgr) WelfareShowRed(p *Player) {
|
||
if p == nil {
|
||
return
|
||
}
|
||
this.MonitorWelfData(p) // 登录检测
|
||
this.WelfareSwitch(p, p.Platform, model.OpAll)
|
||
|
||
if !this.Welfareturnplate(p, 0) {
|
||
p.SendShowRed(hall_proto.ShowRedCode_Welfare, 0, 1) // 0 轮盘红点
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) BlindBoxInfo(p *Player, bid int32) {
|
||
pack := &welfare.SCBlindBoxInfo{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
blindBox := info.WelfareBlindBoxDataList
|
||
if blindBox != nil {
|
||
if blindBox.Switch != model.WelfareOpen {
|
||
logger.Logger.Tracef("BlindBoxInfo Switch err p.SnId = %v %v", p.SnId, blindBox.Switch)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_BLINBOXINFO), pack)
|
||
return
|
||
}
|
||
ln := len(blindBox.List)
|
||
if ln < 2 { // 一个以上
|
||
logger.Logger.Tracef("BlindBoxInfo blindBox.List err p.SnId = %v %v", p.SnId, ln)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_BLINBOXINFO), pack)
|
||
return
|
||
}
|
||
|
||
pack.MinId = blindBox.MinId
|
||
pack.Draw = 1
|
||
cyc := info.BlindBoxCycle
|
||
if p.WelfData.BlindBoxId == -1 {
|
||
if cyc == 1 || blindBox.Cycle == model.WelfareOpen {
|
||
p.WelfData.BlindBoxId = 0
|
||
}
|
||
} // == 1代表当日循环
|
||
if p.WelfData.BlindBoxId == 0 { // 未领取过发随机Date
|
||
|
||
idx := bid
|
||
num := 0
|
||
for int32(idx) == bid { // 不相等跳出 ln>1 不会死循环
|
||
idx = int32(common.RandInt(ln)) + 1
|
||
if num > 100 {
|
||
break
|
||
}
|
||
num++
|
||
}
|
||
data := blindBox.List[idx-1]
|
||
pack.Draw = 2
|
||
pack.Date = &welfare.BlindBoxData{
|
||
Id: data.Id,
|
||
Type: data.Type,
|
||
Name: data.Name,
|
||
Grade: data.Grade,
|
||
Consume: data.Consume,
|
||
Price1: data.Price1,
|
||
Price2: data.Price2,
|
||
Discount: data.Discount,
|
||
//Item_Id: data.Item_Id, 目前未使用
|
||
}
|
||
}
|
||
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.Cycle = blindBox.Cycle
|
||
}
|
||
logger.Logger.Tracef("BlindBoxInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_BLINBOXINFO), pack)
|
||
}
|
||
|
||
func (this *WelfareMgr) RecordWelfareLog(p *Player, num, takenum, discount int64, day, gainWay, wtype int32, item []*model.WelfareItem, oper, remark string) {
|
||
|
||
log := model.NewWelfareLogEx(p.SnId, num, takenum, p.Coin, p.Diamond, discount, day,
|
||
p.Ver, gainWay, wtype, item, oper, remark, p.Platform, p.Channel,
|
||
p.BeUnderAgentCode, p.PackageID)
|
||
|
||
if log != nil {
|
||
//logger.Logger.Trace("RecordItemLog 开始记录 道具操作")
|
||
mq.Write(log)
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) BuyBlindBox(p *Player, buyid, ConfigPayId int32) {
|
||
// this.MonitorWelfData(p)
|
||
//pack := &welfare.SCGetBlindBox{
|
||
// OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
//}
|
||
pack := &shop.SCPayInfo{
|
||
RetCode: shop.OpResultCode_OPRC_Error,
|
||
}
|
||
blindBox := this.GetConfig(p.Platform).WelfareBlindBoxDataList
|
||
if blindBox == nil {
|
||
logger.Logger.Tracef("BuyBlindBox blindBox==nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
if blindBox.Switch != model.WelfareOpen {
|
||
logger.Logger.Tracef("BuyBlindBox Switch err p.SnId = %v %v", p.SnId, blindBox.Switch)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
|
||
if p.WelfData.BlindBoxId != 0 { // 已经领取
|
||
logger.Logger.Tracef("BuyBlindBox BlindBoxId is repeat = %v %v", p.SnId, p.WelfData.BlindBoxId)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
var bbd *webapi_proto.BlindBoxData
|
||
for _, v := range blindBox.List {
|
||
if v.Id == buyid {
|
||
bbd = v
|
||
//if v.Consume == ConsumeDiamond {
|
||
//if p.Diamond < v.Price2 {
|
||
// logger.Logger.Tracef("BuyBlindBox Diamond < Price2 p.SnId = %v %v %v", p.SnId, p.Diamond, v.Price2)
|
||
// pack.OpRetCode = welfare.OpResultCode_OPRC_ErrCoin
|
||
// p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETBLINBOX), pack)
|
||
// return
|
||
//}
|
||
//p.WelfData.BlindBoxId = v.Id
|
||
//gainWay := int32(common.GainWay_ActBlindBox)
|
||
//oper, remark := "system", "购买盲盒"
|
||
//p.AddDiamond(-v.Price2, gainWay, oper, remark) // 消耗
|
||
//oper, remark = "system", "盲盒奖励"
|
||
//switch v.Type { // 增加
|
||
//case 1: //金币
|
||
// p.AddCoin(int64(v.Grade), gainWay, oper, remark)
|
||
//case 2: //钻石
|
||
// p.AddDiamond(int64(v.Grade), gainWay, oper, remark)
|
||
//}
|
||
//
|
||
//// 记录
|
||
//item := []*model.WelfareItem{&model.WelfareItem{
|
||
// Num: int64(v.Grade),
|
||
// ItemId: v.Item_Id,
|
||
// Type: v.Type,
|
||
//}}
|
||
//this.RecordWelfareLog(p, int64(v.Grade), v.Price2, int64(v.Discount*10000), 0, gainWay, model.WelfareBuyBlindBox,
|
||
// item, oper, remark)
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
//break
|
||
//}
|
||
|
||
//if v.Consume != ConsumeDiamond { // 非钻石支付需要接三方 不能走这里判断
|
||
// logger.Logger.Tracef("BuyBlindBox Switch err p.SnId = %v %v", p.SnId, blindBox.Switch)
|
||
// p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETBLINBOX), pack)
|
||
// return
|
||
//}
|
||
}
|
||
}
|
||
if bbd == nil {
|
||
logger.Logger.Tracef("BuyBlindBox bbd == nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
ShopMgrSington.SendAPICreateOrder(p, ConfigPayId, bbd, "BlindBox")
|
||
////三方购买
|
||
//task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||
// var amount [3]int32
|
||
// if bbd.Type == 1 {
|
||
// //金币
|
||
// amount[0] = bbd.Grade
|
||
// } else if bbd.Type == 2 {
|
||
// //钻石
|
||
// amount[1] = bbd.Grade
|
||
// }
|
||
// dbShop := model.NewDbShop(p.Platform, 0, amount[:], Shop_Consume_Money, int32(bbd.Price2), nil, 0, "",
|
||
// p.SnId, 0, "BlindBox")
|
||
// err := model.InsertDbShopLog(dbShop)
|
||
// if err != nil {
|
||
// logger.Logger.Errorf("model.InsertDbShopLog err:", err)
|
||
// return nil
|
||
// }
|
||
// return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
||
// p.DeviceId, bbd.Name, amount, int32(bbd.Price2), nil)
|
||
//}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||
// logger.Logger.Trace("API_CreateOrder_BuyBlindBox:", data)
|
||
// info := data.(*webapi_proto.ASCreateOrder)
|
||
// if info == nil || info.Tag != 0 {
|
||
// //失败
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// } else {
|
||
// pack.RetCode = shop.OpResultCode_OPRC_Sucess
|
||
// pack.Url = info.Url
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// }
|
||
//}), "API_CreateOrder_BuyBlindBox").Start()
|
||
}
|
||
|
||
func (this *WelfareMgr) FirstPayInfo(p *Player) {
|
||
pack := &welfare.SCWelfareFirstPayData{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
firstPay := info.WelfareFirstPayDataList
|
||
if firstPay != nil {
|
||
pack.Switch = firstPay.Switch
|
||
if firstPay.Switch != model.WelfareClose {
|
||
ln := len(firstPay.List)
|
||
if ln == 0 { // 不能为空
|
||
logger.Logger.Tracef("FirstPayInfo firstPay.List err p.SnId = %v %v", p.SnId, ln)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_FIRSTPAYINFO), pack)
|
||
return
|
||
}
|
||
|
||
ts := time.Now().Unix()
|
||
day := p.WelfData.FirstPayDay
|
||
pack.Draw = 2
|
||
if day != 0 { // 查看是否已经领取
|
||
dif := common.DiffDaybyTs(ts, p.WelfData.FirstPayTickets)
|
||
if dif == 0 { // 当天已经领取
|
||
pack.Draw = 1
|
||
}
|
||
}
|
||
|
||
max := firstPay.List[ln-1].Day // 正序
|
||
cyc := info.FirstPayCycle
|
||
if pack.Draw == 2 { // 当天未领取判断
|
||
if day >= max {
|
||
if firstPay.Cycle != model.WelfareOpen && cyc != 1 { // 全部领取完就发最后一天
|
||
day = max
|
||
pack.Draw = 1 // 不循环 且今日无开启循环操作 领完不能再领取了
|
||
} else {
|
||
// p.WelfData.FirstPayDay = 0 // 循环
|
||
day = firstPay.List[0].Day // 从第一天开始
|
||
}
|
||
} else if day == 0 {
|
||
day = firstPay.List[0].Day
|
||
}
|
||
}
|
||
pack.Cycle = firstPay.Cycle
|
||
MoneyRatio := float64(0)
|
||
if vips := VipMgrSington.GetVIPcfg(p.Platform); vips != nil {
|
||
MoneyRatio = vips.MoneyRatio
|
||
}
|
||
for _, v := range firstPay.List {
|
||
if v.Day == day {
|
||
vipEx := v.VIPEX
|
||
if MoneyRatio > 0.000001 {
|
||
vipEx = int32(float64(v.Price2) * MoneyRatio)
|
||
}
|
||
pack.List = &welfare.WelfareSpree{
|
||
Day: v.Day,
|
||
VIPEX: vipEx,
|
||
Consume: v.Consume,
|
||
Price1: v.Price1,
|
||
Price2: v.Price2,
|
||
Discount: v.Discount,
|
||
}
|
||
for _, it := range v.Item {
|
||
pack.List.Item = append(pack.List.Item, &welfare.WelfareDate{
|
||
Grade: it.Grade,
|
||
Type: it.Type,
|
||
Name: it.Name,
|
||
Item_Id: it.Item_Id,
|
||
})
|
||
}
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
logger.Logger.Tracef("FirstPayInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_FIRSTPAYINFO), pack)
|
||
}
|
||
|
||
// 默认已经成功
|
||
func (this *WelfareMgr) BuyFirstPay(p *Player, ConfigPayId int32) {
|
||
// this.MonitorWelfData(p)
|
||
//pack := &welfare.SCWelfareFirstPay{
|
||
// OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
//}
|
||
pack := &shop.SCPayInfo{
|
||
RetCode: shop.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
firstPay := info.WelfareFirstPayDataList
|
||
if firstPay == nil {
|
||
logger.Logger.Errorf("BuyFirstPay firstPay == nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
ts := time.Now().Unix()
|
||
|
||
if p.WelfData.FirstPayDay != 0 { // 查看是否已经领取
|
||
dif := common.DiffDaybyTs(ts, p.WelfData.FirstPayTickets)
|
||
if dif == 0 { // 当天已经领取
|
||
logger.Logger.Errorf("BuyFirstPay LastTickets is repeat p.SnId = %v %v", p.SnId, p.WelfData.FirstPayTickets)
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
}
|
||
|
||
ln := len(firstPay.List)
|
||
if ln == 0 { // 不能为空
|
||
logger.Logger.Errorf("BuyFirstPay firstPay.List err p.SnId = %v %v", p.SnId, ln)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
max := firstPay.List[ln-1].Day // 正序
|
||
|
||
if p.WelfData.FirstPayDay >= max {
|
||
cyc := info.FirstPayCycle
|
||
if firstPay.Cycle != model.WelfareOpen && cyc != 1 { // 全部领取完
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
logger.Logger.Tracef("BuyFirstPay Cycle p.WelfData.FirstPayDay max p.SnId = %v %v", p.SnId, firstPay.Cycle, p.WelfData.FirstPayDay, max)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
p.WelfData.FirstPayDay = 0
|
||
}
|
||
|
||
var wfs *webapi_proto.WelfareSpree
|
||
|
||
for i, v := range firstPay.List {
|
||
|
||
if v.Day == p.WelfData.FirstPayDay || p.WelfData.FirstPayDay == 0 {
|
||
|
||
if p.WelfData.FirstPayDay != 0 { // 为0领取第一个 p.WelfData.FirstPayDay不为0代表已经领取到该礼包 需要领取下一个
|
||
i++
|
||
}
|
||
wfs = v
|
||
|
||
//data := firstPay.List[i] // 越界条件已判断
|
||
//
|
||
//p.WelfData.FirstPayDay = data.Day
|
||
//p.WelfData.FirstPayTickets = ts
|
||
//// TODO
|
||
//p.AddMoneyPayTotal(v.Price2)
|
||
//gainWay := int32(common.GainWay_ActFirstPay)
|
||
//oper, remark := "system", "首充奖励"
|
||
//DrawWelfareDate(data.Item, p, gainWay, oper, remark) // 领取奖励
|
||
//var item []*model.WelfareItem
|
||
//for _, v := range data.Item {
|
||
// item = append(item, &model.WelfareItem{
|
||
// Num: int64(v.Grade),
|
||
// ItemId: v.Item_Id,
|
||
// Type: v.Type,
|
||
// })
|
||
//}
|
||
//MoneyRatio := float64(0)
|
||
//if vips := VipMgrSington.GetVIPcfg(p.Platform); vips != nil {
|
||
// MoneyRatio = vips.MoneyRatio
|
||
//}
|
||
//vipEx := int64(data.VIPEX)
|
||
//if MoneyRatio > 0.000001 {
|
||
// vipEx = int64(float64(v.Price2) * MoneyRatio)
|
||
//}
|
||
//this.RecordWelfareLog(p, vipEx, v.Price2, int64(v.Discount*10000), p.WelfData.FirstPayDay, gainWay, model.WelfareBuyFirstPay,
|
||
// item, oper, remark)
|
||
//
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
break
|
||
}
|
||
}
|
||
if wfs == nil || wfs.Item == nil {
|
||
logger.Logger.Errorf("BuyFirstPay fwfs == nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
ShopMgrSington.SendAPICreateOrder(p, ConfigPayId, wfs, "FirstRecharge")
|
||
////三方购买
|
||
//task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||
// var amount [3]int32
|
||
// for _, it := range wfs.Item {
|
||
// if it.Type == 1 {
|
||
// amount[0] = it.Grade
|
||
// } else if it.Type == 2 {
|
||
// amount[1] = it.Grade
|
||
// }
|
||
// }
|
||
// dbShop := model.NewDbShop(p.Platform, 0, amount[:], Shop_Consume_Money, int32(wfs.Price2),
|
||
// nil, 0, "", p.SnId, 0, "FirstRecharge")
|
||
// err := model.InsertDbShopLog(dbShop)
|
||
// if err != nil {
|
||
// logger.Logger.Errorf("model.InsertDbShopLog err:", err)
|
||
// return nil
|
||
// }
|
||
// return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
||
// p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), nil)
|
||
//}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||
// logger.Logger.Trace("API_CreateOrder_BuyFirstPay:", data)
|
||
// info := data.(*webapi_proto.ASCreateOrder)
|
||
// if info == nil || info.Tag != 0 {
|
||
// //失败
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// } else {
|
||
// pack.RetCode = shop.OpResultCode_OPRC_Sucess
|
||
// pack.Url = info.Url
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// }
|
||
//}), "API_CreateOrder_BuyFirstPay").Start()
|
||
}
|
||
|
||
func (this *WelfareMgr) ContinuousPayInfo(p *Player) {
|
||
// this.MonitorWelfData(p)
|
||
pack := &welfare.SCWelfareContinuousPayData{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
continuousPay := info.WelfareContinuousPayDataList
|
||
if continuousPay != nil {
|
||
pack.Switch = continuousPay.Switch
|
||
if continuousPay.Switch != model.WelfareClose {
|
||
ln := len(continuousPay.List)
|
||
if ln == 0 { // 不能为空
|
||
logger.Logger.Tracef("ContinuousPayInfo continuousPay.List err p.SnId = %v %v", p.SnId, ln)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_FIRSTPAYINFO), pack)
|
||
return
|
||
}
|
||
|
||
ts := time.Now().Unix()
|
||
day := p.WelfData.ContinuousPayDay
|
||
max := continuousPay.List[ln-1].Day // 正序
|
||
pack.Draw = 2
|
||
if day != 0 { // 查看是否已经领取
|
||
dif := common.DiffDaybyTs(ts, p.WelfData.ContinuousPayTickets)
|
||
if dif == 0 { // 当天已经领取
|
||
pack.Draw = 1
|
||
} else if continuousPay.Break == model.WelfareOpen && dif > 1 && p.WelfData.ContinuousPayDay < max { // 开启中断
|
||
day = 0 //continuousPay.List[0].Day // 从头开始
|
||
}
|
||
}
|
||
|
||
if pack.Draw == 2 { // 当天未领取判断
|
||
cyc := info.ContinuousPayCycle
|
||
for i, v := range continuousPay.List {
|
||
if v.Day == day || day == 0 || day >= max {
|
||
if day != 0 { // 为0领取第一个 day不为0代表已经领取到该礼包 需要领取下一个
|
||
i++
|
||
}
|
||
if day >= max {
|
||
i = ln
|
||
}
|
||
if i < ln {
|
||
day = continuousPay.List[i].Day
|
||
} else {
|
||
if continuousPay.Cycle != model.WelfareOpen && cyc != 1 { // 全部领取完就发最后一天
|
||
day = max
|
||
pack.Draw = 1 // 不循环 领完不能再领取了
|
||
} else {
|
||
day = continuousPay.List[0].Day // 从第一天开始
|
||
}
|
||
}
|
||
break
|
||
}
|
||
}
|
||
|
||
}
|
||
pack.Day = day
|
||
pack.Cycle = continuousPay.Cycle
|
||
for _, v := range continuousPay.List {
|
||
|
||
data := &welfare.WelfareSpree{
|
||
Day: v.Day,
|
||
// VIPEX: v.VIPEX,
|
||
Consume: v.Consume,
|
||
Price1: v.Price1,
|
||
Price2: v.Price2,
|
||
Discount: v.Discount,
|
||
}
|
||
for _, it := range v.Item {
|
||
data.Item = append(data.Item, &welfare.WelfareDate{
|
||
Grade: it.Grade,
|
||
Type: it.Type,
|
||
Name: it.Name,
|
||
Item_Id: it.Item_Id,
|
||
})
|
||
}
|
||
pack.List = append(pack.List, data)
|
||
}
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
}
|
||
}
|
||
logger.Logger.Tracef("ContinuousPayInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_CONTINPAYINFO), pack)
|
||
}
|
||
|
||
// 默认已经成功
|
||
func (this *WelfareMgr) BuyContinuousPay(p *Player, ConfigPayId int32) {
|
||
pack := &shop.SCPayInfo{
|
||
RetCode: shop.OpResultCode_OPRC_Error,
|
||
}
|
||
info := this.GetConfig(p.Platform)
|
||
continuousPay := info.WelfareContinuousPayDataList
|
||
if continuousPay == nil {
|
||
logger.Logger.Tracef("BuyContinuousPay continuousPay == nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
ts := time.Now().Unix()
|
||
|
||
ln := len(continuousPay.List)
|
||
if ln == 0 { // 不能为空
|
||
logger.Logger.Tracef("BuyContinuousPay firstPay.List err p.SnId = %v %v", p.SnId, ln)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
max := continuousPay.List[ln-1].Day // 正序
|
||
|
||
if p.WelfData.ContinuousPayDay != 0 { // 查看是否已经领取
|
||
dif := common.DiffDaybyTs(ts, p.WelfData.ContinuousPayTickets)
|
||
if dif == 0 { // 当天已经领取
|
||
logger.Logger.Tracef("BuyContinuousPay LastTickets is repeat p.SnId = %v %v", p.SnId, p.WelfData.ContinuousPayTickets)
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
} else if continuousPay.Break == model.WelfareOpen && dif > 1 && p.WelfData.ContinuousPayDay < max { // 开启中断 且没有领取到最后一天
|
||
p.WelfData.ContinuousPayDay = 0 // 从第一天开始
|
||
}
|
||
}
|
||
|
||
if p.WelfData.ContinuousPayDay >= max {
|
||
cyc := info.ContinuousPayCycle
|
||
if continuousPay.Cycle != model.WelfareOpen && cyc != 1 { // 全部领取完
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_NoTimes
|
||
logger.Logger.Tracef("BuyContinuousPay Cycle p.WelfData.FirstPayDay max p.SnId = %v %v", p.SnId, continuousPay.Cycle, p.WelfData.ContinuousPayDay, max)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
p.WelfData.ContinuousPayDay = 0
|
||
}
|
||
var wfs *webapi_proto.WelfareSpree
|
||
for i, v := range continuousPay.List {
|
||
|
||
if v.Day == p.WelfData.ContinuousPayDay || p.WelfData.ContinuousPayDay == 0 {
|
||
if p.WelfData.ContinuousPayDay != 0 { // 为0领取第一个 p.WelfData.FirstPayDay不为0代表已经领取到该礼包 需要领取下一个
|
||
i++
|
||
}
|
||
wfs = v
|
||
|
||
//data := continuousPay.List[i] // 越界条件已判断
|
||
//
|
||
//p.WelfData.ContinuousPayDay = data.Day
|
||
//p.WelfData.ContinuousPayTickets = ts
|
||
//// TODO
|
||
//p.AddMoneyPayTotal(v.Price2)
|
||
//gainWay := int32(common.GainWay_ActContinuousPay)
|
||
//oper, remark := "system", "连续充值奖励"
|
||
//DrawWelfareDate(data.Item, p, gainWay, oper, remark) // 领取奖励
|
||
//var item []*model.WelfareItem
|
||
//for _, v := range data.Item {
|
||
// item = append(item, &model.WelfareItem{
|
||
// Num: int64(v.Grade),
|
||
// ItemId: v.Item_Id,
|
||
// Type: v.Type,
|
||
// })
|
||
//}
|
||
//MoneyRatio := float64(0)
|
||
//if vips := VipMgrSington.GetVIPcfg(p.Platform); vips != nil {
|
||
// MoneyRatio = vips.MoneyRatio
|
||
//}
|
||
//vipEx := int64(data.VIPEX)
|
||
//if MoneyRatio > 0.000001 {
|
||
// vipEx = int64(float64(v.Price2) * MoneyRatio)
|
||
//}
|
||
//this.RecordWelfareLog(p, vipEx, v.Price2, int64(v.Discount*10000), p.WelfData.FirstPayDay, gainWay, model.WelfareBuyFirstPay,
|
||
// item, oper, remark)
|
||
//
|
||
//pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
break
|
||
}
|
||
}
|
||
if wfs == nil || wfs.Item == nil {
|
||
logger.Logger.Tracef("BuyContinuousPay wfs == nil snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
return
|
||
}
|
||
ShopMgrSington.SendAPICreateOrder(p, ConfigPayId, wfs, "ContinuousPay")
|
||
//三方购买
|
||
//task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||
// var amount [3]int32
|
||
// for _, it := range wfs.Item {
|
||
// if it.Type == 1 {
|
||
// amount[0] = it.Grade
|
||
// } else if it.Type == 2 {
|
||
// amount[1] = it.Grade
|
||
// }
|
||
// }
|
||
// dbShop := model.NewDbShop(p.Platform, 0, amount[:], Shop_Consume_Money, int32(wfs.Price2),
|
||
// nil, 0, "", p.SnId, 0, "ContinuousPay")
|
||
// err := model.InsertDbShopLog(dbShop)
|
||
// if err != nil {
|
||
// logger.Logger.Errorf("model.InsertDbShopLog err:", err)
|
||
// return nil
|
||
// }
|
||
// return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
|
||
// p.DeviceId, "ContinuousRecharge", amount, int32(wfs.Price2), nil)
|
||
//}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||
// logger.Logger.Trace("API_CreateOrder_BuyContinuousPay:", data)
|
||
// info := data.(*webapi_proto.ASCreateOrder)
|
||
// if info == nil || info.Tag != 0 {
|
||
// //失败
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// } else {
|
||
// pack.RetCode = shop.OpResultCode_OPRC_Sucess
|
||
// pack.Url = info.Url
|
||
// p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||
// }
|
||
//}), "API_CreateOrder_BuyContinuousPay").Start()
|
||
}
|
||
|
||
// PigbankGetInfo 存钱罐信息
|
||
func (this *WelfareMgr) PigbankGetInfo(p *Player) {
|
||
pack := &welfare.SCPigbankGetInfo{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
|
||
fGetPropValue := func(propName string) int32 {
|
||
pool := srvdata.PBDB_Pigbank_PropMgr.Datas.GetArr()
|
||
for _, PropItem := range pool {
|
||
if PropItem.PorpName == propName {
|
||
return PropItem.PropValue
|
||
}
|
||
}
|
||
return 0
|
||
}
|
||
|
||
/* fGetCostDiamond := func(taketimes int32) int64 {
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
for _, data := range pool {
|
||
if taketimes >= data.BuyCountMin && taketimes <= data.BuyCountMax {
|
||
return int64(data.CostDiamond)
|
||
}
|
||
}
|
||
return 0
|
||
}*/
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
infoData := pool[0]
|
||
for _, data := range pool {
|
||
if p.WelfData.PigBank.DayBuyTimes+1+1 >= data.BuyCountMin && p.WelfData.PigBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
|
||
BankMaxCoin := int64(0)
|
||
for _, data := range srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr() {
|
||
if p.WelfData.PigBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.PigBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
BankMaxCoin = int64(data.MaxGold)
|
||
break
|
||
}
|
||
}
|
||
if p.WelfData != nil && p.WelfData.PigBank != nil {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.BankCoin = p.WelfData.PigBank.BankCoin
|
||
pack.TakeTimes = p.WelfData.PigBank.DayBuyTimes
|
||
pack.CostDiamond = int64(infoData.CostDiamond)
|
||
pack.BankMaxCoin = BankMaxCoin
|
||
pack.DayBuyMaxCnt = fGetPropValue("DayBuyMaxCnt")
|
||
pack.Price = int64(infoData.CoinPrice)
|
||
logger.Logger.Tracef("PigbankGetInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankGetInfo), pack)
|
||
}
|
||
}
|
||
|
||
// PigbankTakeCoin 存钱罐领取金币
|
||
func (this *WelfareMgr) PigbankTakeCoin(p *Player) {
|
||
pack := &welfare.SCPigbankTakeCoin{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
|
||
fGetPropValue := func(propName string) int32 {
|
||
pool := srvdata.PBDB_Pigbank_PropMgr.Datas.GetArr()
|
||
for _, PropItem := range pool {
|
||
if PropItem.PorpName == propName {
|
||
return PropItem.PropValue
|
||
}
|
||
}
|
||
return 0
|
||
}
|
||
|
||
/* fGetCostDiamond := func(taketimes int32) int64 {
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
for _, data := range pool {
|
||
if taketimes >= data.BuyCountMin && taketimes <= data.BuyCountMax {
|
||
return int64(data.CostDiamond)
|
||
}
|
||
}
|
||
return 0
|
||
}*/
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
infoData := pool[0]
|
||
for _, data := range pool {
|
||
if p.WelfData.PigBank.DayBuyTimes+1+1 >= data.BuyCountMin && p.WelfData.PigBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
|
||
BankMaxCoin := int64(0)
|
||
for _, data := range srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr() {
|
||
if p.WelfData.PigBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.PigBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
BankMaxCoin = int64(data.MaxGold)
|
||
break
|
||
}
|
||
}
|
||
|
||
DayBuyMaxCnt := fGetPropValue("DayBuyMaxCnt")
|
||
|
||
if p.WelfData != nil && p.WelfData.PigBank != nil {
|
||
|
||
pack.CostDiamond = int64(infoData.CostDiamond)
|
||
pack.BankMaxCoin = BankMaxCoin
|
||
|
||
// 检查每日领取次数
|
||
if p.WelfData.PigBank.DayBuyTimes >= DayBuyMaxCnt {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_PigbankOverTakeTimes
|
||
logger.Logger.Trace("存钱罐没有满")
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack)
|
||
return
|
||
}
|
||
|
||
// 检查存钱罐是否满
|
||
/* if p.WelfData.PigBank.BankCoin < BankMaxCoin {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_PigbankNotFull
|
||
logger.Logger.Trace("存钱罐没有满")
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack)
|
||
return
|
||
}*/
|
||
|
||
// 先扣钻石
|
||
costDiamond := int64(infoData.CostDiamond)
|
||
if p.Diamond >= costDiamond {
|
||
logger.Logger.Trace("开存钱罐消耗钻石", costDiamond)
|
||
p.AddDiamond(-costDiamond, 0, common.GainWay_PigrankTakeCoin, "system", "-开存钱罐消耗钻石")
|
||
TaskSubjectSingleton.Touch(common.TaskTypeBuyPig, &TaskData{
|
||
SnId: p.SnId,
|
||
Num: 1,
|
||
})
|
||
} else {
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_DiamondLess
|
||
logger.Logger.Trace("钻石不足")
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack)
|
||
return
|
||
}
|
||
|
||
if p.WelfData.PigBank.BankCoin >= BankMaxCoin {
|
||
p.WelfData.PigBank.BankCoin = BankMaxCoin
|
||
}
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.TakeCoinNum = p.WelfData.PigBank.BankCoin
|
||
|
||
p.AddCoin(p.WelfData.PigBank.BankCoin, 0, common.GainWay_PigrankGainCoin, "sys", "存钱罐领取金币")
|
||
|
||
// 领取完之后 设置为0
|
||
p.WelfData.PigBank.BankCoin = 0
|
||
p.WelfData.PigBank.TakeTimes++
|
||
p.WelfData.PigBank.DayBuyTimes++
|
||
|
||
pack.TakeTimes = p.WelfData.PigBank.DayBuyTimes
|
||
pack.CostDiamond = int64(infoData.CostDiamond)
|
||
pack.DayBuyMaxCnt = DayBuyMaxCnt
|
||
pack.Price = int64(infoData.CoinPrice)
|
||
logger.Logger.Tracef("PigbankTakeCoin snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCPigbankTakeCoin), pack)
|
||
|
||
}
|
||
}
|
||
|
||
// 每日重置存钱罐属性
|
||
func (this *WelfareMgr) DayResetPigrank(p *Player) {
|
||
|
||
if p != nil && p.WelfData != nil && p.WelfData.PigBank != nil {
|
||
p.WelfData.PigBank.DayBuyTimes = 0
|
||
|
||
this.PigbankGetInfo(p)
|
||
}
|
||
if p != nil && p.WelfData != nil && p.WelfData.DiamondBank != nil {
|
||
p.WelfData.DiamondBank.DayBuyTimes = 0
|
||
this.DiamondBankGetInfo(p)
|
||
}
|
||
}
|
||
|
||
// 钻石储存罐信息
|
||
func (this *WelfareMgr) DiamondBankGetInfo(p *Player) {
|
||
pack := &welfare.SCDiamondBankGetInfo{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
fGetPropValue := func(propName string) int32 {
|
||
pool := srvdata.PBDB_Pigbank_PropMgr.Datas.GetArr()
|
||
for _, PropItem := range pool {
|
||
if PropItem.PorpName == propName {
|
||
return PropItem.PropValue
|
||
}
|
||
}
|
||
return 0
|
||
}
|
||
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
infoData := pool[0]
|
||
if p.WelfData.DiamondBank == nil {
|
||
p.WelfData.DiamondBank = &model.DiamondBankData{}
|
||
}
|
||
for _, data := range pool {
|
||
if p.WelfData.DiamondBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.DiamondBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
|
||
BankMaxCoin := infoData.MaxDiamond
|
||
|
||
if p.WelfData != nil && p.WelfData.DiamondBank != nil {
|
||
bankDiamond := math.Floor(p.WelfData.DiamondBank.BankDiamond*10000) / 10000
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
pack.BankDiamond = bankDiamond
|
||
pack.TakeTimes = p.WelfData.DiamondBank.DayBuyTimes
|
||
pack.BankMaxCoin = int64(BankMaxCoin)
|
||
pack.DayBuyMaxCnt = fGetPropValue("DayBuyMaxCntDiamond")
|
||
pack.Price = int64(infoData.DiamondPrice)
|
||
pack.NowPrice = int64(infoData.DiamondNowPrice)
|
||
pack.ShopId = infoData.DiamondId
|
||
logger.Logger.Tracef("DiamondBankGetInfo snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCDiamondBankGetInfo), pack)
|
||
}
|
||
}
|
||
|
||
// DiamondBankTakeCoin 钻石存钱罐领取钻石
|
||
func (this *WelfareMgr) DiamondBankTakeCoin(p *Player) {
|
||
pack := &welfare.SCDiamondBankTakeDiamond{
|
||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||
}
|
||
fGetPropValue := func(propName string) int32 {
|
||
pool := srvdata.PBDB_Pigbank_PropMgr.Datas.GetArr()
|
||
for _, PropItem := range pool {
|
||
if PropItem.PorpName == propName {
|
||
return PropItem.PropValue
|
||
}
|
||
}
|
||
return 0
|
||
}
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
infoData := pool[0]
|
||
for _, data := range pool {
|
||
if p.WelfData.DiamondBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.DiamondBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
|
||
BankMaxDiamond := int64(infoData.MaxDiamond)
|
||
DayBuyMaxCnt := fGetPropValue("DayBuyMaxCntDiamond")
|
||
|
||
if p.WelfData != nil && p.WelfData.PigBank != nil {
|
||
if p.WelfData.DiamondBank.BankDiamond >= float64(BankMaxDiamond) {
|
||
p.WelfData.DiamondBank.BankDiamond = float64(BankMaxDiamond)
|
||
}
|
||
pack.OpRetCode = welfare.OpResultCode_OPRC_Sucess
|
||
addDiamond := int64(math.Ceil(p.WelfData.DiamondBank.BankDiamond))
|
||
p.AddDiamond(addDiamond, 0, common.GainWay_PigrankGainDiamond, "sys", "存钱罐领取钻石")
|
||
TaskSubjectSingleton.Touch(common.TaskTypeBuyPig, &TaskData{
|
||
SnId: p.SnId,
|
||
Num: 1,
|
||
})
|
||
|
||
// 领取完之后 设置为0
|
||
p.WelfData.DiamondBank.BankDiamond = 0.0
|
||
p.WelfData.DiamondBank.TakeTimes++
|
||
p.WelfData.DiamondBank.DayBuyTimes++
|
||
|
||
for _, data := range pool {
|
||
if p.WelfData.DiamondBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.DiamondBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
pack.BankMaxDiamond = int64(infoData.MaxDiamond)
|
||
pack.TakeTimes = p.WelfData.DiamondBank.DayBuyTimes
|
||
pack.DayBuyMaxCnt = DayBuyMaxCnt
|
||
pack.TakeDiamondNum = float64(addDiamond)
|
||
pack.Price = int64(infoData.DiamondPrice)
|
||
pack.NowPrice = int64(infoData.DiamondNowPrice)
|
||
pack.ShopId = infoData.DiamondId
|
||
logger.Logger.Tracef("DiamondBankTakeCoin snid: %v pack: %v", p.SnId, pack)
|
||
p.SendToClient(int(welfare.SPacketID_PACKET_SCDiamondBankTakeDiamond), pack)
|
||
}
|
||
}
|
||
|
||
// 更新钻石存储罐数据
|
||
func (this *WelfareMgr) UpdateDiamondBankData(p *Player, coinNum int64, isWin bool) {
|
||
logger.Logger.Trace("更新钻石存储罐数据!!!!!!!!!!")
|
||
if p.WelfData.DiamondBank == nil {
|
||
p.WelfData.DiamondBank = &model.DiamondBankData{}
|
||
}
|
||
fGetPropValue := func(propName string) int32 {
|
||
pool := srvdata.PBDB_Pigbank_PropMgr.Datas.GetArr()
|
||
for _, PropItem := range pool {
|
||
if PropItem.PorpName == propName {
|
||
return PropItem.PropValue
|
||
}
|
||
}
|
||
return 0
|
||
}
|
||
|
||
if p.WelfData.DiamondBank.DayBuyTimes == fGetPropValue("DayBuyMaxCntDiamond") {
|
||
return
|
||
}
|
||
WinCoinRate := fGetPropValue("WinCoinRateDiamond")
|
||
LoseCoinRate := fGetPropValue("LoseCoinRateDiamond")
|
||
addDiamond := float64(0)
|
||
if isWin {
|
||
addDiamond = float64(coinNum) * float64(WinCoinRate) / 10000000
|
||
} else {
|
||
addDiamond = float64(coinNum) * float64(LoseCoinRate) / 10000000
|
||
}
|
||
//保留小数点后4位
|
||
addDiamond = math.Round(addDiamond*10000) / 10000
|
||
p.WelfData.DiamondBank.BankDiamond += addDiamond
|
||
pool := srvdata.PBDB_PigBank_DiamondMgr.Datas.GetArr()
|
||
infoData := pool[0]
|
||
for _, data := range pool {
|
||
if p.WelfData.DiamondBank.DayBuyTimes+1 >= data.BuyCountMin && p.WelfData.DiamondBank.DayBuyTimes+1 <= data.BuyCountMax {
|
||
infoData = data
|
||
break
|
||
}
|
||
}
|
||
|
||
BankMaxDiamond := int64(infoData.MaxDiamond)
|
||
if p.WelfData.DiamondBank.BankDiamond >= float64(BankMaxDiamond) {
|
||
p.WelfData.DiamondBank.BankDiamond = float64(BankMaxDiamond)
|
||
}
|
||
logger.Logger.Tracef("玩家更新钻石存储罐数据 snid = %d,coinNum = %d,isWin = %s,当前钻石存储罐钻石数量:%f,本次增加钻石数量:%f", p.SnId, coinNum, isWin, p.WelfData.DiamondBank.BankDiamond, addDiamond)
|
||
}
|
||
|
||
func (this *WelfareMgr) Update() {
|
||
|
||
}
|
||
|
||
func (this *WelfareMgr) Shutdown() {
|
||
module.UnregisteModule(this)
|
||
}
|
||
|
||
func (this *WelfareMgr) OnDayTimer() {
|
||
for _, v := range this.GetConfigs() {
|
||
v.BlindBoxCycle = 0
|
||
v.FirstPayCycle = 0
|
||
v.ContinuousPayCycle = 0
|
||
}
|
||
}
|
||
|
||
func (this *WelfareMgr) InterestClockEvent() int {
|
||
return (1 << common.ClockEventMax) - 1
|
||
}
|
||
|
||
func init() {
|
||
module.RegisteModule(WelfareMgrSington, time.Second, 0)
|
||
common.ClockMgrSingleton.RegisterSinker(WelfareMgrSington)
|
||
}
|