From fa3ed06aa1ffa889107c6b22a807987d5210e578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 29 Jan 2024 18:19:55 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/system_store_sku.go | 68 +++++++++--------------- 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index dbacd121c..37b181fc4 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -37,30 +37,15 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromStoreId, toStoreId string case model.VendorIDMTWM: return CopyMtToMT(ctx, fromStore, toStore, isAsync, offSet) case model.VendorIDEBAI: - return CopyEBaiToEBai(ctx, fromStore, toStore, isAsync) + return CopyEBaiToEBai(ctx, fromStore, toStore, isAsync, offSet) default: return "", fmt.Errorf("暂时还不支持") } } // CopyEBaiToEBai 饿了么商品复制到饿了么 -func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isAsync bool) (hint string, err error) { - 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, - } +func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isAsync bool, offset int) (hint string, err error) { + VendorCategoryIDMap := map[int64]int64{} api := api.EbaiAPI taskName := fmt.Sprintf("将饿了么平台门店[%s],分类和商品复制到[%s]", fromStore.VendorStoreID, toStore.VendorStoreID) config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false) @@ -75,29 +60,29 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, // return nil, errs[0] //} case 2: - // 同步分类 - //fromCategoryList, err := api.ShopCategoryGet(utils.Int2Str(fromStore.ID)) - //if err != nil { - // return nil, err - //} - //for _, v := range fromCategoryList { - // parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank) - // if categoryErr != nil { - // globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr) - // continue - // } - // VendorCategoryIDMap[v.CategoryID] = parentID - // if v.Children != nil && len(v.Children) != 0 { - // for _, c := range v.Children { - // childrenCateId, err := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank) - // if err != nil { - // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err) - // continue - // } - // VendorCategoryIDMap[c.CategoryID] = childrenCateId - // } - // } - //} + //同步分类 + fromCategoryList, err := api.ShopCategoryGet(utils.Int2Str(fromStore.ID)) + if err != nil { + return nil, err + } + for _, v := range fromCategoryList { + parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank) + if categoryErr != nil { + globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr) + continue + } + VendorCategoryIDMap[v.CategoryID] = parentID + if v.Children != nil && len(v.Children) != 0 { + for _, c := range v.Children { + childrenCateId, err := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank) + if err != nil { + globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err) + continue + } + VendorCategoryIDMap[c.CategoryID] = childrenCateId + } + } + } case 3: i := 1 for { @@ -108,7 +93,6 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, if len(fromFoodList.List) == 0 || fromFoodList == nil { return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) } - globals.SugarLogger.Debugf("============len %d", len(fromFoodList.List)) if err = BatchInitSkuEBai2EBai(ctx, fromFoodList.List, api, utils.Int2Str(toStore.ID), VendorCategoryIDMap); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) }