This commit is contained in:
邹宗楠
2024-11-08 11:41:39 +08:00
parent 03efa23fb9
commit b16712a930
4 changed files with 25 additions and 12 deletions

View File

@@ -14,7 +14,7 @@ import (
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
beego "github.com/astaxie/beego/server/web"
//beego "github.com/astaxie/beego/server/web"
)
const (
@@ -24,12 +24,12 @@ const (
DefJdCategoryID4Jxgy = 22410 // 其他国产水果
)
func getDefJdCategoryID() int {
if beego.BConfig.RunMode == model.ServerTypeFruits {
return DefJdCategoryID4Jxgy
}
return DefJdCategoryID
}
//func getDefJdCategoryID() int {
// if beego.BConfig.RunMode == model.ServerTypeFruits {
// return DefJdCategoryID4Jxgy
// }
// return DefJdCategoryID
//}
func jdCat2Jx(jdCat *jdapi.CategoryInfo) (jxCat *partner.BareCategoryInfo) {
return &partner.BareCategoryInfo{
@@ -156,7 +156,6 @@ func skuInfo2Param(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (param *jd
TraceID: ctx.GetTrackInfo(),
OutSkuID: utils.Int2Str(sku.SkuID),
ShopCategories: []int64{},
CategoryID: sku.VendorVendorCatID,
BrandID: DefBrandID,
SkuName: utils.LimitUTF8StringLen(sku.SkuName, jdapi.MaxSkuNameCharCount),
SkuPrice: int(sku.Price),
@@ -176,9 +175,22 @@ func skuInfo2Param(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (param *jd
param.Images = jxutils.BatchString2Slice(sku.Img, sku.Img2, sku.Img3, sku.Img4, sku.Img5)
}
if param.CategoryID == 0 {
param.CategoryID = int64(getDefJdCategoryID())
if sku.SkuVendorMapCatID != "" {
param.CategoryID = utils.Str2Int64(sku.SkuVendorMapCatID)
} else if sku.VendorVendorCatID != 0 {
param.CategoryID = sku.VendorVendorCatID
dao.ExecuteSQL(dao.GetDB(), ` UPDATE sku_vendor_category_map SET vendor_category_id = ? WHERE name_id = ? AND vendor_id = ? `, []interface{}{sku.VendorVendorCatID, sku.NameID, sku.VendorID}...)
dao.ExecuteSQL(dao.GetDB(), ` UPDATE sku_name SET jd_category_id = ? WHERE id = ? `, []interface{}{sku.VendorVendorCatID, sku.NameID})
} else {
recommendCategory, _ := getAPI(sku.VendorOrgCode).GetSkuCategoryBySkuName(param.SkuName)
if recommendCategory != nil && recommendCategory.CategoryId != model.NO {
param.CategoryID = int64(recommendCategory.CategoryId)
dao.ExecuteSQL(dao.GetDB(), ` UPDATE sku_vendor_category_map SET vendor_category_id = ? WHERE name_id = ? AND vendor_id = ? `, []interface{}{recommendCategory.CategoryId, sku.NameID, sku.VendorID}...)
dao.ExecuteSQL(dao.GetDB(), ` UPDATE sku_category SET jd_category_id = ? WHERE id = ? `, []interface{}{recommendCategory.CategoryId, sku.LocalCategoryId}...)
dao.ExecuteSQL(dao.GetDB(), ` UPDATE sku_name SET jd_category_id = ? WHERE id = ? `, []interface{}{recommendCategory.CategoryId, sku.NameID})
}
}
// 京东强制要求upc的商品如果没有设置upc自动生成一个假的
if param.Upc == "" && isSkuMustHaveUpc(sku.Unit, param.CategoryID) {
param.Upc = jxutils.GenFakeUPC(sku.SkuID)