- GetVendorStoreSkusInfo处理skuID与平台绑定不正常的情况
This commit is contained in:
@@ -1508,7 +1508,7 @@ func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuI
|
|||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
var locker sync.RWMutex
|
var locker sync.RWMutex
|
||||||
skuVendorMap = make(map[int][]*partner.BareStoreSkuInfo)
|
skuVendorMap = make(map[int][]*partner.BareStoreSkuInfo)
|
||||||
_, err = CurVendorSync.LoopStoresMap(ctx, db, fmt.Sprintf("GetVendorStoreSkusInfo:%d", storeID), false, false, vendorIDs, []int{storeID},
|
_, err = CurVendorSync.LoopStoresMap(ctx, db, fmt.Sprintf("GetVendorStoreSkusInfo storeID:%d", storeID), false, false, vendorIDs, []int{storeID},
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||||
if handler := CurVendorSync.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
if handler := CurVendorSync.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||||
@@ -1521,10 +1521,11 @@ func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuI
|
|||||||
VendorSkuID: v.VendorSkuID,
|
VendorSkuID: v.VendorSkuID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err = handler.GetStoreSkusInfo(ctx, t, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, bareStoreSkuInfoList); err == nil {
|
outBareStoreSkuInfoList, err2 := handler.GetStoreSkusInfo(ctx, t, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, bareStoreSkuInfoList)
|
||||||
|
if err = err2; err == nil && outBareStoreSkuInfoList != nil {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
skuVendorMap[loopMapInfo.VendorID] = bareStoreSkuInfoList
|
skuVendorMap[loopMapInfo.VendorID] = outBareStoreSkuInfoList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,25 +27,28 @@ type BareStoreSkuInfo struct {
|
|||||||
type BareStoreSkuInfoList []*BareStoreSkuInfo
|
type BareStoreSkuInfoList []*BareStoreSkuInfo
|
||||||
|
|
||||||
func (l BareStoreSkuInfoList) GetVendorSkuIDList() (vendorSkuIDList []string) {
|
func (l BareStoreSkuInfoList) GetVendorSkuIDList() (vendorSkuIDList []string) {
|
||||||
vendorSkuIDList = make([]string, len(l))
|
for _, v := range l {
|
||||||
for k, v := range l {
|
if !dao.IsVendorThingIDEmpty(v.VendorSkuID) {
|
||||||
vendorSkuIDList[k] = v.VendorSkuID
|
vendorSkuIDList = append(vendorSkuIDList, v.VendorSkuID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return vendorSkuIDList
|
return vendorSkuIDList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l BareStoreSkuInfoList) GetVendorSkuIDIntList() (vendorSkuIDIntList []int64) {
|
func (l BareStoreSkuInfoList) GetVendorSkuIDIntList() (vendorSkuIDIntList []int64) {
|
||||||
vendorSkuIDIntList = make([]int64, len(l))
|
for _, v := range l {
|
||||||
for k, v := range l {
|
if !dao.IsVendorThingIDEmpty(v.VendorSkuID) {
|
||||||
vendorSkuIDIntList[k] = utils.Str2Int64(v.VendorSkuID)
|
vendorSkuIDIntList = append(vendorSkuIDIntList, utils.Str2Int64(v.VendorSkuID))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return vendorSkuIDIntList
|
return vendorSkuIDIntList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l BareStoreSkuInfoList) GetSkuIDList() (skuIDList []int) {
|
func (l BareStoreSkuInfoList) GetSkuIDList() (skuIDList []int) {
|
||||||
skuIDList = make([]int, len(l))
|
|
||||||
for k, v := range l {
|
for k, v := range l {
|
||||||
skuIDList[k] = v.SkuID
|
if v.SkuID > 0 {
|
||||||
|
skuIDList[k] = v.SkuID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return skuIDList
|
return skuIDList
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[s
|
|||||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||||
vendorSkuIDIntList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
vendorSkuIDIntList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||||
var vendorSkuList []*ebaiapi.SkuInfo
|
var vendorSkuList []*ebaiapi.SkuInfo
|
||||||
if len(inStoreSkuList) > 1 {
|
if len(vendorSkuIDIntList) > 1 {
|
||||||
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
vendorSkuID := batchItemList[0].(int64)
|
vendorSkuID := batchItemList[0].(int64)
|
||||||
@@ -210,13 +210,15 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
|||||||
}, vendorSkuIDIntList)
|
}, vendorSkuIDIntList)
|
||||||
tasksch.HandleTask(task, parentTask, false).Run()
|
tasksch.HandleTask(task, parentTask, false).Run()
|
||||||
_, err = task.GetResult(0)
|
_, err = task.GetResult(0)
|
||||||
} else {
|
} else if len(vendorSkuIDIntList) == 1 {
|
||||||
skuInfo, err2 := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
skuInfo, err2 := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
||||||
SkuID: utils.Str2Int64(inStoreSkuList[0].VendorSkuID),
|
SkuID: vendorSkuIDIntList[0],
|
||||||
})
|
})
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
vendorSkuList = skuInfo.List
|
vendorSkuList = skuInfo.List
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
|
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
|
||||||
@@ -225,10 +227,11 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
|||||||
}
|
}
|
||||||
for _, skuInfo := range vendorSkuList {
|
for _, skuInfo := range vendorSkuList {
|
||||||
storeSku := storeSkuMap[skuInfo.SkuID]
|
storeSku := storeSkuMap[skuInfo.SkuID]
|
||||||
|
globals.SugarLogger.Debug(utils.Format4Output(storeSku, false))
|
||||||
|
outStoreSkuList = append(outStoreSkuList, storeSku)
|
||||||
storeSku.Price = skuInfo.SalePrice
|
storeSku.Price = skuInfo.SalePrice
|
||||||
storeSku.Status = ebaiSkuStatus2Jx(skuInfo.Status)
|
storeSku.Status = ebaiSkuStatus2Jx(skuInfo.Status)
|
||||||
}
|
}
|
||||||
outStoreSkuList = inStoreSkuList
|
|
||||||
}
|
}
|
||||||
return outStoreSkuList, err
|
return outStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,47 +6,52 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"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/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"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/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"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) {
|
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()
|
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||||
for k, v := range inStoreSkuList {
|
for _, v := range inStoreSkuList {
|
||||||
batchSkuInfoList[k] = &jdapi.BaseStockCenterRequest{
|
if !dao.IsVendorThingIDEmpty(v.VendorSkuID) {
|
||||||
StationNo: vendorStoreID,
|
batchSkuInfoList = append(batchSkuInfoList, &jdapi.BaseStockCenterRequest{
|
||||||
SkuId: utils.Str2Int64(v.VendorSkuID),
|
StationNo: vendorStoreID,
|
||||||
|
SkuId: utils.Str2Int64(v.VendorSkuID),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var stockInfo []*jdapi.QueryStockResponse
|
if len(batchSkuInfoList) > 0 {
|
||||||
var priceInfo []*jdapi.StorePriceInfo
|
var stockInfo []*jdapi.QueryStockResponse
|
||||||
task := tasksch.NewParallelTask("获取京东到家平台门店商品信息", tasksch.NewParallelConfig().SetParallelCount(2), ctx,
|
var priceInfo []*jdapi.StorePriceInfo
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
task := tasksch.NewParallelTask("获取京东到家平台门店商品信息", tasksch.NewParallelConfig().SetParallelCount(2), ctx,
|
||||||
subTaskID := batchItemList[0].(int)
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
if subTaskID == 0 {
|
subTaskID := batchItemList[0].(int)
|
||||||
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList)
|
if subTaskID == 0 {
|
||||||
} else {
|
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList)
|
||||||
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList)
|
} else {
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(priceInfo, false))
|
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
|
return outStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
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()
|
vendorSkuIDList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDList()
|
||||||
var vendorFoodList []*mtwmapi.AppFood
|
var vendorFoodList []*mtwmapi.AppFood
|
||||||
if len(inStoreSkuList) > 1 {
|
if len(vendorSkuIDList) > 1 {
|
||||||
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
vendorSkuID := batchItemList[0].(string)
|
vendorSkuID := batchItemList[0].(string)
|
||||||
@@ -220,11 +220,13 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
|||||||
}, vendorSkuIDList)
|
}, vendorSkuIDList)
|
||||||
tasksch.HandleTask(task, parentTask, false).Run()
|
tasksch.HandleTask(task, parentTask, false).Run()
|
||||||
_, err = task.GetResult(0)
|
_, err = task.GetResult(0)
|
||||||
} else {
|
} else if len(vendorSkuIDList) == 1 {
|
||||||
skuInfo, err2 := api.MtwmAPI.RetailGet(vendorStoreID, inStoreSkuList[0].VendorSkuID)
|
skuInfo, err2 := api.MtwmAPI.RetailGet(vendorStoreID, vendorSkuIDList[0])
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
storeSkuMap := make(map[string]*partner.BareStoreSkuInfo)
|
storeSkuMap := make(map[string]*partner.BareStoreSkuInfo)
|
||||||
@@ -234,10 +236,10 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
|||||||
for _, foodInfo := range vendorFoodList {
|
for _, foodInfo := range vendorFoodList {
|
||||||
vendorSku := foodInfo.SkuList[0]
|
vendorSku := foodInfo.SkuList[0]
|
||||||
storeSku := storeSkuMap[vendorSku.SkuID]
|
storeSku := storeSkuMap[vendorSku.SkuID]
|
||||||
|
outStoreSkuList = append(outStoreSkuList, storeSku)
|
||||||
storeSku.Price = jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0))
|
storeSku.Price = jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0))
|
||||||
storeSku.Status = mtwmSkuStatus2Jx(foodInfo.IsSoldOut)
|
storeSku.Status = mtwmSkuStatus2Jx(foodInfo.IsSoldOut)
|
||||||
}
|
}
|
||||||
outStoreSkuList = inStoreSkuList
|
|
||||||
}
|
}
|
||||||
return outStoreSkuList, err
|
return outStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ func (c *StoreSkuController) GetStoreSkus() {
|
|||||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||||
// @Param isBySku query bool false "是否按SKU分拆"
|
// @Param isBySku query bool false "是否按SKU分拆"
|
||||||
|
// @Param jdSyncStatus query int false "京东同步标识"
|
||||||
|
// @Param ebaiSyncStatus query int false "饿百同步标识"
|
||||||
|
// @Param mtwmSyncStatus query int false "美团外卖同步标识"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetStoresSkus [get]
|
// @router /GetStoresSkus [get]
|
||||||
|
|||||||
Reference in New Issue
Block a user