- 京东到家新门店商品同步方式

This commit is contained in:
gazebo
2019-07-11 16:59:09 +08:00
parent 5758252cee
commit 980c6b9023
2 changed files with 67 additions and 8 deletions

View File

@@ -12,6 +12,14 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
switch funcID {
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
batchSize = jdapi.MaxStoreSkuBatchSize
}
return batchSize
}
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
@@ -64,3 +72,49 @@ func jdStoreSkuStatus2Jx(jdStoreSkuStatus int) (jxSkuStatus int) {
}
return jxSkuStatus
}
func jxStoreSkuStatus2Jd(jxStoreSkuStatus int) (isSale bool) {
return jxStoreSkuStatus == model.SkuStatusNormal
}
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
var skuStockList []*jdapi.SkuStock
for _, v := range storeSkuList {
skuStockList = append(skuStockList, &jdapi.SkuStock{
OutSkuId: utils.Int2Str(v.SkuID),
StockQty: v.Stock,
})
}
if globals.EnableJdStoreWrite {
_, err = api.JdAPI.BatchUpdateCurrentQtys("", vendorStoreID, skuStockList, ctx.GetUserName())
}
return err
}
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
var skuVendibilityList []*jdapi.StockVendibility
for _, v := range storeSkuList {
skuVendibilityList = append(skuVendibilityList, &jdapi.StockVendibility{
OutSkuId: utils.Int2Str(v.SkuID),
DoSale: jxStoreSkuStatus2Jd(v.Status),
})
}
if globals.EnableJdStoreWrite {
_, err = api.JdAPI.BatchUpdateVendibility("", vendorStoreID, skuVendibilityList, ctx.GetUserName())
}
return err
}
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
var skuPriceInfoList []*jdapi.SkuPriceInfo
for _, v := range storeSkuList {
skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{
OutSkuId: utils.Int2Str(v.SkuID),
Price: int(v.Price),
})
}
if globals.EnableJdStoreWrite {
_, err = api.JdAPI.UpdateVendorStationPrice("", vendorStoreID, skuPriceInfoList)
}
return err
}