This commit is contained in:
邹宗楠
2023-02-15 15:26:41 +08:00
parent 02de1644f6
commit b42a823540
2 changed files with 17 additions and 19 deletions

View File

@@ -1087,23 +1087,25 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
}
if len(skuIDs) > 0 {
// 判断是否改价
nowPrice, _ := payload["price"].(json.Number).Int64()
if skuName.Price != int(nowPrice) && nowPrice != 0 {
if payload["price"] != nil {
nowPrice, _ := payload["price"].(json.Number).Int64()
if skuName.Price != int(nowPrice) && nowPrice != 0 {
for _, v1 := range payload["skus"].([]interface{}) {
v := v1.(map[string]interface{})
skuInfo := &aa{}
if err := utils.Map2StructByJson(v, skuInfo, false); err != nil {
globals.SugarLogger.Debugf("errr %v", err)
continue
for _, v1 := range payload["skus"].([]interface{}) {
v := v1.(map[string]interface{})
skuInfo := &aa{}
if err := utils.Map2StructByJson(v, skuInfo, false); err != nil {
globals.SugarLogger.Debugf("errr %v", err)
continue
}
var skuPrice int64 = 0
if payload["unit"] == "份" { // 商品规格等于份的时候,标准重量保持为500g
skuPrice = int64(float64(skuInfo.SpecQuality) / float64(500) * float64(nowPrice))
} else {
skuPrice = nowPrice
}
SetUpdateSkuPriceIfChange(db, skuPrice, nowPrice, skuInfo.Id)
}
var skuPrice int64 = 0
if payload["unit"] == "份" { // 商品规格等于份的时候,标准重量保持为500g
skuPrice = int64(float64(skuInfo.SpecQuality) / float64(500) * float64(nowPrice))
} else {
skuPrice = nowPrice
}
SetUpdateSkuPriceIfChange(db, skuPrice, nowPrice, skuInfo.Id)
}
}