- keyword doesn't search store address but want search owner's mobile.

This commit is contained in:
gazebo
2018-10-30 16:40:55 +08:00
parent 8313a52d49
commit 1bdb67864d
3 changed files with 15 additions and 3 deletions

View File

@@ -123,10 +123,18 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
}
if keyword != "" {
keywordLike := "%" + keyword + "%"
sqlWhere += " AND (t1.name LIKE ? OR t1.address LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.last_operator LIKE ? OR city.name LIKE ? OR m1.vendor_store_id LIKE ? OR m2.vendor_store_id LIKE ?"
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
sqlWhere += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.last_operator LIKE ? OR city.name LIKE ? OR m1.vendor_store_id LIKE ? OR m2.vendor_store_id LIKE ?"
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
if jxutils.IsLegalMobileNumber(keywordInt64) {
sql += `
LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.tel = ?
LEFT JOIN weixins wx2 ON wx2.parentid = wx1.id AND wx2.tel = ?
`
sqlParams = append(sqlParams, keywordInt64, keywordInt64)
sqlWhere += " OR wx1.id IS NOT NULL OR wx2.id IS NOT NULL"
}
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.lng = ? OR t1.lat = ?"
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64, keywordInt64)
}

View File

@@ -343,3 +343,7 @@ func MakeValidationMapFromSlice(validValues []string, flag int) map[string]int {
func ComposeQiniuResURL(key string) string {
return "http://image.jxc4.com/" + key
}
func IsLegalMobileNumber(num int64) bool {
return num >= 13000000000 && num <= 19999999999
}

View File

@@ -2,7 +2,7 @@ package legacymodel
type WeiXins struct {
ID int `orm:"column(id)" json:"id"`
JxStoreID int `orm:"column(jxstoreid)" json:"storeID"`
JxStoreID int `orm:"column(jxstoreid);index" json:"storeID"`
OpenID string `orm:"column(openid);size(70);unique;null" json:"openID"`
Tel string `orm:"size(15);unique" json:"tel"`
ParentID int `orm:"column(parentid);default(-1)" json:"parentID"`