- 限制门店价格最大值为1000元

This commit is contained in:
gazebo
2019-05-31 10:53:28 +08:00
parent 3e39423369
commit 0114f078dd

View File

@@ -25,6 +25,8 @@ import (
)
const (
MaxSkuUnitPrice = 100000
CopyStoreSkuModeFresh = "fresh"
CopyStoreSkuModeUpdate = "update"
// CopyStoreSkuModeAdd = "add"
@@ -71,6 +73,7 @@ type StoreSkuBindInfo struct {
type tStoreSkuBindAndSpec struct {
model.StoreSkuBind
Name string
SpecQuality float32
SpecUnit string
SkuNamePrice int
@@ -580,7 +583,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBind
SELECT
t2.*,
t1.id real_sku_id, t1.spec_quality, t1.spec_unit,
t3.price sku_name_price, t3.unit sku_name_unit
t3.price sku_name_price, t3.unit sku_name_unit, t3.name
FROM sku t1
JOIN store ts ON ts.id = ? AND ts.deleted_at = ?
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ?
@@ -604,6 +607,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBind
}
unitPrice := 0
if skuBindInfo.UnitPrice != 0 {
if skuBindInfo.UnitPrice > MaxSkuUnitPrice {
dao.Rollback(db)
return nil, fmt.Errorf("商品:%s价格:%s太夸张", allBinds[0].Name, jxutils.IntPrice2StandardCurrencyString(int64(skuBindInfo.UnitPrice)))
}
unitPrice = skuBindInfo.UnitPrice
} else {
unitPrice = allBinds[0].UnitPrice