All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat(shop): 添加商品限购功能并优化购买逻辑 - 修改购买黄金商品接口,添加商品配额检查功能 - 新增月、周、日三种限购类型检查逻辑 - 当商品超出库存或达到购买限制时返回相应错误码 - 移除gold_log表中PlayerID字段的唯一索引约束 - 修复GoldService中的Cheak方法实现,支持多种时间维度限购检查 ```
50 lines
1.9 KiB
Go
50 lines
1.9 KiB
Go
package model
|
||
|
||
import (
|
||
"blazing/cool"
|
||
)
|
||
|
||
// 表名常量定义:金豆消费记录表
|
||
const (
|
||
TableNameGoldBeanConsume = "player_gold_log" // 金豆消费记录表(记录用户金豆消耗的明细、类型、关联业务等信息)
|
||
)
|
||
|
||
// 通过金豆消费时间来确认金豆物品的购买重置周期
|
||
// GoldBeanConsume 金豆消费核心模型(与数据库表字段一一对应,存储消费明细)
|
||
type GoldBeanConsume struct {
|
||
*cool.Model
|
||
|
||
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"`
|
||
///消费年份
|
||
Year uint32 `gorm:"not null;default:0;comment:'消费年份'" json:"year" description:"消费年份"`
|
||
//消费时间,由月-周-日组成,判断金豆物品的购买重置周期
|
||
Consume []uint32 `gorm:"type:jsonb; comment:'消费时间'" json:"consume" description:"消费时间"`
|
||
}
|
||
|
||
// -------------------------- 核心配套方法 --------------------------
|
||
|
||
// TableName 指定GoldBeanConsume对应的数据库表名(遵循项目规范)
|
||
func (*GoldBeanConsume) TableName() string {
|
||
return TableNameGoldBeanConsume
|
||
}
|
||
|
||
// GroupName 指定表所属分组(与其他精灵/玩家相关表保持一致)
|
||
func (*GoldBeanConsume) GroupName() string {
|
||
return "default"
|
||
}
|
||
|
||
// NewGoldBeanConsume 创建金豆消费记录实例(初始化通用Model及默认值)
|
||
func NewGoldBeanConsume() *GoldBeanConsume {
|
||
return &GoldBeanConsume{
|
||
Model: cool.NewModel(),
|
||
}
|
||
}
|
||
|
||
// -------------------------- 表结构自动同步 --------------------------
|
||
func init() {
|
||
// 程序启动时自动创建/同步金豆消费记录表
|
||
cool.CreateTable(&GoldBeanConsume{})
|
||
}
|