From b16712a930c7a7bf8fda5a0be9d2b47f3445860b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 8 Nov 2024 11:41:39 +0800 Subject: [PATCH] 1 --- business/jxstore/misc/misc.go | 2 +- business/model/dao/sku.go | 1 + business/model/dao/store_sku.go | 2 +- business/partner/purchase/jd/sku2.go | 32 +++++++++++++++++++--------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index f843a929e..bb627275e 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -280,7 +280,7 @@ func Init() { orderman.UpdateJdsOrdersStatus(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -1), time.Now()) }, 5*time.Second, 5*time.Minute) - if beego.BConfig.RunMode == "020c0aa40371cd112eecc034bb3dc094907ff925" { + if beego.BConfig.RunMode == model.ServerTypeFruits || beego.BConfig.RunMode == model.ServerTypePet { ScheduleTimerFuncByInterval(func() { fromData := utils.Time2Date(time.Now()) toData := time.Now() diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index 5b6316a4f..8d37f73cb 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -333,6 +333,7 @@ func GetSkusWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, nameIDs IF(t11.resource_type IS NULL OR t11.resource_type <> ?, t2.img, '') img, IF(t12.resource_type IS NULL OR t12.resource_type <> ?, t2.img2, '') img2, t2.desc_img, + t2.category_id local_category_id, t3.jd_category_id vendor_vendor_cat_id, tsu.ex_prefix, tsu.begin_at ex_prefix_begin, tsu.end_at ex_prefix_end, tsu.img_watermark, t3m.sync_status cat_sync_status, diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 8971bea01..79132d9dd 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -114,7 +114,7 @@ type StoreSkuSyncInfo struct { YbBarCode string //银豹的商品条码 JdsStockSwitch int PreparationTime int - + LocalCategoryId int `orm:"column(local_category_id)"` // 平台相关的图片信息 Img string Img2 string diff --git a/business/partner/purchase/jd/sku2.go b/business/partner/purchase/jd/sku2.go index 21636144f..57bbfba16 100644 --- a/business/partner/purchase/jd/sku2.go +++ b/business/partner/purchase/jd/sku2.go @@ -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)