refactor: 移除旧服务模型统一使用业务提供项

This commit is contained in:
que01 committed 2026-09-21 17:11:45 +08:00
1 parent ca85a583ce
commit 844a3bd715
13 files changed
+92 -146

No files matched your search

+17 -7
View File
@@ -5,17 +5,16 @@ import { BookingService } from "../src/booking.service.js";
const brandId = "brand-1";
const customerId = "customer-1";
const service = {
const offering = {
id: "service-1",
name: "套餐",
bookingEnabled: true,
priceAmount: 2800,
};
function createPrisma(overrides: Record<string, unknown> = {}): any {
return {
service: {
findMany: async () => [service],
offering: {
findMany: async () => [offering],
},
booking: {
create: async ({ data }: any) => ({
@@ -31,7 +30,7 @@ function createPrisma(overrides: Record<string, unknown> = {}): any {
},
tag: { findMany: async () => [] },
bookingTag: { deleteMany: {}, createMany: {} },
$transaction: async () => undefined,
$transaction: async (callback: (tx: unknown) => unknown) => callback(undefined),
...overrides,
};
}
@@ -43,7 +42,7 @@ test("创建普通套餐订单时保存价格快照和预计金额", async () =>
customerName: "陈同学",
wechatId: "wx-test",
contactPreference: "wechat",
items: [{ serviceId: service.id, quantity: 2 }],
items: [{ offeringId: offering.id, quantity: 2 }],
});
assert.equal(result.estimatedAmount, 5600);
assert.equal(result.status, "received");
@@ -85,9 +84,20 @@ test("取消不存在或不属于当前客户的订单返回不存在", async ()
test("订单状态只能按定义的状态机流转", async () => {
const prisma = createPrisma({
booking: {
findFirst: async () => ({ id: "booking-1", status: "received" }),
findFirst: async () => ({
id: "booking-1",
status: "received",
currentState: "received",
workflowKey: "booking.basic",
workflowVersion: "1.0.0",
}),
update: async ({ data }: any) => data,
},
$transaction: async (callback: (tx: any) => unknown) =>
callback({
booking: { update: async ({ data }: any) => data },
bookingStateTransition: { create: async () => undefined },
}),
});
const bookings = new BookingService(prisma);
assert.equal(