This commit is contained in:
gazebo
2019-07-11 17:50:05 +08:00
parent 85f86a19fe
commit 32303dce7d
3 changed files with 61 additions and 20 deletions

View File

@@ -146,6 +146,21 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
return err
}
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
skuStockList := make([]string, len(storeSkuList))
for k, v := range storeSkuList {
skuStockList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Stock)
}
if globals.EnableEbaiStoreWrite {
if len(skuStockList) > 1 {
err = api.EbaiAPI.SkuStockUpdateBatch(utils.Int2Str(storeID), strings.Join(skuStockList, ";"), "", "")
} else if len(skuStockList) == 1 {
err = api.EbaiAPI.SkuStockUpdateOne(utils.Int2Str(storeID), skuStockList[0], "", "")
}
}
return err
}
func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[string]interface{}) {
params = map[string]interface{}{
"name": storeSku.Name,

View File

@@ -77,20 +77,6 @@ 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 {
@@ -118,3 +104,17 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
}
return err
}
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
}

View File

@@ -13,6 +13,18 @@ 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 = mtwmapi.MaxStoreSkuBatchSize
case partner.FuncDeleteStoreSkus:
batchSize = 1 // 可考虑用批量操作
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
batchSize = 1 // 可考虑用批量操作
}
return batchSize
}
// 门店分类
func (p *PurchaseHandler) ReadStoreCategory(ctx *jxcontext.Context, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) {
remoteCats, err := api.MtwmAPI.RetailCatList(vendorStoreID)
@@ -88,12 +100,6 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, vendorStoreID
return p.CreateStoreSkus(ctx, vendorStoreID, storeSkuList)
}
// 通用
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) int {
return 1
}
// 对于多门店平台来说storeSkuList中只有SkuID与VendorSkuID有意义
func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
foodDataList := make([]map[string]interface{}, len(storeSkuList))
@@ -204,6 +210,26 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
return err
}
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
var stockList []*mtwmapi.BareStoreFoodInfo
for _, storeSku := range storeSkuList {
skuInfo := &mtwmapi.BareStoreFoodInfo{
AppFoodCode: storeSku.VendorSkuID,
Skus: []*mtwmapi.BareStoreSkuInfo{
&mtwmapi.BareStoreSkuInfo{
SkuID: storeSku.VendorSkuID,
Stock: utils.Int2Str(storeSku.Stock),
},
},
}
stockList = append(stockList, skuInfo)
}
if globals.EnableMtwmStoreWrite {
err = api.MtwmAPI.RetailSkuStock(vendorStoreID, stockList)
}
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