This commit is contained in:
邹宗楠
2023-02-13 18:35:03 +08:00
parent bcbe6e0d69
commit 91e67ba158

View File

@@ -1093,20 +1093,17 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
for _, v1 := range payload["skus"].([]interface{}) {
v := v1.(map[string]interface{})
skuInfo := &aa{}
err := utils.Map2StructByJson(v, skuInfo, false)
globals.SugarLogger.Debugf("errr %v", err)
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
}
sql := ` UPDATE store_sku_bind s SET s.price = ?,s.unit_price = ? WHERE s.sku_id = ? AND s.deleted_at = ?`
param := []interface{}{skuPrice, nowPrice, skuInfo.Id, utils.DefaultTimeValue}
globals.SugarLogger.Debugf("=================param %s", utils.Format4Output(param, false))
_, err = dao.ExecuteSQL(db, sql, param...)
globals.SugarLogger.Debugf("=================err %v", err)
SetUpdateSkuPriceIfChange(db, skuPrice, nowPrice, skuInfo.Id)
}
}
@@ -1235,6 +1232,13 @@ func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeIDs []int, vendorIDs, skuIDs []i
return num, nil
}
func SetUpdateSkuPriceIfChange(db *dao.DaoDB, skuPrice, nowPrice int64, skuId int) error {
sql := ` UPDATE store_sku_bind s SET s.price = ?,s.unit_price = ? WHERE s.sku_id = ? AND s.deleted_at = ?`
param := []interface{}{skuPrice, nowPrice, skuId, utils.DefaultTimeValue}
_, err := dao.ExecuteSQL(db, sql, param...)
return err
}
func UpdateSkuImg(ctx *jxcontext.Context, skuID int, payload map[string]interface{}) (string, error) {
var (
db = dao.GetDB()