- ebai.store_sku2小修改
This commit is contained in:
@@ -16,9 +16,15 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||||
minBatchSize = 5 // 使用batch相关的API最少的处理数量,因为饿百批处理API的调用频率限制得更低
|
switch funcID {
|
||||||
)
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
||||||
|
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
||||||
|
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) {
|
||||||
@@ -79,12 +85,6 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, vendorStoreID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用
|
|
||||||
|
|
||||||
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) {
|
||||||
storeSku := storeSkuList[0]
|
storeSku := storeSkuList[0]
|
||||||
@@ -115,24 +115,16 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
if len(invalidSkus) > minBatchSize {
|
if len(invalidSkus) > 1 {
|
||||||
err = api.EbaiAPI.SkuOffline(utils.Int2Str(storeID), strings.Join(invalidSkus, ","))
|
err = api.EbaiAPI.SkuOffline(utils.Int2Str(storeID), strings.Join(invalidSkus, ","))
|
||||||
} else if len(invalidSkus) > 0 {
|
} else if len(invalidSkus) == 1 {
|
||||||
for _, v := range invalidSkus {
|
err = api.EbaiAPI.SkuOfflineOne(utils.Int2Str(storeID), utils.Str2Int64(invalidSkus[0]), "", "")
|
||||||
if err = api.EbaiAPI.SkuOfflineOne(utils.Int2Str(storeID), utils.Str2Int64(v), "", ""); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if len(validSkus) > minBatchSize {
|
if len(validSkus) > 1 {
|
||||||
err = api.EbaiAPI.SkuOnline(utils.Int2Str(storeID), strings.Join(validSkus, ","))
|
err = api.EbaiAPI.SkuOnline(utils.Int2Str(storeID), strings.Join(validSkus, ","))
|
||||||
} else if len(validSkus) > 0 {
|
} else if len(validSkus) == 1 {
|
||||||
for _, v := range invalidSkus {
|
err = api.EbaiAPI.SkuOnlineOne(utils.Int2Str(storeID), utils.Str2Int64(validSkus[0]), "", "")
|
||||||
if err = api.EbaiAPI.SkuOnlineOne(utils.Int2Str(storeID), utils.Str2Int64(v), "", ""); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,14 +137,10 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
skuPriceList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Price)
|
skuPriceList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Price)
|
||||||
}
|
}
|
||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
if len(skuPriceList) > minBatchSize {
|
if len(skuPriceList) > 1 {
|
||||||
err = api.EbaiAPI.SkuPriceUpdateBatch(utils.Int2Str(storeID), strings.Join(skuPriceList, ";"), "", "")
|
err = api.EbaiAPI.SkuPriceUpdateBatch(utils.Int2Str(storeID), strings.Join(skuPriceList, ";"), "", "")
|
||||||
} else {
|
} else if len(skuPriceList) == 1 {
|
||||||
for _, v := range skuPriceList {
|
err = api.EbaiAPI.SkuPriceUpdateOne(utils.Int2Str(storeID), skuPriceList[0], "", "")
|
||||||
if err = api.EbaiAPI.SkuPriceUpdateOne(utils.Int2Str(storeID), v, "", ""); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user