新增最小购买数量控制 & 购买前检查实名

This commit is contained in:
2026-04-20 11:20:44 +08:00
parent a964fe4d69
commit 982cbb4cab
6 changed files with 29 additions and 1 deletions

View File

@@ -47,6 +47,11 @@ func (s *productSkuService) Create(create CreateProductSkuData) (err error) {
return core.NewBizErr("产品最低价格的格式不正确", err)
}
countMin := int32(1)
if create.CountMin != nil {
countMin = *create.CountMin
}
return q.ProductSku.Create(&m.ProductSku{
ProductID: create.ProductID,
DiscountId: create.DiscountID,
@@ -54,6 +59,8 @@ func (s *productSkuService) Create(create CreateProductSkuData) (err error) {
Name: create.Name,
Price: price,
PriceMin: priceMin,
Sort: create.Sort,
CountMin: countMin,
})
}
@@ -64,6 +71,8 @@ type CreateProductSkuData struct {
Name string `json:"name"`
Price string `json:"price"`
PriceMin string `json:"price_min"`
Sort int32 `json:"sort"`
CountMin *int32 `json:"count_min"`
}
func (s *productSkuService) Update(update UpdateProductSkuData) (err error) {
@@ -95,6 +104,12 @@ func (s *productSkuService) Update(update UpdateProductSkuData) (err error) {
if update.Status != nil {
do = append(do, q.ProductSku.Status.Value(*update.Status))
}
if update.Sort != nil {
do = append(do, q.ProductSku.Sort.Value(*update.Sort))
}
if update.CountMin != nil {
do = append(do, q.ProductSku.CountMin.Value(*update.CountMin))
}
_, err = q.ProductSku.Where(q.ProductSku.ID.Eq(update.ID)).UpdateSimple(do...)
return err
@@ -108,6 +123,8 @@ type UpdateProductSkuData struct {
Price *string `json:"price"`
PriceMin string `json:"price_min"`
Status *int32 `json:"status"`
Sort *int32 `json:"sort"`
CountMin *int32 `json:"count_min"`
}
func (s *productSkuService) Delete(id int32) (err error) {