From addcca87ae0b3d3580f746625a9cbaec409c2838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 17:13:01 +0800 Subject: [PATCH 1/5] 1 --- business/jxstore/cms/system_store_sku.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index fab447d6c..2c6e56786 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -124,9 +124,10 @@ func BatchInitSkuEBai2EBai(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, t } params["upc"] = storeSku.Upc params["name"] = storeSku.Name - params["cat3_id"] = VendorCategoryIDMap[int64(storeSku.CateId2)] - params["category_id"] = VendorCategoryIDMap[int64(storeSku.CateId)] + params["cat3_id"] = storeSku.CateId + params["category_id"] = VendorCategoryIDMap[utils.Str2Int64(storeSku.CustomCatList[0].CustomCatID)] params["rtf"] = storeSku.Rtf + params["left_num"] = storeSku.LeftNum params["process_type"] = storeSku.ProcessType params["process_detail"] = storeSku.ProcessDetail params["sale_price"] = storeSku.SalePrice From 524a63efdcc84e66a5f317e8eec550b3634dbf39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 17:26:20 +0800 Subject: [PATCH 2/5] 1 --- business/jxstore/cms/system_store_sku.go | 66 +++++++++++++++--------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 2c6e56786..77e2ecac6 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -45,7 +45,22 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromStoreId, toStoreId string // CopyEBaiToEBai 饿了么商品复制到饿了么 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 taskName := fmt.Sprintf("将饿了么平台门店[%s],分类和商品复制到[%s]", fromStore.VendorStoreID, toStore.VendorStoreID) config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false) @@ -61,34 +76,35 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, //} 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 - } - } - } - globals.SugarLogger.Debugf("======VendorCategoryIDMap := %s", utils.Format4Output(VendorCategoryIDMap, false)) + //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 := 0 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 { return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) } From 06d756ea8245fe3fc20761a271d69890731ef166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 17:39:26 +0800 Subject: [PATCH 3/5] 1 --- business/jxstore/cms/system_store_sku.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 77e2ecac6..062e464f5 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -103,6 +103,7 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, for { // 同步商品 fromFoodList, err1 := api.SkuList(utils.Int2Str(fromStore.ID), &ebaiapi.SkuListParams{ + Page: 1, SkuIdOffset: i, }) if len(fromFoodList.List) == 0 || fromFoodList == nil { From 47fed7d90ca056ecc3b7da5b4d67ab1a9c7ad85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 17:40:25 +0800 Subject: [PATCH 4/5] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 062e464f5..af4585325 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -109,7 +109,7 @@ 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)) } From 616c1e3dc8dd0c6572f83658d13159998e01c949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 17:46:52 +0800 Subject: [PATCH 5/5] 1 --- business/jxstore/cms/system_store_sku.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index af4585325..dbacd121c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -99,12 +99,11 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, // } //} case 3: - i := 0 + i := 1 for { // 同步商品 fromFoodList, err1 := api.SkuList(utils.Int2Str(fromStore.ID), &ebaiapi.SkuListParams{ - Page: 1, - SkuIdOffset: i, + Page: i, }) if len(fromFoodList.List) == 0 || fromFoodList == nil { return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) @@ -113,7 +112,7 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, if err = BatchInitSkuEBai2EBai(ctx, fromFoodList.List, api, utils.Int2Str(toStore.ID), VendorCategoryIDMap); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } - i = fromFoodList.SkuIdOffset + i = i + 1 } }