- 重构partner_store_sku
This commit is contained in:
@@ -20,8 +20,12 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||
switch funcID {
|
||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
||||
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
||||
case partner.FuncGetStoreSkusBareInfo:
|
||||
batchSize = 1
|
||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||
batchSize = 1
|
||||
case partner.FuncGetStoreSkusFullInfo:
|
||||
batchSize = 1
|
||||
}
|
||||
return batchSize
|
||||
}
|
||||
@@ -98,14 +102,14 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.SkuDelete(utils.Int2Str(storeID), strings.Join(partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDList(), ","))
|
||||
}
|
||||
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.StoreSkuInfo) (err error) {
|
||||
var validSkus, invalidSkus []string
|
||||
for _, storeSku := range storeSkuList {
|
||||
if storeSku.Status == model.SkuStatusNormal {
|
||||
@@ -131,7 +135,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
skuPriceList := make([]string, len(storeSkuList))
|
||||
for k, v := range storeSkuList {
|
||||
skuPriceList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Price)
|
||||
@@ -146,7 +150,7 @@ 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) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
skuStockList := make([]string, len(storeSkuList))
|
||||
for k, v := range storeSkuList {
|
||||
skuStockList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Stock)
|
||||
@@ -195,7 +199,7 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[s
|
||||
return params
|
||||
}
|
||||
|
||||
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) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||
vendorSkuIDIntList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||
var vendorSkuList []*ebaiapi.SkuInfo
|
||||
if len(vendorSkuIDIntList) > 1 {
|
||||
@@ -224,7 +228,7 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
||||
return nil, nil
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
|
||||
storeSkuMap := make(map[int64]*partner.StoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[utils.Str2Int64(v.VendorSkuID)] = v
|
||||
}
|
||||
@@ -252,10 +256,14 @@ func ebaiSkuStatus2Jx(ebaiSkuStatus int) (jxSkuStatus int) {
|
||||
return jxSkuStatus
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreAllSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
||||
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, skuIDs []int) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
params := &ebaiapi.SkuListParams{
|
||||
PageSize: MaxPageSize,
|
||||
})
|
||||
}
|
||||
if len(skuIDs) == 1 {
|
||||
params.CustomSkuID = utils.Int2Str(skuIDs[0])
|
||||
}
|
||||
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), params)
|
||||
if err == nil {
|
||||
skuNameList = append(skuNameList, vendorSkuList2Jx(page1.List)...)
|
||||
if page1.Pages > 1 {
|
||||
@@ -275,7 +283,7 @@ func (p *PurchaseHandler) GetStoreAllSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
return nil, err2
|
||||
}, pages)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
tasksch.HandleTask(task, parentTask, true).Run()
|
||||
result, err2 := task.GetResult(0)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range result {
|
||||
@@ -297,9 +305,9 @@ func vendorSku2Jx(vendorSku *ebaiapi.SkuInfo) (skuName *partner.SkuNameInfo) {
|
||||
Prefix: prefix,
|
||||
Name: name,
|
||||
Unit: unit,
|
||||
SkuList: []*partner.FullSkuInfo{
|
||||
&partner.FullSkuInfo{
|
||||
BareStoreSkuInfo: partner.BareStoreSkuInfo{
|
||||
SkuList: []*partner.SkuInfo{
|
||||
&partner.SkuInfo{
|
||||
StoreSkuInfo: partner.StoreSkuInfo{
|
||||
VendorSkuID: utils.Int64ToStr(vendorSku.SkuID),
|
||||
SkuID: int(utils.Str2Int64WithDefault(vendorSku.CustomSkuID, 0)),
|
||||
|
||||
@@ -318,7 +326,7 @@ func vendorSku2Jx(vendorSku *ebaiapi.SkuInfo) (skuName *partner.SkuNameInfo) {
|
||||
for _, v := range vendorSku.Photos {
|
||||
skuName.PictureList = append(skuName.PictureList, v.URL)
|
||||
}
|
||||
// todo, 看起来饿百只返回了最底层的商家分类信息
|
||||
// todo, 看起来饿百只返回了最低一级的商家分类信息
|
||||
for _, v := range vendorSku.CustomCatList {
|
||||
skuName.VendorCatIDList = append(skuName.VendorCatIDList, v.CustomCatID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user