- SyncJdStoreProducts
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
@@ -1593,3 +1594,21 @@ func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuI
|
||||
}
|
||||
return skuVendorMap, err
|
||||
}
|
||||
|
||||
func SyncJdStoreProducts(ctx *jxcontext.Context, storeIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
||||
hint, err = CurVendorSync.LoopStoresMap(ctx, db, fmt.Sprintf("京东商家商品状态同步:%v", storeIDs), isAsync, isManageIt, []int{model.VendorIDJD}, storeIDs,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
if handler := partner.GetPurchasePlatformFromVendorID(loopMapInfo.VendorID); handler != nil {
|
||||
jdHandler := handler.(*jd.PurchaseHandler)
|
||||
hint, err2 := jdHandler.SyncStoreProducts(ctx, t, loopMapInfo.StoreMapList[0].StoreID, skuIDs, false, isContinueWhenError)
|
||||
if err = err2; err == nil {
|
||||
retVal = []interface{}{hint}
|
||||
}
|
||||
}
|
||||
return retVal, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||
}, isContinueWhenError)
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -538,8 +538,13 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskN
|
||||
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
||||
tasksch.HandleTask(task, nil, isManageIt).Run()
|
||||
if !isAsync {
|
||||
if _, err = task.GetResult(0); err == nil {
|
||||
hint = "1" // todo 暂时这样
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err == nil {
|
||||
if len(resultList) == 0 {
|
||||
hint = "1" // todo 暂时这样
|
||||
} else {
|
||||
hint = jxutils.TaskResult2Hint(resultList)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
|
||||
Reference in New Issue
Block a user