This commit is contained in:
邹宗楠
2025-04-28 17:11:55 +08:00
parent 17f66fc9b2
commit e2e27d7e1b
2 changed files with 31 additions and 32 deletions

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
) )
@@ -6584,24 +6584,24 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
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, 0) 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, 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,
@@ -6632,11 +6632,11 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
Images: mtSku.PictureList, Images: mtSku.PictureList,
} }
param.ShopCategories = append(param.ShopCategories, 16578930) // 暂无分类 param.ShopCategories = append(param.ShopCategories, 16578930) // 暂无分类
//if mtSku.SecondaryCategoryCode != "" { if mtSku.SecondaryCategoryCode != "" {
// param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryCode])) param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryCode]))
//} else if mtSku.CategoryCode != "" { } else if mtSku.CategoryCode != "" {
// param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[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 != "" {

View File

@@ -451,7 +451,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType)
} }
globals.SugarLogger.Debugf("-----------errr := %v", err) globals.SugarLogger.Debugf("-----------errr := %v", err)
//storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask // 品库修改 售卖状态待同步 价格待同步 //storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask // 品库修改 售卖状态待同步 价格待同步
storeSku.SkuSyncStatus = 0 // 品库修改 售卖状态待同步 价格待同步 storeSku.SkuSyncStatus = 0 // 品库修改 售卖状态待同步 价格待同步
} }