修复(#79): 合并internal并适配数量配价

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-27 01:14:32 -07:00
37 changed files with 1813 additions and 431 deletions
+19 -13
View File
@@ -6,13 +6,19 @@ import (
"gorm.io/gorm"
)
const (
RuleTypeNewUser = "new_user"
RuleTypeInactiveUser = "inactive_user"
RuleTypeCampaign = "campaign"
)
type Rule struct {
Id int64 `gorm:"primaryKey"`
Name string `gorm:"type:varchar(100);not null;default:'';comment:Promo Rule Name"`
Type string `gorm:"type:varchar(32);not null;default:'';comment:Promo Rule Type"`
Name string `gorm:"type:varchar(100);not null;default:'';comment:Rule Name"`
Type string `gorm:"type:varchar(32);not null;default:'';comment:Rule Type"`
Params string `gorm:"type:json;not null;comment:Rule Params"`
Priority int64 `gorm:"type:int;not null;default:0;comment:Priority"`
Enabled *bool `gorm:"type:tinyint(1);not null;default:1;comment:Enabled"`
Enabled bool `gorm:"type:tinyint(1);not null;default:1;comment:Enabled"`
StartTime *time.Time `gorm:"default:null;comment:Start Time"`
EndTime *time.Time `gorm:"default:null;comment:End Time"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
@@ -20,34 +26,34 @@ type Rule struct {
DeletedAt gorm.DeletedAt `gorm:"index;comment:Delete Time"`
}
func (*Rule) TableName() string {
func (Rule) TableName() string {
return "promo_rule"
}
type SubscribePromo struct {
Id int64 `gorm:"primaryKey"`
SubscribeId int64 `gorm:"not null;index:idx_subscribe_qty_rule,unique;comment:Subscribe ID"`
Quantity int64 `gorm:"not null;default:0;index:idx_subscribe_qty_rule,unique;comment:Quantity"`
PromoRuleId int64 `gorm:"not null;index:idx_subscribe_qty_rule,unique;index:idx_promo_rule_id;comment:Promo Rule ID"`
SubscribeId int64 `gorm:"type:bigint unsigned;not null;comment:Subscribe ID"`
Quantity int64 `gorm:"type:bigint;not null;default:1;comment:Quantity"`
PromoRuleId int64 `gorm:"type:bigint unsigned;not null;comment:Promo Rule ID"`
PromoPrice int64 `gorm:"type:bigint;not null;default:0;comment:Promo Price"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"`
}
func (*SubscribePromo) TableName() string {
func (SubscribePromo) TableName() string {
return "subscribe_promo"
}
type Usage struct {
Id int64 `gorm:"primaryKey"`
UserId int64 `gorm:"not null;index:idx_user_rule;comment:User ID"`
PromoRuleId int64 `gorm:"not null;index:idx_user_rule;comment:Promo Rule ID"`
SubscribeId int64 `gorm:"not null;comment:Subscribe ID"`
OrderNo string `gorm:"type:varchar(255);not null;default:'';index:idx_order_no;comment:Order No"`
UserId int64 `gorm:"type:bigint unsigned;not null;comment:User ID"`
PromoRuleId int64 `gorm:"type:bigint unsigned;not null;comment:Promo Rule ID"`
SubscribeId int64 `gorm:"type:bigint unsigned;not null;comment:Subscribe ID"`
OrderNo string `gorm:"type:varchar(255);not null;default:'';comment:Order No"`
PromoPrice int64 `gorm:"type:bigint;not null;default:0;comment:Promo Price"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
}
func (*Usage) TableName() string {
func (Usage) TableName() string {
return "promo_usage"
}