- store search bug fix (vendor store)

This commit is contained in:
gazebo
2018-11-27 11:44:51 +08:00
parent 4fbfcdb13e
commit dde8bc9d20
2 changed files with 10 additions and 3 deletions

View File

@@ -131,8 +131,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
}
if keyword != "" {
keywordLike := "%" + keyword + "%"
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)
sqlWhere += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.last_operator LIKE ? OR city.name LIKE ?"
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
if jxutils.IsLegalMobileNumber(keywordInt64) {
@@ -146,6 +146,13 @@ 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 {
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
`
sqlWhereParams = append(sqlWhereParams, utils.DefaultTimeValue, keywordInt64, utils.DefaultTimeValue, keywordInt64)
}
}
sqlWhere += ")"
}

View File

@@ -5,7 +5,7 @@ type WeiXins struct {
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"`
ParentID int `orm:"column(parentid);default(-1);index" json:"parentID"`
NickName string `orm:"column(nickname);size(30)" json:"nickname"`
}