From f88900e8697d477445c0e1ee34f0957e9b83da62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 3 Feb 2020 17:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=A0=E9=99=A4=E6=9C=AA=E5=85=B3=E6=B3=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 9a245b064..01acf989e 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1603,6 +1603,28 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co break } 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 + } globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2) dao.Commit(db) }