feat: add api http conventions and booking state rules

This commit is contained in:
que01 committed 2026-09-18 17:17:47 +08:00
1 parent 0d4caaba00
commit 0e8b8e1591
5 files changed
+61

No files matched your search

+9
View File
@@ -132,6 +132,15 @@ export class BookingService {
) {
const booking = await this.prisma.booking.findFirst({ where: { id, brandId } });
if (!booking) throw new NotFoundException("订单不存在");
const allowed: Record<string, string[]> = {
received: ["contacting", "cancelled"],
contacting: ["confirmed", "cancelled"],
confirmed: ["completed", "cancelled"],
completed: [],
cancelled: [],
};
if (status !== booking.status && !allowed[booking.status]?.includes(status))
throw new BadRequestException("不允许的订单状态流转");
return this.prisma.booking.update({
where: { id },
data: { status, ...(adminNote !== undefined ? { adminNote } : {}), isRead: true },