From 904acbf3de94bc99803cff6e45b8be49e02b7708 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 24 Dec 2019 11:11:13 +0800 Subject: [PATCH] =?UTF-8?q?updateStoresSkusWithoutSync=E4=B8=AD=20?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=95=86=E5=93=81=E6=97=B6=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9C=89=E5=88=A0=E9=99=A4=E7=9A=84=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=88=A0=E9=99=A4=EF=BC=88=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E6=96=B0=E5=BB=BA=EF=BC=89=20=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E5=9C=A8=E5=88=A0=E9=99=A4=E6=9F=90?= =?UTF-8?q?=E4=B8=AA=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E5=8F=88=E6=8A=8A=E5=95=86=E5=93=81=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E3=80=82=20=E6=89=80=E4=BB=A5=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E7=90=86=E6=88=90=E6=81=A2=E5=A4=8D=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=9A=84=E8=AE=B0=E5=BD=95=EF=BC=8C=E8=BF=99=E6=A0=B7?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 21 +++++++++++++++++---- business/model/dao/store_sku_test.go | 5 +++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index dd3ac73b5..3e69bd1dc 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1021,11 +1021,24 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask) dao.WrapAddIDCULDEntity(skuBind, userName) globals.SugarLogger.Debug(utils.Format4Output(skuBind, false)) - if err = dao.CreateEntity(db, skuBind); err != nil { - dao.Rollback(db) - return nil, err + if deletedSku := dao.GetDeletedStoreSkuBind(db, skuBind.StoreID, skuBind.SkuID); deletedSku == nil { + if err = dao.CreateEntity(db, skuBind); err != nil { + dao.Rollback(db) + return nil, err + } + num = 1 + } else { + // 需要处理,在删除某个门店商品,同步失败的情况下,又把商品重新关注。 + // 所以统一处理成恢复删除的记录,这样避免问题 + skuBind.ID = deletedSku.ID + // vendorSkuID的赋值意义不大 + skuBind.MtwmID = deletedSku.MtwmID + skuBind.EbaiID = deletedSku.EbaiID + if num, err = dao.UpdateEntity(db, skuBind); err != nil { + dao.Rollback(db) + return nil, err + } } - num = 1 } } else { skuBind = &v.StoreSkuBind diff --git a/business/model/dao/store_sku_test.go b/business/model/dao/store_sku_test.go index cf9e569d8..9ef743329 100644 --- a/business/model/dao/store_sku_test.go +++ b/business/model/dao/store_sku_test.go @@ -23,3 +23,8 @@ func TestGetStoreSkus(t *testing.T) { } globals.SugarLogger.Debug(utils.Format4Output(skuList, false)) } + +func TestGetDeletedStoreSkuBind(t *testing.T) { + storeSkuBind := GetDeletedStoreSkuBind(GetDB(), 100123, 30648) + globals.SugarLogger.Debug(utils.Format4Output(storeSkuBind, false)) +}