diff --git a/apps/api/prisma/migrations/20260919123000_add_inquiry_request_type/migration.sql b/apps/api/prisma/migrations/20260919123000_add_inquiry_request_type/migration.sql new file mode 100644 index 0000000..1dc5592 --- /dev/null +++ b/apps/api/prisma/migrations/20260919123000_add_inquiry_request_type/migration.sql @@ -0,0 +1 @@ +ALTER TYPE "BookingRequestType" ADD VALUE 'inquiry'; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index c6980fe..81e8c4c 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -18,6 +18,7 @@ enum BookingStatus { enum BookingRequestType { package private_chef + inquiry } enum ContactPreference { diff --git a/apps/api/src/booking.dto.ts b/apps/api/src/booking.dto.ts index d5e0421..3dea9f3 100644 --- a/apps/api/src/booking.dto.ts +++ b/apps/api/src/booking.dto.ts @@ -17,7 +17,7 @@ export class BookingItemDto { } export class CreateBookingDto { - @IsIn(["package", "private_chef"]) requestType!: "package" | "private_chef"; + @IsIn(["package", "private_chef", "inquiry"]) requestType!: "package" | "private_chef" | "inquiry"; @IsString() customerName!: string; @IsOptional() @IsString() phone?: string; @IsOptional() @IsString() wechatId?: string; diff --git a/apps/api/src/booking.service.ts b/apps/api/src/booking.service.ts index 14fc993..1e1f2ac 100644 --- a/apps/api/src/booking.service.ts +++ b/apps/api/src/booking.service.ts @@ -3,7 +3,7 @@ import { BookingStatus, Prisma } from "@prisma/client"; import { PrismaService } from "./prisma.service.js"; export interface CreateBookingInput { - requestType: "package" | "private_chef"; + requestType: "package" | "private_chef" | "inquiry"; customerName: string; phone?: string; wechatId?: string; diff --git a/apps/api/test/http.integration.test.js b/apps/api/test/http.integration.test.js index 11cb6df..e2c1db0 100644 --- a/apps/api/test/http.integration.test.js +++ b/apps/api/test/http.integration.test.js @@ -152,6 +152,27 @@ test("customer booking DTO rejects incomplete package requests", async () => { assert.equal(JSON.parse(response.body).error.code, "HTTP_400"); }); +test("customer can create a generic inquiry without food-specific fields", async () => { + const response = await request("/customer/bookings", { + method: "POST", + headers: { authorization: `Bearer ${customerToken}` }, + payload: { + requestType: "inquiry", + customerName: "个人品牌咨询客户", + wechatId: "inquiry-wechat", + contactPreference: "wechat", + requestedTime: "下周三 14:00", + note: "希望讨论品牌合作方案", + }, + }); + assert.equal(response.statusCode, 201); + const body = JSON.parse(response.body); + const booking = await prisma.booking.findUnique({ where: { bookingNo: body.bookingNo } }); + assert.ok(booking); + assert.equal(booking.requestType, "inquiry"); + createdBookingIds.push(booking.id); +}); + test("customer can create and cancel a package booking", async () => { const service = await prisma.service.findFirst({ where: { brandId, isEnabled: true, priceAmount: { not: null } } }); assert.ok(service); diff --git a/apps/miniapp/utils/templates.js b/apps/miniapp/utils/templates.js index 9fbf0fd..2e37fb5 100644 --- a/apps/miniapp/utils/templates.js +++ b/apps/miniapp/utils/templates.js @@ -1,6 +1,6 @@ const TEMPLATES = { food: { hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取', serviceSub: '今日可订', first: '普通套餐', firstSub: '日常家常饭', second: '私厨服务', secondSub: '聚餐定制', available: '今日可订', unavailable: '暂不可订', empty: '暂无可订服务', bookingTitle: '预约套餐', requestType: 'package', modeLabel: '取餐方式', modeA: '自取', modeB: '配送', locationLabel: '配送地址', locationPlaceholder: '请输入配送地址', notePlaceholder: '口味、餐具或其他说明', submitNotice: '提交后由摊主人工确认,确认后再安排制作。', submitLabel: '提交预约' }, - personal: { hero: '个人品牌', heroSub: '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系', serviceSub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务', bookingTitle: '合作咨询', requestType: 'package', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' }, + personal: { hero: '个人品牌', heroSub: '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系', serviceSub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务', bookingTitle: '合作咨询', requestType: 'inquiry', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' }, }; function getTemplate(key) { return TEMPLATES[key] || TEMPLATES.personal; } module.exports = { getTemplate, TEMPLATES }; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index f84ff1d..344c1a4 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,5 +1,5 @@ export type BookingStatus = "received" | "contacting" | "confirmed" | "completed" | "cancelled"; -export type BookingRequestType = "package" | "private_chef"; +export type BookingRequestType = "package" | "private_chef" | "inquiry"; export type ContactPreference = "wechat" | "phone" | "none"; export type FulfillmentType = "pickup" | "delivery"; export type OrderStatus = BookingStatus;