feat(admin): 订单页筛选改版并支持用户与商品模糊搜索

收起次要筛选项,去掉过滤测试;列表可按用户编号/昵称/备注/手机与商品名称/规格查询。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 13:10:36 +08:00
parent fccfd7abbe
commit b226af2adc
5 changed files with 223 additions and 109 deletions
@@ -30,6 +30,8 @@ type OrderFilterInput = Pick<
| 'status'
| 'orderType'
| 'userId'
| 'userKeyword'
| 'productKeyword'
| 'cityId'
| 'receiverPhone'
| 'fulfillmentHold'
@@ -177,8 +179,28 @@ export class AdminOrdersService {
}
if (query.orderType) where.orderType = query.orderType as Prisma.EnumOrderTypeFilter['equals'];
if (query.userId) where.userId = BigInt(query.userId);
const userKeyword = query.userKeyword?.trim();
if (userKeyword) {
const userOr: Prisma.UserWhereInput[] = [
{ userNo: { contains: userKeyword } },
{ nickname: { contains: userKeyword } },
{ hqRemark: { contains: userKeyword } },
{ phone: { contains: userKeyword } },
];
if (/^\d+$/.test(userKeyword)) {
userOr.push({ id: BigInt(userKeyword) });
}
where.user = { OR: userOr };
}
if (query.cityId) where.cityId = BigInt(query.cityId);
if (query.receiverPhone) where.receiverPhone = { contains: query.receiverPhone };
const productKeyword = query.productKeyword?.trim();
if (productKeyword) {
where.OR = [
{ productName: { contains: productKeyword } },
{ productSpec: { contains: productKeyword } },
];
}
if (query.deliveryType) {
where.deliveryType = query.deliveryType as Prisma.EnumDeliveryTypeFilter['equals'];
}
@@ -93,6 +93,16 @@ export class AdminOrdersQueryDto extends PaginationQueryDto {
@IsString()
userId?: string;
/** 用户编号 / 昵称 / 备注 / 手机 模糊匹配 */
@IsOptional()
@IsString()
userKeyword?: string;
/** 商品名称 / 规格 模糊匹配 */
@IsOptional()
@IsString()
productKeyword?: string;
@IsOptional()
@IsString()
cityId?: string;
@@ -159,6 +169,14 @@ export class AdminOrdersExportDto {
@IsString()
cityId?: string;
@IsOptional()
@IsString()
userKeyword?: string;
@IsOptional()
@IsString()
productKeyword?: string;
@IsOptional()
@IsString()
receiverPhone?: string;