webadmin端订单修改

This commit is contained in:
2026-07-17 08:45:33 +08:00
parent ed44e88e93
commit c643b0b979
6 changed files with 448 additions and 130 deletions
@@ -30,6 +30,7 @@ export class AdminOrdersService {
if (query.orderNo) where.orderNo = { contains: query.orderNo };
if (query.status) where.status = query.status as Prisma.EnumOrderStatusFilter['equals'];
if (query.userId) where.userId = BigInt(query.userId);
if (query.cityId) where.cityId = BigInt(query.cityId);
if (query.receiverPhone) where.receiverPhone = { contains: query.receiverPhone };
if (query.createdFrom || query.createdTo) {
where.createdAt = {};
@@ -46,6 +47,8 @@ export class AdminOrdersService {
include: {
user: { select: { id: true, userNo: true, phone: true, nickname: true } },
delivery: { select: { provider: true, trackingNo: true, providerOrderNo: true } },
city: { select: { id: true, name: true, code: true } },
fulfillmentWarehouse: { select: { id: true, name: true } },
},
}),
this.prisma.order.count({ where }),
@@ -75,6 +78,18 @@ export class AdminOrdersService {
city: { select: { id: true, name: true, code: true } },
product: { select: { id: true, name: true, skuCode: true, barcode69: true } },
imageResource: { select: { id: true, url: true } },
fulfillmentWarehouse: {
select: {
id: true,
name: true,
contactName: true,
contactPhone: true,
address: true,
lng: true,
lat: true,
fulfillmentMode: true,
},
},
},
});
if (!order) throw new NotFoundException('订单不存在');
@@ -101,7 +116,7 @@ export class AdminOrdersService {
throw new BadRequestException('暂仅支持小飞侠配送');
}
const order = await this.prisma.order.findUnique({
let order = await this.prisma.order.findUnique({
where: { id },
include: {
delivery: true,
@@ -117,7 +132,30 @@ export class AdminOrdersService {
throw new BadRequestException('该订单已有运单号,请勿重复发货');
}
if (dto.warehouseId) {
const warehouseId = BigInt(dto.warehouseId);
const warehouseRow = await this.prisma.cityWarehouse.findFirst({
where: { id: warehouseId, cityId: order.cityId, status: 'ACTIVE' },
});
if (!warehouseRow) {
throw new BadRequestException('仓库不存在或不属于该订单开城城市');
}
if (order.fulfillmentWarehouseId !== warehouseId) {
await this.prisma.order.update({
where: { id },
data: { fulfillmentWarehouseId: warehouseId },
});
order = await this.prisma.order.findUniqueOrThrow({
where: { id },
include: { delivery: true, fulfillmentWarehouse: true },
});
}
}
const warehouse = order.fulfillmentWarehouse;
if (!warehouse) {
throw new BadRequestException('请先选择履约仓库');
}
const providerId =
order.delivery?.fulfillmentProviderId ??
warehouse?.fulfillmentProviderId ??
@@ -711,6 +711,11 @@ export class AdminShipOrderDto {
@IsIn(['XFX'])
provider: string;
/** 可选:指定/改派履约仓后再推仓配 */
@IsOptional()
@IsString()
warehouseId?: string;
@IsOptional()
@IsString()
fromName?: string;
@@ -52,6 +52,10 @@ export class AdminOrdersQueryDto extends PaginationQueryDto {
@IsString()
userId?: string;
@IsOptional()
@IsString()
cityId?: string;
@IsOptional()
@IsString()
receiverPhone?: string;