- up
This commit is contained in:
@@ -48,9 +48,9 @@ func PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, ven
|
|||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
if len(sku2Delete) > 0 {
|
if len(sku2Delete) > 0 {
|
||||||
err = putils.FreeBatchStoreSkuInfo(func(batchedStoreSkuList []*partner.StoreSkuInfo) (err error) {
|
_, err = putils.FreeBatchStoreSkuInfo(func(batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, err error) {
|
||||||
err = handler.DeleteStoreSkus(ctx, storeID, vendorStoreID, sku2Delete)
|
err = handler.DeleteStoreSkus(ctx, storeID, vendorStoreID, sku2Delete)
|
||||||
return err
|
return nil, err
|
||||||
}, ctx, parentTask, sku2Delete, handler.GetStoreSkusBatchSize(partner.FuncDeleteStoreSkus))
|
}, ctx, parentTask, sku2Delete, handler.GetStoreSkusBatchSize(partner.FuncDeleteStoreSkus))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package partner
|
package partner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
@@ -20,6 +22,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
UnlimitedBatchSize = math.MaxInt32
|
||||||
|
|
||||||
MaxStoreSkuStock = 9999
|
MaxStoreSkuStock = 9999
|
||||||
UnlimitedStoreSkuStock = -1
|
UnlimitedStoreSkuStock = -1
|
||||||
)
|
)
|
||||||
@@ -109,13 +113,14 @@ type IPurchasePlatformStoreSkuHandler interface {
|
|||||||
type ISingleStoreStoreSkuHandler interface {
|
type ISingleStoreStoreSkuHandler interface {
|
||||||
IPurchasePlatformStoreSkuHandler
|
IPurchasePlatformStoreSkuHandler
|
||||||
|
|
||||||
GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, skuIDs []int) (outSkuNameList []*SkuNameInfo, err error)
|
GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (outSkuNameList []*SkuNameInfo, err error)
|
||||||
CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
||||||
UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
||||||
DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error)
|
DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error)
|
||||||
DeleteStoreAllSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, isContinueWhenError bool) (err error)
|
DeleteStoreAllSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, isContinueWhenError bool) (err error)
|
||||||
|
|
||||||
GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*BareCategoryInfo, err error)
|
GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*BareCategoryInfo, err error)
|
||||||
|
GetStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, catName string) (cat *BareCategoryInfo, err error)
|
||||||
CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
||||||
UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
||||||
DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string) (err error)
|
DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string) (err error)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
|||||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
||||||
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
||||||
case partner.FuncGetStoreSkusBareInfo:
|
case partner.FuncGetStoreSkusBareInfo:
|
||||||
batchSize = 1
|
batchSize = partner.UnlimitedBatchSize
|
||||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||||
batchSize = 1
|
batchSize = 1
|
||||||
case partner.FuncGetStoreSkusFullInfo:
|
case partner.FuncGetStoreSkusFullInfo:
|
||||||
@@ -210,12 +210,17 @@ func ebaiSkuStatus2Jx(ebaiSkuStatus int) (jxSkuStatus int) {
|
|||||||
return jxSkuStatus
|
return jxSkuStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, skuIDs []int) (skuNameList []*partner.SkuNameInfo, err error) {
|
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||||
params := &ebaiapi.SkuListParams{
|
params := &ebaiapi.SkuListParams{
|
||||||
PageSize: MaxPageSize,
|
PageSize: MaxPageSize,
|
||||||
}
|
}
|
||||||
if len(skuIDs) == 1 {
|
if len(storeSkuList) == 1 {
|
||||||
params.CustomSkuID = utils.Int2Str(skuIDs[0])
|
if storeSkuList[0].SkuID > 0 {
|
||||||
|
params.CustomSkuID = utils.Int2Str(storeSkuList[0].SkuID)
|
||||||
|
}
|
||||||
|
if storeSkuList[0].VendorSkuID != "" {
|
||||||
|
params.SkuID = utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), params)
|
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -3,12 +3,18 @@ package ebai
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetStoreSkusFullInfo(t *testing.T) {
|
func TestGetStoreSkusFullInfo(t *testing.T) {
|
||||||
skuNameList, err := CurPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, []int{4256})
|
skuNameList, err := CurPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, []*partner.StoreSkuInfo{
|
||||||
|
&partner.StoreSkuInfo{
|
||||||
|
SkuID: 4256,
|
||||||
|
},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
|||||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
||||||
batchSize = mtwmapi.MaxStoreSkuBatchSize
|
batchSize = mtwmapi.MaxStoreSkuBatchSize
|
||||||
case partner.FuncGetStoreSkusBareInfo:
|
case partner.FuncGetStoreSkusBareInfo:
|
||||||
batchSize = 1
|
batchSize = partner.UnlimitedBatchSize
|
||||||
case partner.FuncDeleteStoreSkus:
|
case partner.FuncDeleteStoreSkus:
|
||||||
batchSize = 1 // 可考虑用批量操作
|
batchSize = 1 // 可考虑用批量操作
|
||||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||||
@@ -246,8 +246,14 @@ func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
|||||||
return jxSkuStatus
|
return jxSkuStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, skuIDs []int) (skuNameList []*partner.SkuNameInfo, err error) {
|
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||||
if len(skuIDs) == 0 {
|
if len(storeSkuList) == 1 {
|
||||||
|
skuInfo, err := api.MtwmAPI.RetailGet(vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
skuNameList = append(skuNameList, vendorSku2Jx(skuInfo))
|
||||||
|
} else {
|
||||||
for {
|
for {
|
||||||
result, err := api.MtwmAPI.RetailList(vendorStoreID, len(skuNameList), mtwmapi.GeneralMaxLimit)
|
result, err := api.MtwmAPI.RetailList(vendorStoreID, len(skuNameList), mtwmapi.GeneralMaxLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -258,12 +264,6 @@ func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTas
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
skuInfo, err := api.MtwmAPI.RetailGet(vendorStoreID, utils.Int2Str(skuIDs[0]))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
skuNameList = append(skuNameList, vendorSku2Jx(skuInfo))
|
|
||||||
}
|
}
|
||||||
return skuNameList, err
|
return skuNameList, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetStoreSkusFullInfo(t *testing.T) {
|
func TestGetStoreSkusFullInfo(t *testing.T) {
|
||||||
skuNameList, err := new(PurchaseHandler).GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, 2, "2523687", nil)
|
skuNameList, err := curPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, 2, "2523687", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -18,7 +19,14 @@ func TestGetStoreSkusFullInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetStoreSkusBareInfo(t *testing.T) {
|
func TestGetStoreSkusBareInfo(t *testing.T) {
|
||||||
storeSkuList, err := curPurchaseHandler.GetStoreSkusBareInfo(jxcontext.AdminCtx, nil, 2, "2523687", nil)
|
storeSkuList, err := curPurchaseHandler.GetStoreSkusBareInfo(jxcontext.AdminCtx, nil, 2, "2523687", []*partner.StoreSkuInfo{
|
||||||
|
&partner.StoreSkuInfo{
|
||||||
|
SkuID: 969,
|
||||||
|
},
|
||||||
|
&partner.StoreSkuInfo{
|
||||||
|
SkuID: 1306,
|
||||||
|
},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -39,3 +47,18 @@ func TestDeleteStoreAllCategories(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetStoreCategory(t *testing.T) {
|
||||||
|
_, err := curPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", "不存在的分类")
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("应该找不到这个分类")
|
||||||
|
}
|
||||||
|
catName := "小月饼"
|
||||||
|
cat, err := curPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", catName)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if cat.Name != catName {
|
||||||
|
t.Fatal("没有找到正确的商家分类")
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(cat, false))
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
@@ -20,22 +19,17 @@ func (p *DefSingleStorePlatform) DeleteStoreAllSkus(ctx *jxcontext.Context, pare
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
batchSize := p.GetStoreSkusBatchSize(partner.FuncDeleteStoreSkus)
|
storeStoreList := make([]*partner.StoreSkuInfo, len(skuNameList))
|
||||||
task := tasksch.NewParallelTask(fmt.Sprintf("DeleteStoreAllSkus, vendorStoreID:%s", vendorStoreID),
|
for k, v := range skuNameList {
|
||||||
tasksch.NewParallelConfig().SetBatchSize(batchSize).SetIsContinueWhenError(isContinueWhenError), ctx,
|
storeStoreList[k] = &partner.StoreSkuInfo{
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
SkuID: v.SkuList[0].SkuID,
|
||||||
var skuList []*partner.StoreSkuInfo
|
VendorSkuID: v.SkuList[0].VendorSkuID,
|
||||||
for _, v := range batchItemList {
|
}
|
||||||
skuName := v.(*partner.SkuNameInfo)
|
}
|
||||||
skuList = append(skuList, &partner.StoreSkuInfo{
|
_, err = FreeBatchStoreSkuInfo(func(batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, err error) {
|
||||||
VendorSkuID: skuName.SkuList[0].VendorSkuID,
|
err = p.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList)
|
||||||
})
|
return nil, err
|
||||||
}
|
}, ctx, parentTask, storeStoreList, p.GetStoreSkusBatchSize(partner.FuncDeleteStoreSkus))
|
||||||
err = p.DeleteStoreSkus(ctx, storeID, vendorStoreID, skuList)
|
|
||||||
return nil, err
|
|
||||||
}, skuNameList)
|
|
||||||
tasksch.HandleTask(task, parentTask, true).Run()
|
|
||||||
_, err = task.GetResult(0)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +50,13 @@ func (p *DefSingleStorePlatform) DeleteStoreAllCategories(ctx *jxcontext.Context
|
|||||||
sort.Sort(sort.Reverse(sort.IntSlice(levelList)))
|
sort.Sort(sort.Reverse(sort.IntSlice(levelList)))
|
||||||
task1 := tasksch.NewSeqTask(fmt.Sprintf("DeleteStoreAllCategories1, vendorStoreID:%s", vendorStoreID), ctx,
|
task1 := tasksch.NewSeqTask(fmt.Sprintf("DeleteStoreAllCategories1, vendorStoreID:%s", vendorStoreID), ctx,
|
||||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
task2 := tasksch.NewParallelTask(fmt.Sprintf("DeleteStoreAllCategories2, vendorStoreID:%s", vendorStoreID), tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
vendorCatIDs := make([]string, len(catListMap[levelList[step]]))
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
for k, v := range catListMap[levelList[step]] {
|
||||||
catInfo := batchItemList[0].(*partner.BareCategoryInfo)
|
vendorCatIDs[k] = v.VendorCatID
|
||||||
err = p.DeleteStoreCategory(ctx, storeID, vendorStoreID, catInfo.VendorCatID)
|
}
|
||||||
return nil, err
|
err = FreeBatchCategoryIDOp(func(vendorCatID string) (err error) {
|
||||||
}, catListMap[levelList[step]])
|
return p.DeleteStoreCategory(ctx, storeID, vendorStoreID, vendorCatID)
|
||||||
tasksch.HandleTask(task2, task, true).Run()
|
}, ctx, task, vendorCatIDs)
|
||||||
_, err = task2.GetResult(0)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}, len(levelList))
|
}, len(levelList))
|
||||||
tasksch.HandleTask(task1, parentTask, true).Run()
|
tasksch.HandleTask(task1, parentTask, true).Run()
|
||||||
@@ -80,28 +73,53 @@ func flatCatList(catList []*partner.BareCategoryInfo) (flattedCatList []*partner
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *DefSingleStorePlatform) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
func (p *DefSingleStorePlatform) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||||
var skuIDs []int
|
resultList, err := FreeBatchStoreSkuInfo(func(batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, err error) {
|
||||||
isSingle := len(inStoreSkuList) == 1
|
return p.GetStoreSkusFullInfo(ctx, parentTask, storeID, vendorStoreID, batchedStoreSkuList)
|
||||||
if isSingle {
|
}, ctx, parentTask, inStoreSkuList, p.GetStoreSkusBatchSize(partner.FuncGetStoreSkusFullInfo))
|
||||||
skuIDs = []int{inStoreSkuList[0].SkuID}
|
if err != nil || len(resultList) == 0 {
|
||||||
}
|
|
||||||
globals.SugarLogger.Debug(p)
|
|
||||||
skuNameList, err := p.GetStoreSkusFullInfo(ctx, parentTask, storeID, vendorStoreID, skuIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, skuName := range skuNameList {
|
inStoreSkuMap := make(map[string]*partner.StoreSkuInfo)
|
||||||
|
for _, v := range inStoreSkuList {
|
||||||
|
if v.VendorSkuID != "" {
|
||||||
|
inStoreSkuMap[v.VendorNameID] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range resultList {
|
||||||
|
skuName := v.(*partner.SkuNameInfo)
|
||||||
storeSkuBareInfo := &skuName.SkuList[0].StoreSkuInfo
|
storeSkuBareInfo := &skuName.SkuList[0].StoreSkuInfo
|
||||||
if isSingle {
|
if storeSkuBareInfo.SkuID == 0 && inStoreSkuMap[storeSkuBareInfo.VendorSkuID] != nil {
|
||||||
storeSkuBareInfo.VendorNameID = inStoreSkuList[0].VendorNameID
|
storeSkuBareInfo.SkuID = inStoreSkuMap[storeSkuBareInfo.VendorSkuID].SkuID
|
||||||
storeSkuBareInfo.VendorSkuID = inStoreSkuList[0].VendorSkuID
|
storeSkuBareInfo.NameID = inStoreSkuMap[storeSkuBareInfo.VendorSkuID].NameID
|
||||||
}
|
}
|
||||||
outStoreSkuList = append(outStoreSkuList, storeSkuBareInfo)
|
outStoreSkuList = append(outStoreSkuList, storeSkuBareInfo)
|
||||||
}
|
}
|
||||||
return outStoreSkuList, err
|
return outStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func FreeBatchStoreSkuInfo(handler func([]*partner.StoreSkuInfo) (err error), ctx *jxcontext.Context, parentTask tasksch.ITask, storeSkuList []*partner.StoreSkuInfo, batchSize int) (err error) {
|
func findCategoryByName(catList []*partner.BareCategoryInfo, catName string) (cat *partner.BareCategoryInfo) {
|
||||||
|
for _, v := range catList {
|
||||||
|
if v.Name == catName {
|
||||||
|
cat = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if cat = findCategoryByName(v.Children, catName); cat != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cat
|
||||||
|
}
|
||||||
|
func (p *DefSingleStorePlatform) GetStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, catName string) (cat *partner.BareCategoryInfo, err error) {
|
||||||
|
catList, err := p.GetStoreAllCategories(ctx, storeID, vendorStoreID)
|
||||||
|
if err == nil {
|
||||||
|
if cat = findCategoryByName(catList, catName); cat == nil {
|
||||||
|
err = fmt.Errorf("门店:%d,%s不能找到商家分类:%s", storeID, vendorStoreID, catName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cat, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func FreeBatchStoreSkuInfo(handler func([]*partner.StoreSkuInfo) (interface{}, error), ctx *jxcontext.Context, parentTask tasksch.ITask, storeSkuList []*partner.StoreSkuInfo, batchSize int) (resultList []interface{}, err error) {
|
||||||
if len(storeSkuList) > batchSize {
|
if len(storeSkuList) > batchSize {
|
||||||
task := tasksch.NewParallelTask("FreeBatchStoreSkuInfo", tasksch.NewParallelConfig().SetBatchSize(batchSize), ctx,
|
task := tasksch.NewParallelTask("FreeBatchStoreSkuInfo", tasksch.NewParallelConfig().SetBatchSize(batchSize), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
@@ -109,13 +127,31 @@ func FreeBatchStoreSkuInfo(handler func([]*partner.StoreSkuInfo) (err error), ct
|
|||||||
for k, v := range batchItemList {
|
for k, v := range batchItemList {
|
||||||
batchStoreSkuList[k] = v.(*partner.StoreSkuInfo)
|
batchStoreSkuList[k] = v.(*partner.StoreSkuInfo)
|
||||||
}
|
}
|
||||||
err = handler(batchStoreSkuList)
|
retVal, err = handler(batchStoreSkuList)
|
||||||
return nil, err
|
return retVal, err
|
||||||
}, storeSkuList)
|
}, storeSkuList)
|
||||||
tasksch.HandleTask(task, parentTask, false).Run()
|
tasksch.HandleTask(task, parentTask, false).Run()
|
||||||
_, err = task.GetResult(0)
|
resultList, err = task.GetResult(0)
|
||||||
} else {
|
} else {
|
||||||
err = handler(storeSkuList)
|
result, err2 := handler(storeSkuList)
|
||||||
|
if err = err2; err == nil {
|
||||||
|
resultList = utils.Interface2Slice(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func FreeBatchCategoryIDOp(handler func(vendorCatID string) (err error), ctx *jxcontext.Context, parentTask tasksch.ITask, vendorCatIDs []string) (err error) {
|
||||||
|
if len(vendorCatIDs) > 1 {
|
||||||
|
task := tasksch.NewParallelTask("FreeBatchCategoryIDOp", nil, ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
err = handler(batchItemList[0].(string))
|
||||||
|
return nil, err
|
||||||
|
}, vendorCatIDs)
|
||||||
|
tasksch.HandleTask(task, parentTask, false).Run()
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
} else if len(vendorCatIDs) > 0 {
|
||||||
|
err = handler(vendorCatIDs[0])
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user