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++ {
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 {
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)
var (
//mtAccessToken = ""
db = dao.GetDB()
//db = dao.GetDB()
catMap = make(map[string]string)
LoopCatChild funcType
)
@@ -6583,58 +6583,60 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
step := batchItemList[0].(int)
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)
skuList, _ := mtapi.RetailList(mtStoreID, 0, 2)
skuList, _ := mtapi.RetailListAll(mtStoreID, 0)
//skuList, _ := mtapi.RetailList(mtStoreID, 0, 2)
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,
ShopCategories: []int64{},
CategoryID: utils.Str2Int64(catMaps[0].JdID),
BrandID: 35247,
SkuName: mtSku.Name,
SkuPrice: int(jxutils.StandardPrice2Int(mtSku.Price)),
Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight))),
FixedStatus: 1,
IsSale: -1,
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]))
//CategoryID: utils.Str2Int64(catMaps[0].JdID),
CategoryID: 291, // 暂无分类
BrandID: 35247,
SkuName: mtSku.Name,
SkuPrice: int(jxutils.StandardPrice2Int(mtSku.Price)),
Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight))),
FixedStatus: 1,
IsSale: -1,
Upc: mtSku.SkuList[0].Upc,
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]))
//}
param.ProductDesc = fmt.Sprintf(`<img src="%s" alt="一张图片" />`, mtSku.PictureContents)
skuID, err := jd.AddSku2(param)
if skuID != "" {