diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 9035835dc..afa825a46 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -240,7 +240,7 @@ func UpdateStoreSkus(ctx *jxcontext.Context, storeID int, skuBindInfos []*StoreS skuIDs, err := updateStoreSkusWithoutSync(ctx, storeID, skuBindInfos, userName) if err == nil { db := dao.GetDB() - _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, userName) + _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, false) return int64(len(skuIDs)), err } return 0, err @@ -389,7 +389,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St } } db := dao.GetDB() - _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, userName) + _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, false) return num, err } @@ -445,7 +445,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo skuIDs = append(skuIDs, v.SkuID) } db := dao.GetDB() - _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, userName) + _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, false) return num, err } diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index b7990958d..9b420095f 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -295,7 +295,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v } // -func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isAsync bool, userName string) (hint string, err error) { +func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("SyncStoresSkus") return v.LoopStoresMap(ctx, db, "SyncStoresSkus", isAsync, vendorIDs, storeIDs, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) @@ -303,14 +303,14 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo if len(loopMapInfo.StoreMapList) > 1 { loopStoreTask := tasksch.NewSeqTask("SyncStoresSkus loop stores", ctx.GetUserName(), func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { storeID := loopMapInfo.StoreMapList[step].StoreID - _, err = handler.SyncStoreSkus(ctx, task, storeID, skuIDs, false) + _, err = handler.SyncStoreSkus(ctx, task, storeID, skuIDs, false, isContinueWhenError) return nil, err }, len(loopMapInfo.StoreMapList)) t.AddChild(loopStoreTask).Run() _, err = loopStoreTask.GetResult(0) return nil, err } - _, err = handler.SyncStoreSkus(ctx, t, loopMapInfo.StoreMapList[0].StoreID, skuIDs, false) + _, err = handler.SyncStoreSkus(ctx, t, loopMapInfo.StoreMapList[0].StoreID, skuIDs, false, isContinueWhenError) } return nil, err }) diff --git a/business/partner/partner.go b/business/partner/partner.go index eff59323e..77c59a3cd 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -85,7 +85,7 @@ type IPurchasePlatformHandler interface { // OpenStore(vendorStoreID string, userName string) error // CloseStore(vendorStoreID, closeNotice, userName string) error - SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync bool) (hint string, err error) + SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) GetVendorID() int diff --git a/business/partner/purchase/ebai/store_sku.go b/business/partner/purchase/ebai/store_sku.go index 3a3454fc8..3239aae83 100644 --- a/business/partner/purchase/ebai/store_sku.go +++ b/business/partner/purchase/ebai/store_sku.go @@ -74,9 +74,9 @@ var ( } ) -func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync bool) (hint string, err error) { +func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { userName := ctx.GetUserName() - globals.SugarLogger.Debugf("SyncStoreSkus storeID:%d, skuIDs:%v, userName:%s", storeID, skuIDs, userName) + globals.SugarLogger.Debugf("SyncStoreSkus storeID:%d, skuIDs:%v, isContinueWhenError:%t, userName:%s", storeID, skuIDs, isContinueWhenError, userName) db := dao.GetDB() if err = p.SyncLocalStoreCategory(db, storeID, userName); err != nil { @@ -138,7 +138,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks return "", err } if err = dao.GetRows(db, &storeSkuInfoList, sql, sqlParams...); err == nil { - task := tasksch.NewParallelTask("SyncStoreSkus skus", nil, userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + task := tasksch.NewParallelTask("SyncStoreSkus skus", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeSku := batchItemList[0].(*tStoreSkuFullInfo) updateFields := []string{model.FieldEbaiSyncStatus} isCreate := false diff --git a/business/partner/purchase/ebai/store_sku_test.go b/business/partner/purchase/ebai/store_sku_test.go index f7b80b4cc..8ab1cb6c7 100644 --- a/business/partner/purchase/ebai/store_sku_test.go +++ b/business/partner/purchase/ebai/store_sku_test.go @@ -13,7 +13,7 @@ func TestSyncStoresSkus(t *testing.T) { for i := 0; i < 100; i++ { skus[i] = i + 1 } - _, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false) + _, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false, false) if err != nil { t.Fatal(err.Error()) } diff --git a/business/partner/purchase/elm/store_sku.go b/business/partner/purchase/elm/store_sku.go index d54263c30..8e19e9c42 100644 --- a/business/partner/purchase/elm/store_sku.go +++ b/business/partner/purchase/elm/store_sku.go @@ -17,7 +17,7 @@ func (p *PurchaseHandler) ReadStoreSku(storeID, skuID int) (skuNameExt *model.Sk return nil, nil } -func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync bool) (hint string, err error) { +func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { return hint, err } diff --git a/business/partner/purchase/jd/store_sku.go b/business/partner/purchase/jd/store_sku.go index f8ec06a6a..66507b78f 100644 --- a/business/partner/purchase/jd/store_sku.go +++ b/business/partner/purchase/jd/store_sku.go @@ -18,7 +18,7 @@ type tStoreSkuBindExt struct { } // 京东到家,以有库存表示关注(认领) -func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync bool) (hint string, err error) { +func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debugf("jd SyncStoresSkus, storeID:%d, skuIDs:%v", storeID, skuIDs) sqlWhere := ` WHERE (t1.jd_sync_status <> 0) AND t1.store_id = ? @@ -47,7 +47,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks return "", err } outStationNo := utils.Int2Str(storeID) - task := tasksch.NewParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(jdapi.MaxStoreSkuBatchSize), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { + task := tasksch.NewParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(jdapi.MaxStoreSkuBatchSize).SetIsContinueWhenError(isContinueWhenError), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { var skuPriceInfoList []*jdapi.SkuPriceInfo var skuVendibilityList []*jdapi.StockVendibility var skuStockList []*jdapi.SkuStock diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index d8292d42b..a972fe8e7 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -81,6 +81,7 @@ func (c *StoreSkuController) UpdateStoreSkus() { // @Param vendorIDs formData string true "厂商ID列表" // @Param isAsync formData bool true "是否异步操作" // @Param skuIDs formData string false "SKU ID列表,缺省为全部" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SyncStoresSkus [put] @@ -101,7 +102,7 @@ func (c *StoreSkuController) SyncStoresSkus() { return retVal, "", err } } - retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.Ctx.GetUserName()) + retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError) return retVal, "", err }) } diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index 81494761b..526f4a4c9 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -18,7 +18,7 @@ type SyncController struct { // @Param vendorIDs formData string true "厂商ID列表" // @Param isAsync formData bool true "是否异步操作" // @Param skuIDs formData string false "SKU ID列表,缺省为全部" -// @Param isContinueWhenErr formData bool false "单个同步失败是否继续,缺省false" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SyncStoresSkus [put] @@ -39,7 +39,7 @@ func (c *SyncController) SyncStoresSkus() { return retVal, "", err } } - retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.Ctx.GetUserName()) + retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError) return retVal, "", err }) } @@ -50,7 +50,7 @@ func (c *SyncController) SyncStoresSkus() { // @Param storeIDs formData string true "门店ID列表" // @Param vendorIDs formData string true "厂商ID列表" // @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenErr formData bool false "单个同步失败是否继续,缺省false" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SyncStoresCategory [put]