fix(search): 修复跨租户重复手机号查询报错
This commit is contained in:
@@ -234,7 +234,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
||||
}
|
||||
|
||||
if phoneKeyword = strings.TrimSpace(phoneKeyword); isPhoneKeyword(phoneKeyword) {
|
||||
withdrawal = withdrawal.Where("wr.user_id = (SELECT id FROM users WHERE phone = ?)", phoneKeyword)
|
||||
withdrawal = withdrawal.Where("wr.user_id IN (SELECT id FROM users WHERE phone = ?)", phoneKeyword)
|
||||
return db.Table("(?) AS d", withdrawal)
|
||||
}
|
||||
|
||||
@@ -298,8 +298,8 @@ func (r *Repository) applyDisbursementFilters(db *gorm.DB, query DisbursementQue
|
||||
if query.Keyword != "" {
|
||||
keyword := strings.TrimSpace(query.Keyword)
|
||||
if isPhoneKeyword(keyword) {
|
||||
// 完整手机号只可能命中提现收款人,先经 users(phone) 唯一索引解析用户。
|
||||
db = db.Where("d.source_type = ? AND d.user_id = (SELECT id FROM users WHERE phone = ?)", "withdrawal", keyword)
|
||||
// 完整手机号只匹配提现收款人,先查询该手机号对应的所有租户和站点账号。
|
||||
db = db.Where("d.source_type = ? AND d.user_id IN (SELECT id FROM users WHERE phone = ?)", "withdrawal", keyword)
|
||||
} else {
|
||||
like := "%" + keyword + "%"
|
||||
db = db.Where(`(d.business_no LIKE ? OR d.payee_name LIKE ? OR d.payee_phone LIKE ?
|
||||
|
||||
Reference in New Issue
Block a user