diff --git a/modules/viking/api_buy.go b/modules/viking/api_buy.go index 751748c64..1ae1f1fb0 100644 --- a/modules/viking/api_buy.go +++ b/modules/viking/api_buy.go @@ -24,8 +24,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code curByCount int32 costRes *cfg.Gameatn mapData map[string]interface{} - curCount int32 // 当前门票数量 - szcostRes []*cfg.Gameatn + curCount int32 // 当前门票数量 + szcostRes []*cfg.Gameatn // 购买累计消耗 ) mapData = make(map[string]interface{}, 0) code = this.BuyCheck(session, req) @@ -60,16 +60,19 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code } amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 curCount = amount - if amount != conf.VikingNum { + if amount < conf.VikingNum { if list.RecoveryTime == 0 { list.RecoveryTime = configure.Now().Unix() - mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间 + } + if conf.VikingExpeditionRecoveryTime == 0 { // 配置校验 被除数不能为0 + code = pb.ErrorCode_ConfigNoFound + return } count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60) if count > 1 { curCount += int32(count) } - if curCount >= conf.VikingNum { + if curCount > conf.VikingNum { curCount = conf.VikingNum list.RecoveryTime = 0 } else { @@ -86,9 +89,9 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code } } else { list.RecoveryTime = 0 - mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间 } - curByCount += req.Count // 当前需要购买的数量 + mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间 + curByCount += req.Count // 当前需要购买的数量 if this.configure.GetMaxBuyChallengeCount() < curByCount { code = pb.ErrorCode_VikingBuyMaxCount