From d9ae3e686113ece5f8dae121051eb1da5a199b26 Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 30 Mar 2019 10:11:53 +0800 Subject: [PATCH] - GuessVendorIDFromVendorStoreID --- business/jxstore/cms/store.go | 2 +- business/jxutils/jxutils_cms.go | 16 ++++++++++++++++ business/model/const.go | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 578570358..e35c2e476 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -161,7 +161,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa } sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?" sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64) - if keywordInt64 > 2000000 { + if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown { sqlWhere += ` OR (SELECT COUNT(*) FROM store_map tsm WHERE t1.id = tsm.store_id AND tsm.deleted_at = ? AND tsm.vendor_store_id = ?) > 0 OR (SELECT COUNT(*) FROM store_courier_map tsm WHERE t1.id = tsm.store_id AND tsm.deleted_at = ? AND tsm.vendor_store_id = ?) > 0 diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 058164407..409c38e89 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -284,3 +284,19 @@ func DownloadFileByURL(fileURL string) (bodyData []byte, fileMD5 string, err err func GenPicFileName(suffix string) string { return fmt.Sprintf("%x%s", md5.Sum([]byte(utils.GetUUID()+suffix)), suffix) } + +func GuessVendorIDFromVendorStoreID(vendorStoreID int64) (vendorID int) { + vendorID = model.VendorIDUnknown + if vendorStoreID > 10040008 && vendorStoreID < 98765432 { // 京东11733065,8位 + vendorID = model.VendorIDJD + } else if vendorStoreID > 1234567 && vendorStoreID < 9876543 { // 美团外卖 2461713,7位 + vendorID = model.VendorIDMTWM + } else if vendorStoreID > 1234567890 && vendorStoreID < 9987654321 { // 饿百 2167002607,10位 + vendorID = model.VendorIDEBAI + } else if vendorStoreID > 123456789 && vendorStoreID < 987654321 { // 微盟微商城 132091048,9位 + vendorID = model.VendorIDWSC + } else if vendorStoreID > 123456 && vendorStoreID < 654321 { // 京西门店ID,6位 + vendorID = model.VendorIDJX + } + return vendorID +} diff --git a/business/model/const.go b/business/model/const.go index acbc84fdb..6616b978e 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -8,6 +8,7 @@ const ( VendorIDMTWM = 1 VendorIDELM = 2 VendorIDEBAI = 3 + VendorIDJX = 9 // 这是一个假的京西VendorID VendorIDWSC = 11 // 微盟微商城 VendorIDPurchaseEnd = 11