diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 92f98289c..7f19a6c7b 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -219,9 +219,16 @@ func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo } func isStoreSkuSyncNeedDelete(storeSku *dao.StoreSkuSyncInfo) bool { - return model.IsSyncStatusDelete(storeSku.SkuSyncStatus) || + if model.IsSyncStatusDelete(storeSku.SkuSyncStatus) || storeSku.BindDeletedAt != utils.DefaultTimeValue || storeSku.BindID == 0 || - storeSku.NameID == 0 || storeSku.NameStatus != model.SkuStatusNormal || storeSku.Status != model.SkuStatusNormal + storeSku.NameID == 0 || storeSku.NameStatus != model.SkuStatusNormal { + return true + } + if storeSku.Status != model.SkuStatusNormal { + storeSku.IsDeletedBySku = true + return true + } + return false } func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSkuInfo) { @@ -238,6 +245,7 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk JxUnitPrice: inSku.UnitPrice, VendorSkuID2: utils.Int64ToStr(inSku.JdsWareID), JdsStockSwitch: inSku.JdsStockSwitch, + IsDeletedBySku: inSku.IsDeletedBySku, } if !isStoreSkuSyncNeedDelete(inSku) { outSku.Stock = model.MaxStoreSkuStockQty diff --git a/business/partner/partner_store_sku.go b/business/partner/partner_store_sku.go index 46b73bdab..004d026b2 100644 --- a/business/partner/partner_store_sku.go +++ b/business/partner/partner_store_sku.go @@ -53,6 +53,7 @@ type StoreSkuInfo struct { JxUnitPrice int64 `json:"jxUnitPrice,omitempty"` VendorSkuID2 string `json:"vendorSkuID2,omitempty"` JdsStockSwitch int `json:"jdsStockSwitch"` + IsDeletedBySku bool `json:"isDeletedBySku"` } type StoreSkuInfoWithErr struct { diff --git a/business/partner/purchase/jdshop/store_sku.go b/business/partner/purchase/jdshop/store_sku.go index fbfa20e7c..6ef86768a 100644 --- a/business/partner/purchase/jdshop/store_sku.go +++ b/business/partner/purchase/jdshop/store_sku.go @@ -200,14 +200,16 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID { for _, v := range storeSkuList { - // err = api.JdShopAPI.DeleteSku(utils.Str2Int64(v.VendorSkuID)) - err = api.JdShopAPI.UpOrDown(utils.Str2Int64(v.VendorSkuID2), 2) - if err == nil { - err = api.JdShopAPI.DeleteWare(utils.Str2Int(v.VendorSkuID2)) + if v.IsDeletedBySku { + err = api.JdShopAPI.DeleteSku(utils.Str2Int64(v.VendorSkuID)) + } else { + err = api.JdShopAPI.UpOrDown(utils.Str2Int64(v.VendorSkuID2), 2) + if err == nil { + err = api.JdShopAPI.DeleteWare(utils.Str2Int(v.VendorSkuID2)) + } } if err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "删除商品")...) - } } }