This commit is contained in:
邹宗楠
2024-01-26 17:26:20 +08:00
parent 3986ec8fc0
commit 524a63efdc

View File

@@ -45,7 +45,22 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromStoreId, toStoreId string
// CopyEBaiToEBai 饿了么商品复制到饿了么 // CopyEBaiToEBai 饿了么商品复制到饿了么
func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isAsync bool) (hint string, err error) { func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isAsync bool) (hint string, err error) {
VendorCategoryIDMap := make(map[int64]int64, 0) VendorCategoryIDMap := map[int64]int64{
170606586622696: 170625362622152,
170606586622697: 170625362622153,
170606586722698: 170625362622154,
170606586822844: 170625362622155,
170606586922845: 170625362722162,
170606587022847: 170625362722163,
170606587122869: 170625362722164,
170606587222899: 170625362722165,
170606587322900: 170625362822166,
170606587422901: 170625362822167,
170606587522928: 170625362822168,
170606587622931: 170625362822169,
170606587722932: 170625362922170,
170606587822933: 170625362922171,
}
api := api.EbaiAPI api := api.EbaiAPI
taskName := fmt.Sprintf("将饿了么平台门店[%s],分类和商品复制到[%s]", fromStore.VendorStoreID, toStore.VendorStoreID) taskName := fmt.Sprintf("将饿了么平台门店[%s],分类和商品复制到[%s]", fromStore.VendorStoreID, toStore.VendorStoreID)
config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false) config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false)
@@ -61,34 +76,35 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail,
//} //}
case 2: case 2:
// 同步分类 // 同步分类
fromCategoryList, err := api.ShopCategoryGet(utils.Int2Str(fromStore.ID)) //fromCategoryList, err := api.ShopCategoryGet(utils.Int2Str(fromStore.ID))
if err != nil { //if err != nil {
return nil, err // return nil, err
} //}
for _, v := range fromCategoryList { //for _, v := range fromCategoryList {
parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank) // parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank)
if categoryErr != nil { // if categoryErr != nil {
globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr) // globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
continue // continue
} // }
VendorCategoryIDMap[v.CategoryID] = parentID // VendorCategoryIDMap[v.CategoryID] = parentID
if v.Children != nil && len(v.Children) != 0 { // if v.Children != nil && len(v.Children) != 0 {
for _, c := range v.Children { // for _, c := range v.Children {
childrenCateId, err := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank) // childrenCateId, err := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank)
if err != nil { // if err != nil {
globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err) // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err)
continue // continue
} // }
VendorCategoryIDMap[c.CategoryID] = childrenCateId // VendorCategoryIDMap[c.CategoryID] = childrenCateId
} // }
} // }
} //}
globals.SugarLogger.Debugf("======VendorCategoryIDMap := %s", utils.Format4Output(VendorCategoryIDMap, false))
case 3: case 3:
i := 0 i := 0
for { for {
// 同步商品 // 同步商品
fromFoodList, err1 := api.SkuList(utils.Int2Str(fromStore.ID), &ebaiapi.SkuListParams{}) fromFoodList, err1 := api.SkuList(utils.Int2Str(fromStore.ID), &ebaiapi.SkuListParams{
SkuIdOffset: i,
})
if len(fromFoodList.List) == 0 || fromFoodList == nil { if len(fromFoodList.List) == 0 || fromFoodList == nil {
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
} }