+ GetStoresSkus添加平台同步参数条件
+ GetStoreAbnoramlSkuCount + GetVendorStoreSkusInfo
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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"
|
||||
@@ -191,7 +192,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
Skus: []*mtwmapi.BareStoreSkuInfo{
|
||||
&mtwmapi.BareStoreSkuInfo{
|
||||
SkuID: storeSku.VendorSkuID,
|
||||
Price: utils.Int2Str(storeSku.Price),
|
||||
Price: utils.Int64ToStr(storeSku.Price),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -202,3 +203,50 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
vendorSkuIDList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDList()
|
||||
var vendorFoodList []*mtwmapi.AppFood
|
||||
if len(inStoreSkuList) > 1 {
|
||||
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorSkuID := batchItemList[0].(string)
|
||||
skuInfo, err := api.MtwmAPI.RetailGet(vendorStoreID, vendorSkuID)
|
||||
if err == nil {
|
||||
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
||||
return vendorFoodList, nil
|
||||
}
|
||||
return nil, err
|
||||
}, vendorSkuIDList)
|
||||
tasksch.HandleTask(task, parentTask, false).Run()
|
||||
_, err = task.GetResult(0)
|
||||
} else {
|
||||
skuInfo, err2 := api.MtwmAPI.RetailGet(vendorStoreID, inStoreSkuList[0].VendorSkuID)
|
||||
if err = err2; err == nil {
|
||||
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[string]*partner.BareStoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[v.VendorSkuID] = v
|
||||
}
|
||||
for _, foodInfo := range vendorFoodList {
|
||||
vendorSku := foodInfo.SkuList[0]
|
||||
storeSku := storeSkuMap[vendorSku.SkuID]
|
||||
storeSku.Price = jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0))
|
||||
storeSku.Status = mtwmSkuStatus2Jx(foodInfo.IsSoldOut)
|
||||
}
|
||||
outStoreSkuList = inStoreSkuList
|
||||
}
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
||||
if mtwmSkuStatus == 0 {
|
||||
jxSkuStatus = model.SkuStatusNormal
|
||||
} else {
|
||||
jxSkuStatus = model.SkuStatusDontSale
|
||||
}
|
||||
return jxSkuStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user