diff --git a/business/authz/authz.go b/business/authz/authz.go index 247b3e4cb..b6ec6406a 100644 --- a/business/authz/authz.go +++ b/business/authz/authz.go @@ -47,6 +47,8 @@ func (r *RoleInfo) GetFullName() (fullRoleName string) { } if r.StoreID > 0 { strList = append(strList, StoreRolePrefix, utils.Int2Str(r.StoreID)) + } else if r.StoreID != 0 { + strList = append(strList, StoreRolePrefix, "") } fullRoleName = strings.Join(strList, RoleNameSep) return fullRoleName diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 0a63ad7ff..ebcefd970 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -42,6 +42,7 @@ type StoreExt struct { MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名 OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名 + OperatorName2 string `orm:"size(8)" json:"operatorName2"` // 非京东运营人姓名 FloatLng float64 `json:"lng"` FloatLat float64 `json:"lat"` @@ -120,6 +121,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte */ LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone AND mm.deleted_at = ? LEFT JOIN user om ON om.mobile <> '' AND om.mobile = t1.operator_phone AND om.deleted_at = ? + LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = t1.operator_phone2 AND om2.deleted_at = ? ` sqlFromParams = []interface{}{ utils.DefaultTimeValue, @@ -128,6 +130,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte // utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue, + utils.DefaultTimeValue, } sqlWhere := ` WHERE t1.deleted_at = ? @@ -174,20 +177,21 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte } if keyword != "" { keywordLike := "%" + keyword + "%" - sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.market_man_phone LIKE ? + sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.operator_phone2 LIKE ? OR t1.market_man_phone LIKE ? OR t1.last_operator LIKE ? OR city.name LIKE ? OR t1.address LIKE ? OR t1.printer_sn LIKE ? OR t1.licence_code LIKE ? OR t1.id_code LIKE ?` - sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike) + sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, + keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike) if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil { - // if !globals.DisableWXAuth1 && jxutils.IsLegalMobileNumber(keywordInt64) { - // sql += ` - // LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ? - // LEFT JOIN weixins wx2 ON t1.id = wx2.jxstoreid AND wx2.parentid = -1 - // LEFT JOIN weixins wx3 ON wx3.parentid = wx2.id AND wx3.tel = ? - // ` - // sqlParams = append(sqlParams, keywordInt64, keywordInt64) - // sqlWhere += " OR wx1.id IS NOT NULL OR wx3.id IS NOT NULL" - // } + if true { // jxutils.IsLegalMobileNumber(keywordInt64) { + sqlWhere += ` OR ( + SELECT COUNT(*) + FROM casbin_rule t11 + JOIN user t12 ON t12.user_id = t11.v0 AND t12.mobile LIKE ? + WHERE t11.v1 <> '' AND (t11.v1 = CONCAT(?, t1.id) OR t11.v1 = t1.market_man_role OR t11.v1 = t1.operator_role OR t11.v1 = t1.operator_role2) + ) > 0` + sqlWhereParams = append(sqlWhereParams, keyword+"%", autils.NewStoreBossRole(-1).GetFullName()) // 必须要前缀,不然不能用过些会很慢 + } sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?" sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64) if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown { @@ -195,7 +199,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte 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 ` - sqlWhereParams = append(sqlWhereParams, utils.DefaultTimeValue, keywordInt64, utils.DefaultTimeValue, keywordInt64) + sqlWhereParams = append(sqlWhereParams, utils.DefaultTimeValue, keyword, utils.DefaultTimeValue, keyword) } } sqlWhere += ")" @@ -308,6 +312,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, bank.value payee_bank_name, IF(om.name <> '', om.name, om.user_id2) operator_name, + IF(om2.name <> '', om2.name, om2.user_id2) operator_name2, province.code province_code, province.name province_name, city.name city_name, @@ -323,6 +328,9 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) mapLimit := false + // globals.SugarLogger.Debug(sql) + // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) + if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { // 地图区域限制过滤 if mapLongitude2, ok := params["mapLongitude"].(string); ok { @@ -1546,7 +1554,7 @@ func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store } // 直接电话信息相关人员 - for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone} { + for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone, store.OperatorPhone2} { if mobile != "" { if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil { if userMap[user.GetID()] == 0 { diff --git a/business/model/casbin_rule.go b/business/model/casbin_rule.go index b0913f95a..2dcdffcaf 100644 --- a/business/model/casbin_rule.go +++ b/business/model/casbin_rule.go @@ -3,8 +3,8 @@ package model type CasbinRule struct { ID int `orm:"column(id)" json:"id"` PType string - V0 string - V1 string + V0 string `orm:"index"` + V1 string `orm:"index"` V2 string V3 string V4 string diff --git a/business/model/dao/dao_user2.go b/business/model/dao/dao_user2.go index a015ec9cb..009ab8f40 100644 --- a/business/model/dao/dao_user2.go +++ b/business/model/dao/dao_user2.go @@ -99,7 +99,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityN FROM ( SELECT * FROM store t1 - WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?) + WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?) UNION DISTINCT SELECT t1.* FROM store t1 @@ -111,6 +111,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityN WHERE t1.deleted_at = ? ORDER BY t1.name` sqlParams := []interface{}{ + mobile, mobile, mobile, mobile, @@ -132,8 +133,8 @@ func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList utils.DefaultTimeValue, } if mobile != "" { - sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?" - sqlParams = append(sqlParams, mobile, mobile) + sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?" + sqlParams = append(sqlParams, mobile, mobile, mobile) } if len(shortRoleNameList) > 0 { questionMarks := GenQuestionMarks(len(shortRoleNameList)) diff --git a/business/model/store.go b/business/model/store.go index 2fb4c0819..d6dfce14b 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -301,7 +301,9 @@ type Store struct { // OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名 OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 运营人电话 OperatorRole string `orm:"size(32)" json:"operatorRole"` // 京东运营人组(角色) - OperatorRole2 string `orm:"size(32)" json:"operatorRole2"` // 非京东运营人组(角色) + + OperatorPhone2 string `orm:"size(16)" json:"operatorPhone2"` // 非京东运营人电话 + OperatorRole2 string `orm:"size(32)" json:"operatorRole2"` // 非京东运营人组(角色) } func (*Store) TableUnique() [][]string {