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

@@ -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