- fixed bug in updateStoreSkusWithoutSync

This commit is contained in:
gazebo
2018-10-25 08:42:49 +08:00
parent f525d659f8
commit 62ea34eb70
4 changed files with 15 additions and 6 deletions

View File

@@ -25,6 +25,9 @@ type tStoreSkuBindExt struct {
// 京东到家,以有库存表示关注(认领)
func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, storeIDs []int, skuIDs []int, isAsync bool) (hint string, err error) {
globals.SugarLogger.Debugf("jd SyncStoresSkus, storeIDs:%v, skuIDs:%v", storeIDs, skuIDs)
if len(skuIDs) == 0 {
return "", nil
}
parallelCount := 1
if len(skuIDs) < MaxSkuBatchSize {
@@ -57,7 +60,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
}
if err = dao.GetRows(db, &storeSkus, sql, append(sqlParams, sqlWhereParams...)...); err == nil {
outStationNo := utils.Int2Str(storeID)
task := tasksch.RunParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(MaxSkuBatchSize), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
task := tasksch.NewParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(MaxSkuBatchSize), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
var skuPriceInfoList []*jdapi.SkuPriceInfo
var skuVendibilityList []*jdapi.StockVendibility
var skuStockList []*jdapi.SkuStock
@@ -95,6 +98,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
}
if globals.EnableStoreWrite {
// todo 以下可以优化为并行操作
// globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
if len(skuVendibilityList) > 0 {
_, err = api.JdAPI.BatchUpdateVendibility(outStationNo, "", skuVendibilityList, ctx.GetUserName())
}
@@ -107,6 +111,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
}
return nil, err
}, storeSkus)
t.AddChild(task).Run()
if _, err = task.GetResult(0); err == nil {
sql := `
UPDATE store_sku_bind t1