尝试
This commit is contained in:
@@ -1116,25 +1116,7 @@ func (v *VendorSync) SyncJdsStoresSkus(ctx *jxcontext.Context, storeIDs []int, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.ITask, storeSkus []*model.StoreSkuBind, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (err error) {
|
func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.ITask, storeSkus []*model.StoreSkuBind, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (err error) {
|
||||||
for _, storeSku := range storeSkus {
|
// for _, storeSku := range storeSkus {
|
||||||
stock := 0
|
|
||||||
if storeSku.Status == model.StoreSkuBindStatusNormal {
|
|
||||||
stock = 9999
|
|
||||||
}
|
|
||||||
storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
|
||||||
if storeSku.JdsID != 0 {
|
|
||||||
if len(storeSku2) > 0 {
|
|
||||||
if storeSku.Status != storeSku2[0].Status && storeMap.VendorStoreID != "" {
|
|
||||||
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
|
||||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
||||||
// storeSku := batchItemList[0].(*model.StoreSkuBind)
|
|
||||||
// stock := 0
|
// stock := 0
|
||||||
// storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
// storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
||||||
// if storeSku.JdsID != 0 {
|
// if storeSku.JdsID != 0 {
|
||||||
@@ -1149,12 +1131,30 @@ func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch
|
|||||||
// err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
// err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// return retVal, err
|
|
||||||
// }, storeSkus)
|
|
||||||
// tasksch.HandleTask(task, parentTask, true).Run()
|
|
||||||
// if !isAsync {
|
|
||||||
// _, err = task.GetResult(0)
|
|
||||||
// }
|
// }
|
||||||
|
task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
storeSku := batchItemList[0].(*model.StoreSkuBind)
|
||||||
|
stock := 0
|
||||||
|
storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
||||||
|
if storeSku.JdsID != 0 {
|
||||||
|
if len(storeSku2) > 0 {
|
||||||
|
if storeSku2[0].Status == model.StoreSkuBindStatusNormal {
|
||||||
|
stock = 9999
|
||||||
|
}
|
||||||
|
if storeMap.VendorStoreID != "" {
|
||||||
|
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeSkus)
|
||||||
|
tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
|
if !isAsync {
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user