From e6a2040027f485ae5223be589cda621a656e3366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 Jan 2021 09:40:40 +0800 Subject: [PATCH 1/9] aa --- business/model/dao/sku.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index 35da21905..04f1efe34 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -108,12 +108,12 @@ func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int, eclpIDs []string } if len(catIDs) > 0 { sql += ` - JOIN sku_category t3 ON t3.id = t2.category_id - LEFT JOIN sku_category t3p ON t3p.id = t3.parent_id + JOIN sku_category t3 ON t3.id = t2.category_id AND t3.is_exd_spec = ? + LEFT JOIN sku_category t3p ON t3p.id = t3.parent_id AND t3p.is_exd_spec = ? ` sqlWhere += " AND (t3.id IN (" + GenQuestionMarks(len(catIDs)) + ")" sqlWhere += " OR t3p.id IN (" + GenQuestionMarks(len(catIDs)) + ") )" - sqlParams = append(sqlParams, catIDs, catIDs) + sqlParams = append(sqlParams, model.NO, model.NO, catIDs, catIDs) } if len(eclpIDs) > 0 { sqlWhere += " AND t1.eclp_id IN (" + GenQuestionMarks(len(eclpIDs)) + ")" From 24bdadb1db11b8d722f0a696ec11abf22b6f4fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 Jan 2021 10:24:55 +0800 Subject: [PATCH 2/9] aa --- business/model/dao/sku.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index 04f1efe34..19ce985a3 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -113,6 +113,7 @@ func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int, eclpIDs []string ` sqlWhere += " AND (t3.id IN (" + GenQuestionMarks(len(catIDs)) + ")" sqlWhere += " OR t3p.id IN (" + GenQuestionMarks(len(catIDs)) + ") )" + sqlWhere += " AND t1.exd_sku_id = ''" sqlParams = append(sqlParams, model.NO, model.NO, catIDs, catIDs) } if len(eclpIDs) > 0 { From d2955b2a2f595cc128ec033d141b458714b24ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 Jan 2021 14:15:35 +0800 Subject: [PATCH 3/9] aa --- business/jxstore/cms/sku.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index b34c2aff5..a110d2748 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -752,12 +752,12 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric return skuNamesInfo, err } -func CheckHasSensitiveWord(word string) (bool, error) { +func CheckHasSensitiveWord(word string) (bool, string) { if hasSensitiveWord, sensitiveWord := IsSensitiveWordInList(word); hasSensitiveWord { - return true, errors.New(fmt.Sprintf("不能包含敏感词:[%s]", sensitiveWord)) + return true, sensitiveWord } - return false, nil + return false, "" } func IsSensitiveWordInList(str string) (bool, string) { @@ -802,8 +802,8 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s } skuNameExt.Name = utils.TrimBlankChar(skuNameExt.Name) - if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord { - return nil, err + if hasSensitiveWord, word := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord { + skuNameExt.Name = strings.ReplaceAll(skuNameExt.Name, word, "") } upc := utils.Pointer2String(skuNameExt.Upc) if upc == "" { @@ -946,10 +946,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf var beforSkuName = *skuName if payload["name"] != nil { newSkuName := utils.TrimBlankChar(utils.Interface2String(payload["name"])) - if hasSensitiveWord, err := CheckHasSensitiveWord(newSkuName); hasSensitiveWord { - return 0, err + if hasSensitiveWord, word := CheckHasSensitiveWord(newSkuName); hasSensitiveWord { + payload["name"] = strings.ReplaceAll(payload["name"].(string), word, "") + } else { + payload["name"] = newSkuName } - payload["name"] = newSkuName } delete(payload, "isSpu") From e38ab5104d89bf2db05cc4a0d39b58a2619c2870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 Jan 2021 15:26:01 +0800 Subject: [PATCH 4/9] aa --- business/partner/purchase/ebai/store.go | 11 +++++++++-- business/partner/purchase/jd/store.go | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index 17e01b310..ceb0a7dc6 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -30,6 +30,7 @@ type tEbaiStoreInfo struct { CityID int `orm:"column(city_id)"` DistrictID int `orm:"column(district_id)"` VendorStoreName string + BrandName string } func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) { @@ -151,9 +152,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin SELECT t1.*, t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code, - IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name + IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name, + t3.name brand_name FROM store t1 JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) + LEFT JOIN brand t3 ON t3.id = t1.brand_id WHERE t1.id = ? ORDER BY t2.updated_at ` @@ -398,7 +401,11 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} { if store.VendorStoreName != "" { params["name"] = store.VendorStoreName } else { - params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) + if store.BrandID != 1 { + params["name"] = store.Name + } else { + params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) + } } } boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee) diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 9b7182995..2e9b4b23c 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -33,6 +33,7 @@ type tJdStoreInfo struct { RealLastOperator string SyncStatus int VendorStoreName string + BrandName string } var ( @@ -127,9 +128,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, - t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name + t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name, + t3.name brand_name FROM store t1 JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) + LEFT JOIN brand t3 ON t3.id = t1.brand_id LEFT JOIN place city ON t1.city_code = city.code LEFT JOIN place district ON t1.district_code = district.code WHERE t1.id = ? @@ -159,7 +162,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin if store.VendorStoreName != "" { storeParams.StationName = store.VendorStoreName } else { - storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) + if store.BrandID != 1 { + storeParams.StationName = store.Name + } else { + storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) + } } storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen) } From 61c44e257dfc31f0a2cffb8de5a620fe06cdcebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 Jan 2021 17:58:50 +0800 Subject: [PATCH 5/9] aa --- business/model/dao/permission.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/business/model/dao/permission.go b/business/model/dao/permission.go index 4c0fbc6ae..94d4fc989 100644 --- a/business/model/dao/permission.go +++ b/business/model/dao/permission.go @@ -29,6 +29,7 @@ func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.M sql += " AND a.level = ?" sqlParams = append(sqlParams, level) } + sql += " ORDER BY a.id" err = GetRows(db, &menus, sql, sqlParams) return menus, err } @@ -42,6 +43,7 @@ func GetMenuWithUser(db *DaoDB, name string, level int, userID string) (menus [] JOIN role_menu c ON c.menu_id = a.id AND c.role_id = b.role_id AND c.deleted_at = ? WHERE a.deleted_at = ?)a JOIN menu b ON (b.id = a.id OR b.id = a.parent_id) + ORDER BY b.id ` sqlParams := []interface{}{userID, utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue} err = GetRows(db, &menus, sql, sqlParams) From a24754705a5667b7513b5527411513875dde2845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 28 Jan 2021 09:16:54 +0800 Subject: [PATCH 6/9] aa --- business/model/vendor_org_code.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/model/vendor_org_code.go b/business/model/vendor_org_code.go index 951e48014..24c12cf16 100644 --- a/business/model/vendor_org_code.go +++ b/business/model/vendor_org_code.go @@ -8,5 +8,6 @@ type VendorOrgCode struct { Comment string `json:"comment"` //备注 //appkey,secret token等 - IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 + Type string `json:"type"` //platform 普通平台, delivery 三方配送平台 + IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 } From 7deeb4fbd3c38b9ec7ccec2d5f5416ed6e8c49ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 28 Jan 2021 09:41:37 +0800 Subject: [PATCH 7/9] aa --- business/model/vendor_org_code.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/model/vendor_org_code.go b/business/model/vendor_org_code.go index 24c12cf16..222391989 100644 --- a/business/model/vendor_org_code.go +++ b/business/model/vendor_org_code.go @@ -10,4 +10,5 @@ type VendorOrgCode struct { Type string `json:"type"` //platform 普通平台, delivery 三方配送平台 IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 + IsOpen int `json:"isOpen"` //主要三方配送用,是否配送,默认0表示打开,1表示关 } From 599749191b50d6427f6cd1d033e1abcff2be79c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 28 Jan 2021 09:52:18 +0800 Subject: [PATCH 8/9] aa --- business/jxstore/common/common.go | 4 ++-- business/model/dao/common.go | 8 ++++++-- business/model/vendor_org_code.go | 11 ++++++++--- controllers/sys.go | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/business/jxstore/common/common.go b/business/jxstore/common/common.go index 7ba9e7a0b..3704bb470 100644 --- a/business/jxstore/common/common.go +++ b/business/jxstore/common/common.go @@ -231,6 +231,6 @@ func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius return storeList, err } -func GetVendorOrgCode(ctx *jxcontext.Context, vendorID int, vendorOrgCode string) (vendorOrgs []*model.VendorOrgCode, err error) { - return dao.GetVendorOrgCode(dao.GetDB(), vendorID, vendorOrgCode) +func GetVendorOrgCode(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorType string) (vendorOrgs []*model.VendorOrgCode, err error) { + return dao.GetVendorOrgCode(dao.GetDB(), vendorID, vendorOrgCode, vendorType) } diff --git a/business/model/dao/common.go b/business/model/dao/common.go index 188ff3e7f..32a235869 100644 --- a/business/model/dao/common.go +++ b/business/model/dao/common.go @@ -32,9 +32,9 @@ func GetNeedUploadDataResource(db *DaoDB) (dataResList []*model.DataResource, er return dataResList, err } -func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode string) (vendorOrgs []*model.VendorOrgCode, err error) { +func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode, vendorType string) (vendorOrgs []*model.VendorOrgCode, err error) { sql := ` - SELECT vendor_id, vendor_org_code, comment, is_jx_cat + SELECT vendor_id, vendor_org_code, comment, is_jx_cat, is_open FROM vendor_org_code WHERE deleted_at = ? ` @@ -47,6 +47,10 @@ func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode string) (vendorOrgs sql += " AND vendor_org_code = ?" sqlParams = append(sqlParams, vendorOrgCode) } + if vendorType != "" { + sql += " AND vendor_type = ?" + sqlParams = append(sqlParams, vendorType) + } err = GetRows(db, &vendorOrgs, sql, sqlParams) return vendorOrgs, err } diff --git a/business/model/vendor_org_code.go b/business/model/vendor_org_code.go index 222391989..c286b12e2 100644 --- a/business/model/vendor_org_code.go +++ b/business/model/vendor_org_code.go @@ -1,5 +1,10 @@ package model +const ( + VendorOrgTypePlatform = "platform" //外卖平台 + VendorOrgTypeDelivery = "delivery" //配送平台 +) + type VendorOrgCode struct { ModelIDCULD @@ -8,7 +13,7 @@ type VendorOrgCode struct { Comment string `json:"comment"` //备注 //appkey,secret token等 - Type string `json:"type"` //platform 普通平台, delivery 三方配送平台 - IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 - IsOpen int `json:"isOpen"` //主要三方配送用,是否配送,默认0表示打开,1表示关 + VendorType string `json:"vendorType"` //platform 普通平台, delivery 三方配送平台 + IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用 + IsOpen int `json:"isOpen"` //主要三方配送用,是否配送,默认0表示打开,1表示关 } diff --git a/controllers/sys.go b/controllers/sys.go index 28e6214a2..313aa34ac 100644 --- a/controllers/sys.go +++ b/controllers/sys.go @@ -137,7 +137,7 @@ func (c *SysController) GetEbaiRTFDetail() { // @router /GetVendorOrgCode [get] func (c *SysController) GetVendorOrgCode() { c.callGetVendorOrgCode(func(params *tSysGetVendorOrgCodeParams) (retVal interface{}, errCode string, err error) { - retVal, err = common.GetVendorOrgCode(params.Ctx, params.VendorID, params.VendorOrgCode) + retVal, err = common.GetVendorOrgCode(params.Ctx, params.VendorID, params.VendorOrgCode, model.VendorOrgTypePlatform) return retVal, "", err }) } From a32c7f7983fa9b5cf0a501bafef45d0a4ba1d516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 28 Jan 2021 10:01:13 +0800 Subject: [PATCH 9/9] aa --- business/partner/delivery/dada/waybill.go | 9 +++++++++ business/partner/delivery/fn/waybill.go | 10 ++++++++++ business/partner/delivery/mtps/waybill.go | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index 63995afb4..d305ef610 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -248,6 +248,15 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder) // IDeliveryPlatformHandler func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { db := dao.GetDB() + if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDDada, "", model.VendorOrgTypeDelivery); err == nil { + if len(vendorOrgCode) > 0 { + if vendorOrgCode[0].IsOpen == model.YES { + return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) + } + } + } else { + return nil, err + } billParams, err := c.getBillParams(db, order) if err == nil { if globals.EnableStoreWrite { diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index 84627b1d8..f22877e71 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -1,6 +1,7 @@ package fn import ( + "fmt" "strings" "time" @@ -66,6 +67,15 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee var ( db = dao.GetDB() ) + if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDFengNiao, "", model.VendorOrgTypeDelivery); err == nil { + if len(vendorOrgCode) > 0 { + if vendorOrgCode[0].IsOpen == model.YES { + return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) + } + } + } else { + return nil, err + } storeDetail, err := dao.GetStoreDetail(db, order.StoreID, order.VendorID, order.VendorOrgCode) deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db) if err == nil { diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index f7a300f6e..769896de5 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -191,6 +191,15 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf // IDeliveryPlatformHandler func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { db := dao.GetDB() + if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDMTPS, "", model.VendorOrgTypeDelivery); err == nil { + if len(vendorOrgCode) > 0 { + if vendorOrgCode[0].IsOpen == model.YES { + return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) + } + } + } else { + return nil, err + } deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db) if err == nil { if err = delivery.CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee, order, model.VendorIDMTPS); err != nil {