- fix GetStores search by mobile

This commit is contained in:
gazebo
2018-11-02 22:59:42 +08:00
parent 57ad34bb19
commit cf10eb777e

View File

@@ -131,11 +131,12 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil { if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
if jxutils.IsLegalMobileNumber(keywordInt64) { if jxutils.IsLegalMobileNumber(keywordInt64) {
sql += ` sql += `
LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.tel = ? LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ?
LEFT JOIN weixins wx2 ON wx2.parentid = wx1.id AND wx2.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) sqlParams = append(sqlParams, keywordInt64, keywordInt64)
sqlWhere += " OR wx1.id IS NOT NULL OR wx2.id IS NOT NULL" sqlWhere += " OR wx1.id IS NOT NULL OR wx3.id IS NOT NULL"
} }
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?" sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64) sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)