- add param isContinueWhenError for SyncStoresSkus.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user