diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index abcacf4d8..260a09bf0 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -1039,6 +1039,7 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return 0, err } } + if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil { if places, ok := payload["places"].([]interface{}); ok { if _, err = dao.DeleteSkuNamePlace(db, nameID, nil); err != nil { @@ -1084,6 +1085,38 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return 0, err } if len(skuIDs) > 0 { + // 判断是否改价 + if skuName.Price != payload["price"].(int) { + i := payload["skus"].([]struct { + Id int `json:"id"` + SpecQuality int `json:"specQuality"` + SpecUnit string `json:"specUnit"` + Weight int `json:"weight"` + Status string `json:"status"` + Comment string `json:"comment"` + MinOrderCount int `json:"minOrderCount"` + LadderBoxNum int `json:"ladderBoxNum"` + LadderBoxPrice int `json:"ladderBoxPrice"` + EclpID string `json:"eclpID"` + CategoryID []interface{} `json:"categoryID"` + ExdSkuID string `json:"exdSkuID"` + }) + for _, v := range i { + skuPrice := 0 + if payload["unit"] == "份" { // 商品规格等于份的时候,标准重量保持为500g + skuPrice = (v.SpecQuality / 500) * payload["price"].(int) + } else { + skuPrice = payload["price"].(int) + } + + sql := ` UPDATE store_sku_bind s SET s.price = ? WHERE s.sku_id = ? AND s.deleted_at = ?` + param := []interface{}{skuPrice, v.Id, utils.DefaultTimeValue} + _, err := dao.ExecuteSQL(db, sql, param...) + globals.SugarLogger.Debugf("=================err %v", err) + } + } + + // 更新skuIds对应在store_sku_bind中的价格体系,解决老版本改价之前关注的商品,在价格修改后,store_sku_bind中京西价未修改的问题 if _, err = SetStoreSkuSyncStatus2(db, nil, partner.GetSingleStoreVendorIDs(), skuIDs, model.SyncFlagModifiedMask); err != nil { dao.Rollback(db, txDB) return 0, err