From 0ffe12bb75d1eb70882fd364767a9ba6d9b163b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:09:11 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/system_store_sku.go | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index d88eef30c..d0f00c116 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -13,7 +13,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/business/partner/putils" ) @@ -78,18 +77,26 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 3: - // 同步商品 - fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) - if len(fromFoodList) == 0 || fromFoodList == nil { - return nil, fmt.Errorf("fromFoodList 为空") - } - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) - if err1 != nil { - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) - } - if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + i := 0 + for { + // 同步商品 + fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) + if len(fromFoodList) == 0 || fromFoodList == nil { + return nil, fmt.Errorf("fromFoodList 为空") + } + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) + if err1 != nil { + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) + } + if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { + globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + } + if len(fromFoodList) < 200 { + break + } + i++ } + } return } @@ -105,7 +112,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId } func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode string) (err []error) { - foodList, err1 := api.RetailListAll(poiCode) + foodList, err1 := api.RetailListAll(poiCode, 0) if err1 != nil { return append(err, err1) } @@ -156,7 +163,7 @@ type Skus struct { // BatchInitData 批量创建商品 func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error { - globals.SugarLogger.Debugf("===========[] %s", utils.Format4Output(fromSku[0], false)) + globals.SugarLogger.Debugf("===========[] %d", len(fromSku)) foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) @@ -178,10 +185,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["min_order_count"] = storeSku.MinOrderCount foodData["unit"] = storeSku.Unit //todo 增加商品必填属性 - attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) - if attr != "" { - foodData["common_attr_value"] = attr - } + //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) + //if attr != "" { + foodData["common_attr_value"] = storeSku.CommonAttrValue + //} if storeSku.SecondaryCategoryCode != "" { foodData["category_code"] = storeSku.SecondaryCategoryCode } else { @@ -257,7 +264,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if len(foodDataList)%5 != 0 { count += 1 } - + globals.SugarLogger.Debugf("===========[count] %d", count) for i := 0; i < count; i++ { if i == count-1 { failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:])