diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 34cc94ce2..9e1c5f3ab 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1604,27 +1604,27 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co } num += num2 //上方insert会无视目标门店中未关注的商品(以前关注,后来取消关注),所以这里批量删一下 - // sql2 := ` - // DELETE FROM store_sku_bind a - // WHERE a.store_id = ? AND a.sku_id IN ( - // SELECT b.sku_id FROM ( - // SELECT store_id,sku_id,count(*) - // FROM store_sku_bind - // WHERE store_id = ? - // GROUP BY 1,2 - // HAVING count(*) > 1)b - // ) - // AND a.deleted_at <> ? - // ` - // sqlParams2 := []interface{}{ - // toStoreID, toStoreID, utils.DefaultTimeValue, - // } - // _, err = dao.ExecuteSQL(db, sql2, sqlParams2) - // if err != nil { - // errList.AddErr(err) - // dao.Rollback(db) - // break - // } + sql2 := ` + DELETE FROM store_sku_bind a + WHERE a.store_id = ? AND a.sku_id IN ( + SELECT b.sku_id FROM ( + SELECT store_id,sku_id,count(*) + FROM store_sku_bind + WHERE store_id = ? + GROUP BY 1,2 + HAVING count(*) > 1)b + ) + AND a.deleted_at <> ? + ` + sqlParams2 := []interface{}{ + toStoreID, toStoreID, utils.DefaultTimeValue, + } + _, err = dao.ExecuteSQL(db, sql2, sqlParams2) + if err != nil { + errList.AddErr(err) + dao.Rollback(db) + break + } globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2) dao.Commit(db) }