perf(query): 优化后台手机号精确查询

This commit is contained in:
yml2213
2026-11-02 18:28:12 +08:00
parent 9c379b7e0c
commit 599e22331d
17 changed files with 254 additions and 62 deletions
@@ -911,6 +911,17 @@ func TestDistributionReceivedListingsAndWallet(t *testing.T) {
if recPage.Total != 1 || len(recPage.Items) != 1 {
t.Fatalf("expected 1 received listing, got %d", recPage.Total)
}
phonePage, err := repo.ListReceivedListings(t.Context(), 0, site.ID, ReceivedListingQuery{
Page: 1,
PageSize: 10,
Keyword: user.Phone,
})
if err != nil {
t.Fatalf("ListReceivedListings by phone failed: %v", err)
}
if phonePage.Total != 1 || phonePage.Items[0].ListingID != listing.ID {
t.Fatalf("expected listing %d by phone, got total=%d items=%+v", listing.ID, phonePage.Total, phonePage.Items)
}
item := recPage.Items[0]
if item.ListingNo != "RL-99001" || item.GameName != "delta_force" || item.OwnerNickname != "seller01" {
t.Fatalf("unexpected received listing: %+v", item)
@@ -1804,6 +1815,18 @@ func TestListOrdersPerformanceAndScoping(t *testing.T) {
if len(allPage.Items) != 2 {
t.Fatalf("expected 2 items, got %d", len(allPage.Items))
}
phonePage, err := repo.ListOrders(t.Context(), DistributionOrderListQuery{
SiteID: 0,
Page: 1,
Size: 10,
Keyword: u.Phone,
})
if err != nil {
t.Fatalf("ListOrders by phone failed: %v", err)
}
if phonePage.Total != 2 {
t.Fatalf("expected 2 distribution orders by renter phone, got %d", phonePage.Total)
}
// B. 分销商1查询其订单 (SiteID = site1.ID)
// 预期:只查出 distOrder1