数据校验

This commit is contained in:
meixiongfeng 2022-11-28 19:56:09 +08:00
parent 20293241e7
commit ac247bc78b

View File

@ -25,7 +25,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
costRes *cfg.Gameatn
mapData map[string]interface{}
curCount int32 // 当前门票数量
szcostRes []*cfg.Gameatn
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,8 +89,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
}
} else {
list.RecoveryTime = 0
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
}
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
curByCount += req.Count // 当前需要购买的数量
if this.configure.GetMaxBuyChallengeCount() < curByCount {