This commit is contained in:
邹宗楠
2025-03-21 13:46:45 +08:00
parent a74e2e45f8
commit 4be0560888
2 changed files with 46 additions and 44 deletions

View File

@@ -472,7 +472,7 @@ func JdSyncSkuPriceAndStatus(db *dao.DaoDB, sm *model.StoreMap, skuMap map[strin
for i := 1; i <= count; i++ { for i := 1; i <= count; i++ {
if i == count { if i == count {
jdsApi.BatchUpdateVendibility(jxcontext.AdminCtx.GetTrackInfo(), "", sm.VendorStoreID, skuVendibilityList[i*50:], jxcontext.AdminCtx.GetUserName()) jdsApi.BatchUpdateVendibility(jxcontext.AdminCtx.GetTrackInfo(), "", sm.VendorStoreID, skuVendibilityList[(i-1)*50:], jxcontext.AdminCtx.GetUserName())
} else { } else {
jdsApi.BatchUpdateVendibility(jxcontext.AdminCtx.GetTrackInfo(), "", sm.VendorStoreID, skuVendibilityList[(i-1)*50:i*50], jxcontext.AdminCtx.GetUserName()) jdsApi.BatchUpdateVendibility(jxcontext.AdminCtx.GetTrackInfo(), "", sm.VendorStoreID, skuVendibilityList[(i-1)*50:i*50], jxcontext.AdminCtx.GetUserName())
} }

View File

@@ -6559,7 +6559,7 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
type funcType func(mtID, parentID string, catInfo []*mtwmapi.RetailCategoryInfo) type funcType func(mtID, parentID string, catInfo []*mtwmapi.RetailCategoryInfo)
var ( var (
//mtAccessToken = "" //mtAccessToken = ""
db = dao.GetDB() //db = dao.GetDB()
catMap = make(map[string]string) catMap = make(map[string]string)
LoopCatChild funcType LoopCatChild funcType
) )
@@ -6583,58 +6583,60 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
step := batchItemList[0].(int) step := batchItemList[0].(int)
switch step { switch step {
case 0: case 0:
//建分类 //建分类 ,账号存在分类,不在创建分类
jdCatList, _ := jd.QueryCategoriesByOrgCode() //jdCatList, _ := jd.QueryCategoriesByOrgCode()
if len(jdCatList) == 0 { //if len(jdCatList) == 0 {
catList, _ := mtapi.RetailCatList(mtStoreID) // catList, _ := mtapi.RetailCatList(mtStoreID)
for i := len(catList) - 1; i > -1; i-- { // for i := len(catList) - 1; i > -1; i-- {
catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "") // catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "")
if catID != "" { // if catID != "" {
catMap[catList[i].Code] = catID // catMap[catList[i].Code] = catID
} // }
//LoopCatChild(catList[i].Code, catID, catList[i].Children) // //LoopCatChild(catList[i].Code, catID, catList[i].Children)
//美团好像只能建两级分类? // //美团好像只能建两级分类?
for j := len(catList[i].Children) - 1; j > -1; j-- { // 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, "") // catID2, _ := jd.AddShopCategory(utils.Str2Int64(catID), catList[i].Children[j].Name, catList[i].Children[j].Level, catList[i].Children[j].Sequence, "")
if catID2 != "" { // if catID2 != "" {
catMap[catList[i].Children[j].Code] = catID2 // catMap[catList[i].Children[j].Code] = catID2
} // }
} // }
} // }
} //}
case 1: case 1:
//建商品 //建商品
//skuList, _ := mtapi.RetailListAll(mtStoreID) skuList, _ := mtapi.RetailListAll(mtStoreID, 0)
skuList, _ := mtapi.RetailList(mtStoreID, 0, 2) //skuList, _ := mtapi.RetailList(mtStoreID, 0, 2)
task2 := tasksch.NewParallelTask("美团到京东, 建商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx, task2 := tasksch.NewParallelTask("美团到京东, 建商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
mtSku := batchItemList[0].(*mtwmapi.AppFood) mtSku := batchItemList[0].(*mtwmapi.AppFood)
catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "") //catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "")
if len(catMaps) == 0 { //if len(catMaps) == 0 {
results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID) // results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID)
results2, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results[0].ParentID)) // results2, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results[0].ParentID))
results3, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, utils.Str2Int(results2[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) // return retVal, fmt.Errorf("该商品美团分类还未映射到京东,商品名:[%v],美团分类:[%v] ->[%v] ->[%v]。", mtSku.Name, results3[0].Name, results2[0].Name, results[0].Name)
} //}
param := &jdapi.OpSkuParam{ param := &jdapi.OpSkuParam{
TraceID: ctx.GetTrackInfo(), TraceID: ctx.GetTrackInfo(),
OutSkuID: mtSku.AppFoodCode, OutSkuID: mtSku.AppFoodCode,
ShopCategories: []int64{}, ShopCategories: []int64{},
CategoryID: utils.Str2Int64(catMaps[0].JdID), //CategoryID: utils.Str2Int64(catMaps[0].JdID),
BrandID: 35247, CategoryID: 291, // 暂无分类
SkuName: mtSku.Name, BrandID: 35247,
SkuPrice: int(jxutils.StandardPrice2Int(mtSku.Price)), SkuName: mtSku.Name,
Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight))), SkuPrice: int(jxutils.StandardPrice2Int(mtSku.Price)),
FixedStatus: 1, Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight))),
IsSale: -1, FixedStatus: 1,
Upc: mtSku.SkuList[0].Upc, IsSale: -1,
Images: mtSku.PictureList, Upc: mtSku.SkuList[0].Upc,
} Images: mtSku.PictureList,
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.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]))
//}
param.ProductDesc = fmt.Sprintf(`<img src="%s" alt="一张图片" />`, mtSku.PictureContents) param.ProductDesc = fmt.Sprintf(`<img src="%s" alt="一张图片" />`, mtSku.PictureContents)
skuID, err := jd.AddSku2(param) skuID, err := jd.AddSku2(param)
if skuID != "" { if skuID != "" {