1
This commit is contained in:
@@ -45,6 +45,7 @@ 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)
|
||||||
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)
|
||||||
@@ -60,21 +61,29 @@ 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 {
|
if err != nil {
|
||||||
// parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank)
|
return nil, err
|
||||||
// if categoryErr != nil {
|
}
|
||||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
for _, v := range fromCategoryList {
|
||||||
// continue
|
parentID, categoryErr := api.ShopCategoryCreate(utils.Int2Str(toStore.ID), 0, v.Name, v.Rank)
|
||||||
// }
|
if categoryErr != nil {
|
||||||
// if v.Children != nil && len(v.Children) != 0 {
|
globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
||||||
// for _, c := range v.Children {
|
continue
|
||||||
// if _, err = api.ShopCategoryCreate(utils.Int2Str(toStore.ID), parentID, c.Name, c.Rank); err != nil {
|
}
|
||||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err)
|
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[v.CategoryID] = childrenCateId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("======VendorCategoryIDMap := %s", utils.Format4Output(VendorCategoryIDMap, false))
|
||||||
case 3:
|
case 3:
|
||||||
i := 0
|
i := 0
|
||||||
for {
|
for {
|
||||||
@@ -84,8 +93,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, utils.Int2Str(toStore.ID), VendorCategoryIDMap); 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))
|
||||||
}
|
}
|
||||||
i = fromFoodList.SkuIdOffset
|
i = fromFoodList.SkuIdOffset
|
||||||
@@ -106,7 +114,7 @@ func CopyEBaiToEBai(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BatchInitSkuEBai2EBai 批量创建商品
|
// BatchInitSkuEBai2EBai 批量创建商品
|
||||||
func BatchInitSkuEBai2EBai(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, toApi *ebaiapi.API, storeID string) error {
|
func BatchInitSkuEBai2EBai(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, toApi *ebaiapi.API, storeID string, VendorCategoryIDMap map[int64]int64) error {
|
||||||
for _, storeSku := range fromSku {
|
for _, storeSku := range fromSku {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"left_num": model.MaxStoreSkuStockQty,
|
"left_num": model.MaxStoreSkuStockQty,
|
||||||
@@ -116,8 +124,8 @@ func BatchInitSkuEBai2EBai(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, t
|
|||||||
}
|
}
|
||||||
params["upc"] = storeSku.Upc
|
params["upc"] = storeSku.Upc
|
||||||
params["name"] = storeSku.Name
|
params["name"] = storeSku.Name
|
||||||
params["cat3_id"] = storeSku.CateId2
|
params["cat3_id"] = VendorCategoryIDMap[int64(storeSku.CateId2)]
|
||||||
params["category_id"] = storeSku.CateId
|
params["category_id"] = VendorCategoryIDMap[int64(storeSku.CateId)]
|
||||||
params["rtf"] = storeSku.Rtf
|
params["rtf"] = storeSku.Rtf
|
||||||
params["process_type"] = storeSku.ProcessType
|
params["process_type"] = storeSku.ProcessType
|
||||||
params["process_detail"] = storeSku.ProcessDetail
|
params["process_detail"] = storeSku.ProcessDetail
|
||||||
|
|||||||
Reference in New Issue
Block a user