This commit is contained in:
邹宗楠
2024-01-26 15:37:26 +08:00
parent cdb4a81de5
commit ee8cba6dc0

View File

@@ -46,7 +46,6 @@ 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) {
api := api.EbaiAPI api := api.EbaiAPI
globals.SugarLogger.Debugf("===========%s", api.GetSource())
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)
work := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { work := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
@@ -61,21 +60,21 @@ 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))
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
} // }
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 {
if _, err = api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank); err != nil { // if _, err = api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank); err != nil {
globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err) // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err)
} // }
} // }
} // }
} //}
case 3: case 3:
i := 0 i := 0
for { for {
@@ -85,6 +84,7 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail,
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)
} }
globals.SugarLogger.Debugf("===========%s", api.GetSource())
if err = BatchInitSkuEBai2EBai(ctx, fromFoodList.List, api, toStore.VendorStoreID); err != nil { if err = BatchInitSkuEBai2EBai(ctx, fromFoodList.List, api, toStore.VendorStoreID); err != nil {
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
} }