From 94bce18432a0b5e499f617c4d830c23596574815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 17 Feb 2020 16:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A5=BF=E9=B2=9C=E8=BE=BE=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sku.go | 16 ++++++++----- business/jxstore/cms/sync_store_sku.go | 5 ++++ business/model/const.go | 5 ++++ business/model/sku.go | 5 ++-- business/partner/purchase/ebai/store_sku2.go | 24 ++++++++------------ 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index 040557d08..e1921af72 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -132,9 +132,11 @@ func AddCategory(ctx *jxcontext.Context, cat *model.SkuCategory, userName string dao.Rollback(db) return nil, err } - if err = OnCreateThing(ctx, db, nil, int64(cat.ID), model.ThingTypeCategory); err != nil { - dao.Rollback(db) - return nil, err + if cat.IsExdSpec == model.NO { + if err = OnCreateThing(ctx, db, nil, int64(cat.ID), model.ThingTypeCategory); err != nil { + dao.Rollback(db) + return nil, err + } } dao.Commit(db) outCat = cat @@ -191,9 +193,11 @@ func UpdateCategory(ctx *jxcontext.Context, categoryID int, payload map[string]i dao.Rollback(db) return 0, err } - if err = OnUpdateThing(ctx, db, nil, int64(categoryID), model.ThingTypeCategory); err != nil { - dao.Rollback(db) - return 0, err + if cat.IsExdSpec == model.NO { + if err = OnUpdateThing(ctx, db, nil, int64(categoryID), model.ThingTypeCategory); err != nil { + dao.Rollback(db) + return 0, err + } } dao.Commit(db) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 7b7b8f82f..df46cea91 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -84,6 +84,11 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo storeCatMap := &model.StoreSkuCategoryMap{} storeCatMap.ID = catInfo.MapID var failedList []*partner.StoreSkuInfoWithErr + if catInfo.IsExdSpec == model.YES { + if vendorID == model.VendorIDJD || vendorID == model.VendorIDMTWM { + return nil, err + } + } if model.IsSyncStatusDelete(catInfo.CatSyncStatus) { // 删除 if model.IsSyncStatusDelete(catInfo.CatSyncStatus) && !dao.IsVendorThingIDEmpty(catInfo.VendorCatID) { err = handler.DeleteStoreCategory(ctx, storeID, vendorStoreID, catInfo.VendorCatID, level) diff --git a/business/model/const.go b/business/model/const.go index b524bf37f..228d6eb79 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -395,6 +395,11 @@ const ( MaxVendorPricePercentage = 400 ) +const ( + YES = 1 //通用 + NO = 0 +) + func IsPurchaseVendorExist(vendorID int) bool { _, ok := VendorNames[vendorID] return ok && vendorID >= VendorIDPurchaseBegin && vendorID <= VendorIDPurchaseEnd diff --git a/business/model/sku.go b/business/model/sku.go index aeadb11d8..d323a9a38 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -151,8 +151,9 @@ type SkuCategory struct { Status int8 `orm:"default(1)" json:"status"` //分类状态,0表示禁用,1表示启用 Img string `orm:"size(512)" json:"img"` //分类图片 - ExdName string `json:"exdName"` //饿鲜达对应分类名 - ExdSeq int `json:"exdSeq"` + ExdName string `json:"exdName"` //饿鲜达对应分类名 + ExdSeq int `json:"exdSeq"` + IsExdSpec int `json:"isExdSpec"` //是否是饿鲜达特有新建的分类 // JdID int64 `orm:"column(jd_id);index" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID // JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"` } diff --git a/business/partner/purchase/ebai/store_sku2.go b/business/partner/purchase/ebai/store_sku2.go index dadf35cea..11645dbc5 100644 --- a/business/partner/purchase/ebai/store_sku2.go +++ b/business/partner/purchase/ebai/store_sku2.go @@ -24,8 +24,9 @@ const ( var ( sensitiveWordRegexp = regexp.MustCompile(`商品名称中含有敏感词(\[.*\])`) - categoryCheck = map[string]string{ - "赠品专区": "赠品专区", + categoryCheck = map[int]string{ + 175: "赠品专区", + 18: "烧烤吧台", } ) @@ -80,10 +81,9 @@ func getCheckExdStoreNameAndSeq(storeID int, storeCat *dao.SkuStoreCatInfo) (nam return storeCat.Name, storeCat.Seq, false } if strings.Contains(store.Name, model.ExdStoreName) { - if categoryCheck[storeCat.ExdName] != "" { + if categoryCheck[storeCat.ID] != "" { return storeCat.ExdName, storeCat.ExdSeq, true } - return storeCat.ExdName, storeCat.ExdSeq, false } else { return storeCat.Name, storeCat.Seq, false } @@ -93,11 +93,9 @@ func getCheckExdStoreNameAndSeq(storeID int, storeCat *dao.SkuStoreCatInfo) (nam func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { var vendorCatID int64 if globals.EnableEbaiStoreWrite { - catName, catSeq, _ := getCheckExdStoreNameAndSeq(storeID, storeCat) - // if isCheck { - // return nil - // } - vendorCatID, err = api.EbaiAPI.ShopCategoryCreate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.ParentVendorCatID, 0), formatCatName(catName), jxCatSeq2Ebai(catSeq)) + if catName, catSeq, isCheck := getCheckExdStoreNameAndSeq(storeID, storeCat); !isCheck { + vendorCatID, err = api.EbaiAPI.ShopCategoryCreate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.ParentVendorCatID, 0), formatCatName(catName), jxCatSeq2Ebai(catSeq)) + } } else { vendorCatID = jxutils.GenFakeID() } @@ -107,11 +105,9 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { if globals.EnableEbaiStoreWrite { - catName, catSeq, _ := getCheckExdStoreNameAndSeq(storeID, storeCat) - // if isCheck { - // return nil - // } - err = api.EbaiAPI.ShopCategoryUpdate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.VendorCatID, 0), formatCatName(catName), jxCatSeq2Ebai(catSeq)) + if catName, catSeq, isCheck := getCheckExdStoreNameAndSeq(storeID, storeCat); !isCheck { + err = api.EbaiAPI.ShopCategoryUpdate(utils.Int2Str(storeID), utils.Str2Int64WithDefault(storeCat.VendorCatID, 0), formatCatName(catName), jxCatSeq2Ebai(catSeq)) + } // todo, 饿百将一个分类重复改名,也会报分类名重复错,特殊处理一下,不过因为GetStoreCategory其实会拉取所有的门店分类,是比较耗时的操作 if utils.IsErrMatch(err, "1", []string{"分类名称已经存在"}) { if cat, err2 := p.GetStoreCategory(ctx, storeID, vendorStoreID, storeCat.Name); err2 == nil {