- 京东handler不直接依赖api.JdAPI

This commit is contained in:
gazebo
2019-08-28 14:25:29 +08:00
parent da6fdd4c8e
commit cf4202a41b
13 changed files with 113 additions and 112 deletions

View File

@@ -10,7 +10,6 @@ import (
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/putils"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
@@ -39,9 +38,9 @@ func (p *PurchaseHandler) getStoreSkusBareInfoLimitSize(ctx *jxcontext.Context,
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)
stockInfo, err = getAPI("").QueryOpenUseable(batchSkuInfoList)
} else {
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList)
priceInfo, err = getAPI("").GetStationInfoList(vendorStoreID, batchSkuList)
}
return nil, err
}, []int{0, 1})
@@ -119,7 +118,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
})
}
if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
}
@@ -130,7 +129,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if len(storeSkuList) == 1 {
if globals.EnableJdStoreWrite {
_, err = api.JdAPI.UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
_, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
}
} else {
var skuPriceInfoList []*jdapi.SkuPriceInfo
@@ -141,7 +140,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
})
}
if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
}
@@ -153,7 +152,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if len(storeSkuList) == 1 {
if globals.EnableJdStoreWrite {
err = api.JdAPI.UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
}
} else {
var skuStockList []*jdapi.SkuStock
@@ -164,7 +163,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
})
}
if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
}
@@ -189,7 +188,7 @@ func (p *PurchaseHandler) SyncStoreProducts(ctx *jxcontext.Context, parentTask t
storeSku := batchItemList[0].(*dao.StoreSkuSyncInfo)
if storeSku.VendorSkuID != "" && storeSku.StoreSkuStatus == model.SkuStatusNormal {
if globals.EnableJdStoreWrite {
synchronized, err2 := api.JdAPI.SyncProduct(storeDetail.VendorStoreID, storeSku.VendorSkuID)
synchronized, err2 := getAPI("").SyncProduct(storeDetail.VendorStoreID, storeSku.VendorSkuID)
if err = err2; err == nil && synchronized {
retVal = []int{1}
}