diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 73f0a8fb2..421098ad6 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -6559,7 +6559,7 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo type funcType func(mtID, parentID string, catInfo []*mtwmapi.RetailCategoryInfo) var ( //mtAccessToken = "" - //db = dao.GetDB() + db = dao.GetDB() catMap = make(map[string]string) LoopCatChild funcType ) @@ -6584,24 +6584,24 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo switch step { case 0: //建分类 ,账号存在分类,不在创建分类 - //jdCatList, _ := jd.QueryCategoriesByOrgCode() - //if len(jdCatList) == 0 { - // catList, _ := mtapi.RetailCatList(mtStoreID) - // for i := len(catList) - 1; i > -1; i-- { - // catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "") - // if catID != "" { - // catMap[catList[i].Code] = catID - // } - // //LoopCatChild(catList[i].Code, catID, catList[i].Children) - // //美团好像只能建两级分类? - // for j := len(catList[i].Children) - 1; j > -1; j-- { - // catID2, _ := jd.AddShopCategory(utils.Str2Int64(catID), catList[i].Children[j].Name, catList[i].Children[j].Level, catList[i].Children[j].Sequence, "") - // if catID2 != "" { - // catMap[catList[i].Children[j].Code] = catID2 - // } - // } - // } - //} + jdCatList, _ := jd.QueryCategoriesByOrgCode() + if len(jdCatList) == 0 { + catList, _ := mtapi.RetailCatList(mtStoreID) + for i := len(catList) - 1; i > -1; i-- { + catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "") + if catID != "" { + catMap[catList[i].Code] = catID + } + //LoopCatChild(catList[i].Code, catID, catList[i].Children) + //美团好像只能建两级分类? + for j := len(catList[i].Children) - 1; j > -1; j-- { + catID2, _ := jd.AddShopCategory(utils.Str2Int64(catID), catList[i].Children[j].Name, catList[i].Children[j].Level, catList[i].Children[j].Sequence, "") + if catID2 != "" { + catMap[catList[i].Children[j].Code] = catID2 + } + } + } + } case 1: //建商品 skuList, _ := mtapi.RetailListAll(mtStoreID, 0) @@ -6609,13 +6609,13 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo task2 := tasksch.NewParallelTask("美团到京东, 建商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { mtSku := batchItemList[0].(*mtwmapi.AppFood) - //catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "") - //if len(catMaps) == 0 { - // results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID) - // results2, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results[0].ParentID)) - // results3, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results2[0].ParentID)) - // return retVal, fmt.Errorf("该商品美团分类还未映射到京东,商品名:[%v],美团分类:[%v] ->[%v] ->[%v]。", mtSku.Name, results3[0].Name, results2[0].Name, results[0].Name) - //} + catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "") + if len(catMaps) == 0 { + results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID) + results2, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results[0].ParentID)) + results3, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results2[0].ParentID)) + return retVal, fmt.Errorf("该商品美团分类还未映射到京东,商品名:[%v],美团分类:[%v] ->[%v] ->[%v]。", mtSku.Name, results3[0].Name, results2[0].Name, results[0].Name) + } param := &jdapi.OpSkuParam{ TraceID: ctx.GetTrackInfo(), OutSkuID: mtSku.AppFoodCode, @@ -6632,11 +6632,11 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo Images: mtSku.PictureList, } param.ShopCategories = append(param.ShopCategories, 16578930) // 暂无分类 - //if mtSku.SecondaryCategoryCode != "" { - // param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryCode])) - //} else if mtSku.CategoryCode != "" { - // param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.CategoryCode])) - //} + if mtSku.SecondaryCategoryCode != "" { + param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryCode])) + } else if mtSku.CategoryCode != "" { + param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.CategoryCode])) + } param.ProductDesc = fmt.Sprintf(`一张图片`, mtSku.PictureContents) skuID, err := jd.AddSku2(param) if skuID != "" { diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 6afed4a9b..0809636ac 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -451,7 +451,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) } globals.SugarLogger.Debugf("-----------errr := %v", err) - //storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask // 品库修改 售卖状态待同步 价格待同步 storeSku.SkuSyncStatus = 0 // 品库修改 售卖状态待同步 价格待同步 }