1
This commit is contained in:
@@ -6609,35 +6609,36 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
//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 != "" {
|
||||
if catList[i].Code != "" {
|
||||
catMap[catList[i].Code] = catID
|
||||
} else {
|
||||
catMap[catList[i].Name] = 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 != "" {
|
||||
if catList[i].Children[j].Code != "" {
|
||||
catMap[catList[i].Children[j].Code] = catID2
|
||||
} else {
|
||||
catMap[catList[i].Children[j].Name] = catID2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("--------catMapcatMap := %s", utils.Format4Output(catList, false))
|
||||
//}
|
||||
case 1:
|
||||
//建商品
|
||||
var i = 0
|
||||
skuList := make([]*mtwmapi.AppFood, 0, 0)
|
||||
//for i := 0; i < 9; i++ {
|
||||
// skuList2, _ := mtapi.RetailListAll(mtStoreID, i)
|
||||
// skuList = append(skuList, skuList2...)
|
||||
//}
|
||||
//skuList, _ := mtapi.RetailList(mtStoreID, 0, 2)
|
||||
|
||||
for {
|
||||
foodList, err := mtapi.RetailListAll(mtStoreID, i)
|
||||
if err != nil {
|
||||
@@ -6662,35 +6663,35 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
// 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,
|
||||
param := &jdapi.NewAddSkuParam{
|
||||
TraceId: ctx.GetTrackInfo(),
|
||||
OutSkuId: mtSku.AppFoodCode,
|
||||
ShopCategories: []int64{}, // 商家分类
|
||||
//CategoryID: utils.Str2Int64(catMaps[0].JdID), // 到家分类
|
||||
//BrandID: 35247,
|
||||
CategoryId: 0, // 到家分类
|
||||
BrandId: 0,
|
||||
SkuName: mtSku.Name,
|
||||
SkuPrice: int(jxutils.StandardPrice2Int(mtSku.Price)),
|
||||
Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight))),
|
||||
SkuPrice: int64(jxutils.StandardPrice2Int(mtSku.Price)),
|
||||
Weight: math.Round(float64(jxutils.IntWeight2Float(utils.Str2Int(mtSku.SkuList[0].Weight)))*1000) / 1000,
|
||||
FixedStatus: 1,
|
||||
IsSale: 1,
|
||||
IsSale: true,
|
||||
Upc: mtSku.SkuList[0].Upc,
|
||||
Images: mtSku.PictureList,
|
||||
}
|
||||
brandList, err := jd.GetSkuCategoryBySkuName(mtSku.Name)
|
||||
if brandList == nil || err != nil {
|
||||
param.BrandID = 35247
|
||||
param.BrandId = 35247
|
||||
} else {
|
||||
param.BrandID = int64(brandList.BrandId)
|
||||
param.CategoryID = int64(brandList.CategoryId)
|
||||
param.BrandId = int64(brandList.BrandId)
|
||||
param.CategoryId = int64(brandList.CategoryId)
|
||||
}
|
||||
|
||||
if param.OutSkuID == "" {
|
||||
param.OutSkuID = fmt.Sprintf("%d_%d%d", time.Now().Unix(), param.SkuPrice, len(mtSku.Name))
|
||||
if param.OutSkuId == "" {
|
||||
param.OutSkuId = fmt.Sprintf("%d_%d%d", time.Now().Unix(), param.SkuPrice, len(mtSku.Name))
|
||||
}
|
||||
|
||||
if param.CategoryID == 0 {
|
||||
if param.CategoryId == 0 {
|
||||
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(jdOrgCode, strings.Join(mtSku.PictureList, "|"))
|
||||
param.CategoryID = utils.Str2Int64(vendorCategoryId)
|
||||
param.CategoryId = utils.Str2Int64(vendorCategoryId)
|
||||
//if vendorCategoryId != "" && utils.Str2Int64(vendorCategoryId) <= 25048 {
|
||||
// param.CategoryID = utils.Str2Int64(vendorCategoryId) // 其他水果
|
||||
//} else if utils.Str2Int64(vendorCategoryId) > 25048 { // 只有水果,後面刪除
|
||||
@@ -6699,7 +6700,7 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
}
|
||||
|
||||
if mtSku.SecondaryCategoryCode != "" {
|
||||
param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryCode]))
|
||||
param.ShopCategories = append(param.ShopCategories, utils.Str2Int64WithDefault(catMap[mtSku.SecondaryCategoryCode], 33313305))
|
||||
} else if mtSku.SecondaryCategoryName != "" {
|
||||
param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(catMap[mtSku.SecondaryCategoryName]))
|
||||
} else if mtSku.CategoryCode != "" {
|
||||
@@ -6712,10 +6713,18 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
if mtSku.PictureContents != "" {
|
||||
param.ProductDesc = fmt.Sprintf(`<img src="%s" alt="一张图片" />`, mtSku.PictureContents)
|
||||
}
|
||||
skuID, err := jd.AddSku2(param)
|
||||
if param.Upc == "" {
|
||||
productInfo, _ := jd.GetJdUpcCodeByName(param.SkuName, "", 1, 10)
|
||||
if len(productInfo) != 0 {
|
||||
param.Upc = productInfo[0].UpcCode
|
||||
}
|
||||
}
|
||||
|
||||
skuID, err := jd.NewAddSku(param)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("---------AddSku2 := %s,%v", utils.Format4Output(param, false), err)
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
if skuID != "" {
|
||||
err1 := jd.UpdateCurrentQty(ctx.GetTrackInfo(), jdStoreID, utils.Str2Int64(skuID), utils.Str2Int(mtSku.SkuList[0].Stock))
|
||||
if err1 != nil {
|
||||
|
||||
Reference in New Issue
Block a user