feat(shop): 添加商品限购功能并优化购买逻辑 - 修改购买黄金商品接口,添加商品配额检查功能 - 新增月、周、日三种限购类型检查逻辑 - 当商品超出库存或达到购买限制时返回相应错误码 - 移除gold_log表中PlayerID字段的唯一索引约束 - 修复GoldService中的Cheak方法实现,支持多种时间维度限购检查 ```
This commit is contained in:
@@ -14,7 +14,7 @@ const (
|
||||
type GoldBeanConsume struct {
|
||||
*cool.Model
|
||||
|
||||
PlayerID uint64 `gorm:"not null;uniqueIndex;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
ConsumeNum uint32 `gorm:"not null;default:0;comment:'消费数量'" json:"consume_num" description:"消费数量"`
|
||||
BizID uint32 `gorm:"not null;default:0;comment:'关联业务ID(如道具ID/扭蛋池ID,无则填0)'" json:"biz_id" description:"关联业务ID"`
|
||||
///消费年份
|
||||
|
||||
@@ -10,13 +10,29 @@ type GoldService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func (s *GoldService) Cheak(pid, count uint32) {
|
||||
// 月 周 日限购检查
|
||||
func (s *GoldService) Cheak(pid, ptye uint32) int {
|
||||
|
||||
now := time.Now()
|
||||
var va int
|
||||
switch ptye {
|
||||
case 0: //月限购
|
||||
va = int(now.Month())
|
||||
case 1: //周限购
|
||||
_, va = now.ISOWeek()
|
||||
case 2: //日限购
|
||||
va = now.Day()
|
||||
|
||||
}
|
||||
ret, _ := s.dbm_fix(s.Model).Where("year", now.Year()).Where("biz_id", pid).Wheref("consume ->> ?::integer = ?", ptye, va).Count()
|
||||
|
||||
return ret
|
||||
|
||||
}
|
||||
func (s *GoldService) Log(pid, count uint32) {
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
return
|
||||
}
|
||||
// if cool.Config.ServerInfo.IsVip != 0 {
|
||||
// return
|
||||
// }
|
||||
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
|
||||
Reference in New Issue
Block a user