- GetVendorStoreSkusInfo处理skuID与平台绑定不正常的情况

This commit is contained in:
gazebo
2019-05-30 18:24:22 +08:00
parent cfadf9b787
commit fb47383f42
6 changed files with 66 additions and 49 deletions

View File

@@ -6,47 +6,52 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
batchSkuInfoList := make([]*jdapi.BaseStockCenterRequest, len(inStoreSkuList))
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
for k, v := range inStoreSkuList {
batchSkuInfoList[k] = &jdapi.BaseStockCenterRequest{
StationNo: vendorStoreID,
SkuId: utils.Str2Int64(v.VendorSkuID),
for _, v := range inStoreSkuList {
if !dao.IsVendorThingIDEmpty(v.VendorSkuID) {
batchSkuInfoList = append(batchSkuInfoList, &jdapi.BaseStockCenterRequest{
StationNo: vendorStoreID,
SkuId: utils.Str2Int64(v.VendorSkuID),
})
}
}
var stockInfo []*jdapi.QueryStockResponse
var priceInfo []*jdapi.StorePriceInfo
task := tasksch.NewParallelTask("获取京东到家平台门店商品信息", tasksch.NewParallelConfig().SetParallelCount(2), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
subTaskID := batchItemList[0].(int)
if subTaskID == 0 {
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList)
} else {
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList)
globals.SugarLogger.Debug(utils.Format4Output(priceInfo, false))
if len(batchSkuInfoList) > 0 {
var stockInfo []*jdapi.QueryStockResponse
var priceInfo []*jdapi.StorePriceInfo
task := tasksch.NewParallelTask("获取京东到家平台门店商品信息", tasksch.NewParallelConfig().SetParallelCount(2), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
subTaskID := batchItemList[0].(int)
if subTaskID == 0 {
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList)
} else {
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList)
globals.SugarLogger.Debug(utils.Format4Output(priceInfo, false))
}
return nil, err
}, []int{0, 1})
tasksch.HandleTask(task, parentTask, false).Run()
_, err = task.GetResult(0)
if err == nil {
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
for _, v := range inStoreSkuList {
storeSkuMap[utils.Str2Int64(v.VendorSkuID)] = v
}
for _, v := range stockInfo {
outStoreSkuList = append(outStoreSkuList, storeSkuMap[v.SkuID])
storeSkuMap[v.SkuID].Status = jdStoreSkuStatus2Jx(v.Vendibility)
}
for _, v := range priceInfo {
storeSkuMap[v.SkuID].Price = v.Price
}
return nil, err
}, []int{0, 1})
tasksch.HandleTask(task, parentTask, false).Run()
_, err = task.GetResult(0)
if err == nil {
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
for _, v := range inStoreSkuList {
storeSkuMap[utils.Str2Int64(v.VendorSkuID)] = v
}
for _, v := range stockInfo {
storeSkuMap[v.SkuID].Status = jdStoreSkuStatus2Jx(v.Vendibility)
}
for _, v := range priceInfo {
storeSkuMap[v.SkuID].Price = v.Price
}
outStoreSkuList = inStoreSkuList
}
return outStoreSkuList, err
}