fix(search): 修复跨租户重复手机号查询报错

This commit is contained in:
yml
2026-11-29 20:07:57 +08:00
parent 2e0018b943
commit a1e6089aa5
15 changed files with 382 additions and 28 deletions
@@ -1151,7 +1151,7 @@ func (r *Repository) ListOrders(ctx context.Context, query DistributionOrderList
if strings.TrimSpace(query.Keyword) != "" {
keyword := strings.TrimSpace(query.Keyword)
if isPhoneKeyword(keyword) {
base = base.Where("ro.renter_id = (SELECT id FROM users WHERE phone = ?)", keyword)
base = base.Where("ro.renter_id IN (SELECT id FROM users WHERE phone = ?)", keyword)
} else {
kw := "%" + keyword + "%"
base = base.Where("(ro.order_no LIKE ? OR rl.listing_no LIKE ? OR ga.title LIKE ? OR u.phone LIKE ?)", kw, kw, kw, kw)
@@ -3055,7 +3055,7 @@ func (r *Repository) ListReceivedListings(ctx context.Context, adminID, siteID u
if q.Keyword != "" {
keyword := strings.TrimSpace(q.Keyword)
if isPhoneKeyword(keyword) {
base = base.Where("rl.owner_id = (SELECT id FROM users WHERE phone = ?)", keyword)
base = base.Where("rl.owner_id IN (SELECT id FROM users WHERE phone = ?)", keyword)
} else {
kw := "%" + keyword + "%"
base = base.Where("(rl.listing_no LIKE ? OR ga.title LIKE ? OR u.phone LIKE ? OR u.nickname LIKE ?)", kw, kw, kw, kw)