修复(#79): 修复促销管理审查问题

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-27 06:09:22 -07:00
parent 9de7a69756
commit c18a6788c4
9 changed files with 217 additions and 25 deletions
+13 -2
View File
@@ -81,7 +81,15 @@ func (m *defaultPromoModel) FindRule(ctx context.Context, id int64) (*Rule, erro
}
func (m *defaultPromoModel) UpdateRule(ctx context.Context, data *Rule) error {
return m.db.WithContext(ctx).Save(data).Error
return m.db.WithContext(ctx).Model(&Rule{}).Where("id = ?", data.Id).Updates(map[string]interface{}{
"name": data.Name,
"type": data.Type,
"params": data.Params,
"priority": data.Priority,
"enabled": data.Enabled,
"start_time": data.StartTime,
"end_time": data.EndTime,
}).Error
}
func (m *defaultPromoModel) DeleteRule(ctx context.Context, id int64) error {
@@ -129,7 +137,10 @@ func (m *defaultPromoModel) UpsertPrices(ctx context.Context, ruleId int64, item
return err
}
if errors.Is(err, gorm.ErrRecordNotFound) {
return tx.Create(item).Error
if err := tx.Create(item).Error; err != nil {
return err
}
continue
}
existing.Quantity = item.Quantity
existing.PromoPrice = item.PromoPrice
+1 -1
View File
@@ -33,7 +33,7 @@ func (Rule) TableName() string {
type SubscribePromo struct {
Id int64 `gorm:"primaryKey"`
SubscribeId int64 `gorm:"type:bigint unsigned;not null;comment:Subscribe ID"`
Quantity int64 `gorm:"type:bigint;not null;default:1;comment:Quantity"`
Quantity int64 `gorm:"type:int;not null;default:0;comment:购买数量"`
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"`