同步库存再次修改
This commit is contained in:
@@ -1116,45 +1116,45 @@ 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) {
|
||||
for _, storeSku := range storeSkus {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
// task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1).SetBatchSize(20), 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))
|
||||
// for _, storeSku := range storeSkus {
|
||||
// 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 && storeSku.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)
|
||||
// }
|
||||
// }
|
||||
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 && storeSku.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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user