```
feat(item_buy): 优化商品购买限额检查逻辑 - 修改购买黄金商品时的限额验证方式,直接检查单次购买数量是否超过限制 - 调整GoldLog.Cheak方法参数顺序,增加总量控制参数 - 更新错误返回条件,提高限额检查准确性 fix(player_service): 添加时间范围检查功能 - 引入utils工具包用于时间范围验证 - 在IsMatch方法中添加活动开始时间和结束时间的范围检查 - 如果当前时间不在活动时间内则返回匹配失败 refactor(gold_log):
This commit is contained in:
@@ -97,8 +97,12 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, player *player.
|
||||
if pro == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrTooManyProducts
|
||||
}
|
||||
|
||||
if pro.QuotaType != 0 {
|
||||
if player.Service.GoldLog.Cheak(data.ProductID, pro.QuotaType-1)+int(data.Count) > int(pro.QuotaLimit) {
|
||||
if data.Count > int64(pro.QuotaLimit) {
|
||||
return nil, errorcode.ErrorCodes.ErrExceedStock
|
||||
}
|
||||
if player.Service.GoldLog.Cheak(pro.QuotaLimit-uint32(data.Count), data.ProductID, pro.QuotaType-1) {
|
||||
return nil, errorcode.ErrorCodes.ErrExceedStock
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package player
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/modules/config/model"
|
||||
"blazing/modules/config/service"
|
||||
"sync/atomic"
|
||||
@@ -19,6 +20,12 @@ func (p *Player) IsMatch(t model.Event) bool {
|
||||
return false
|
||||
|
||||
}
|
||||
if t.StartTime != "" && t.EndTime != "" {
|
||||
ok, _ := utils.IsCurrentTimeInRange(t.StartTime, t.EndTime)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
@@ -78,7 +85,6 @@ func (p *Player) GenMonster() {
|
||||
}
|
||||
p.Data[i].HandleNPCFightSpecial(v.IsCapture)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ type GoldService struct {
|
||||
}
|
||||
|
||||
// 月 周 日限购检查
|
||||
func (s *GoldService) Cheak(pid, ptye uint32) int {
|
||||
func (s *GoldService) Cheak(allcount, pid, ptye uint32) bool {
|
||||
|
||||
now := time.Now()
|
||||
var va int
|
||||
@@ -24,9 +24,15 @@ func (s *GoldService) Cheak(pid, ptye uint32) int {
|
||||
va = now.Day()
|
||||
|
||||
}
|
||||
ret, _ := s.dbm_fix(s.Model).Where("year", now.Year()).Where("biz_id", pid).Wheref("consume ->> ?::integer = ?", ptye, va).Count()
|
||||
ret, err := s.dbm_fix(s.Model).Where("year", now.Year()).Where("biz_id", pid).Wheref("consume ->> ?::integer = ?", ptye, va).Count()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if uint32(ret) < allcount {
|
||||
return true
|
||||
}
|
||||
|
||||
return ret
|
||||
return false
|
||||
|
||||
}
|
||||
func (s *GoldService) Log(pid, count uint32) {
|
||||
|
||||
Reference in New Issue
Block a user