数据校验
This commit is contained in:
parent
20293241e7
commit
ac247bc78b
@ -24,8 +24,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
|
|||||||
curByCount int32
|
curByCount int32
|
||||||
costRes *cfg.Gameatn
|
costRes *cfg.Gameatn
|
||||||
mapData map[string]interface{}
|
mapData map[string]interface{}
|
||||||
curCount int32 // 当前门票数量
|
curCount int32 // 当前门票数量
|
||||||
szcostRes []*cfg.Gameatn
|
szcostRes []*cfg.Gameatn // 购买累计消耗
|
||||||
)
|
)
|
||||||
mapData = make(map[string]interface{}, 0)
|
mapData = make(map[string]interface{}, 0)
|
||||||
code = this.BuyCheck(session, req)
|
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)) // 获取当前数量
|
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
|
||||||
curCount = amount
|
curCount = amount
|
||||||
if amount != conf.VikingNum {
|
if amount < conf.VikingNum {
|
||||||
if list.RecoveryTime == 0 {
|
if list.RecoveryTime == 0 {
|
||||||
list.RecoveryTime = configure.Now().Unix()
|
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)
|
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
curCount += int32(count)
|
curCount += int32(count)
|
||||||
}
|
}
|
||||||
if curCount >= conf.VikingNum {
|
if curCount > conf.VikingNum {
|
||||||
curCount = conf.VikingNum
|
curCount = conf.VikingNum
|
||||||
list.RecoveryTime = 0
|
list.RecoveryTime = 0
|
||||||
} else {
|
} else {
|
||||||
@ -86,9 +89,9 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list.RecoveryTime = 0
|
list.RecoveryTime = 0
|
||||||
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
|
|
||||||
}
|
}
|
||||||
curByCount += req.Count // 当前需要购买的数量
|
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
|
||||||
|
curByCount += req.Count // 当前需要购买的数量
|
||||||
|
|
||||||
if this.configure.GetMaxBuyChallengeCount() < curByCount {
|
if this.configure.GetMaxBuyChallengeCount() < curByCount {
|
||||||
code = pb.ErrorCode_VikingBuyMaxCount
|
code = pb.ErrorCode_VikingBuyMaxCount
|
||||||
|
Loading…
Reference in New Issue
Block a user