- up
This commit is contained in:
@@ -146,6 +146,21 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
return err
|
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{}) {
|
func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[string]interface{}) {
|
||||||
params = map[string]interface{}{
|
params = map[string]interface{}{
|
||||||
"name": storeSku.Name,
|
"name": storeSku.Name,
|
||||||
|
|||||||
@@ -77,20 +77,6 @@ func jxStoreSkuStatus2Jd(jxStoreSkuStatus int) (isSale bool) {
|
|||||||
return jxStoreSkuStatus == model.SkuStatusNormal
|
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) {
|
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||||
var skuVendibilityList []*jdapi.StockVendibility
|
var skuVendibilityList []*jdapi.StockVendibility
|
||||||
for _, v := range storeSkuList {
|
for _, v := range storeSkuList {
|
||||||
@@ -118,3 +104,17 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
}
|
}
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"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) {
|
func (p *PurchaseHandler) ReadStoreCategory(ctx *jxcontext.Context, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) {
|
||||||
remoteCats, err := api.MtwmAPI.RetailCatList(vendorStoreID)
|
remoteCats, err := api.MtwmAPI.RetailCatList(vendorStoreID)
|
||||||
@@ -88,12 +100,6 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, vendorStoreID
|
|||||||
return p.CreateStoreSkus(ctx, vendorStoreID, storeSkuList)
|
return p.CreateStoreSkus(ctx, vendorStoreID, storeSkuList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用
|
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) int {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// 对于多门店平台来说,storeSkuList中只有SkuID与VendorSkuID有意义
|
// 对于多门店平台来说,storeSkuList中只有SkuID与VendorSkuID有意义
|
||||||
func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
|
func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
|
||||||
foodDataList := make([]map[string]interface{}, len(storeSkuList))
|
foodDataList := make([]map[string]interface{}, len(storeSkuList))
|
||||||
@@ -204,6 +210,26 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
return err
|
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) {
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user