diff --git a/logic/controller/item_buy.go b/logic/controller/item_buy.go index ca5c98d4..18822a32 100644 --- a/logic/controller/item_buy.go +++ b/logic/controller/item_buy.go @@ -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 } } diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index a112be1f..5903ebfc 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -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) - } } diff --git a/modules/player/service/gold_log.go b/modules/player/service/gold_log.go index e7b1acad..66ec8b44 100644 --- a/modules/player/service/gold_log.go +++ b/modules/player/service/gold_log.go @@ -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) {