订单详情页内容调整(增加配送方式、订单号等)
This commit is contained in:
@@ -46,6 +46,11 @@ export class TradeController {
|
||||
) {
|
||||
return this.tradeService.updateAddress(user.actorId, BigInt(id), body);
|
||||
}
|
||||
|
||||
@Post(':id/confirm-receive')
|
||||
confirmReceive(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
||||
return this.tradeService.confirmReceive(user.actorId, BigInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('partner/orders')
|
||||
|
||||
@@ -247,6 +247,16 @@ export class TradeService {
|
||||
return serializeBigInt(updated);
|
||||
}
|
||||
|
||||
async confirmReceive(userId: bigint, orderId: bigint) {
|
||||
const order = await this.prisma.order.findFirst({ where: { id: orderId, userId } });
|
||||
if (!order) throw new NotFoundException('订单不存在');
|
||||
if (order.status !== 'PENDING_RECEIVE') {
|
||||
throw new BadRequestException('当前状态不可确认收货');
|
||||
}
|
||||
await this.applyStatusTransition(order.id, order.status, 'COMPLETED', 'USER');
|
||||
return this.getOrder(userId, orderId);
|
||||
}
|
||||
|
||||
async listPartnerOrders(partnerAccountId: bigint, page = 1, pageSize = 20) {
|
||||
const account = await this.prisma.partnerAccount.findUniqueOrThrow({
|
||||
where: { id: partnerAccountId },
|
||||
@@ -296,7 +306,12 @@ export class TradeService {
|
||||
return this.getPartnerOrder(partnerAccountId, orderId);
|
||||
}
|
||||
|
||||
async applyStatusTransition(orderId: bigint, fromStatus: string, targetStatus: string) {
|
||||
async applyStatusTransition(
|
||||
orderId: bigint,
|
||||
fromStatus: string,
|
||||
targetStatus: string,
|
||||
operator = 'MOCK',
|
||||
) {
|
||||
const order = await this.prisma.order.findUnique({ where: { id: orderId } });
|
||||
if (!order) return;
|
||||
const currentStatus = fromStatus || order.status;
|
||||
@@ -324,7 +339,7 @@ export class TradeService {
|
||||
orderId,
|
||||
fromStatus: currentStatus,
|
||||
toStatus: targetStatus,
|
||||
operator: 'MOCK',
|
||||
operator,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user