feat: 支持客户查询咨询详情
This commit is contained in:
1 parent
b299c313d1
commit
3186757d93
4 files changed
+46
-1
No files matched your search
@@ -497,6 +497,20 @@ export class CustomerInquirySubmissionController {
|
||||
return submissions.map((submission) => this.present(submission));
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
async get(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
||||
const identity = this.identity(request);
|
||||
const submission = await this.prisma.inquirySubmission.findFirst({
|
||||
where: { id, brandId: identity.brandId, customerSubject: identity.subject },
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
},
|
||||
});
|
||||
if (!submission) throw new NotFoundException("咨询记录不存在");
|
||||
return this.present(submission);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Req() request: FastifyRequest,
|
||||
|
||||
@@ -534,6 +534,17 @@ test("admin can create and version an inquiry form", async () => {
|
||||
(item) => item.id === JSON.parse(submission.body).id,
|
||||
),
|
||||
);
|
||||
const customerSubmission = await request(
|
||||
`/customer/inquiry-submissions/${JSON.parse(submission.body).id}`,
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(customerSubmission.statusCode, 200);
|
||||
assert.equal(JSON.parse(customerSubmission.body).customerSubject, undefined);
|
||||
const missingCustomerSubmission = await request(
|
||||
"/customer/inquiry-submissions/00000000-0000-0000-0000-000000000000",
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(missingCustomerSubmission.statusCode, 404);
|
||||
const adminSubmissionsWithoutToken = await request("/admin/workspace/submissions");
|
||||
assert.equal(adminSubmissionsWithoutToken.statusCode, 401);
|
||||
const adminSubmissions = await request("/admin/workspace/submissions", {
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
const { customerRequest } = require("../../utils/request");
|
||||
|
||||
Page({
|
||||
data: { record: {} },
|
||||
onLoad(options) {
|
||||
const record = wx.getStorageSync("latestInquirySubmission") || {};
|
||||
this.setData({ record: record.id === options.id ? record : {} });
|
||||
if (record.id === options.id) this.setData({ record });
|
||||
if (options.id && wx.getStorageSync("customerToken")) {
|
||||
customerRequest("/customer/inquiry-submissions/" + encodeURIComponent(options.id))
|
||||
.then((submission) =>
|
||||
this.setData({
|
||||
record: {
|
||||
...record,
|
||||
id: submission.id,
|
||||
status: submission.status === "new" ? "待处理" : submission.status,
|
||||
createdAt: submission.createdAt,
|
||||
offeringName: submission.offering?.name || record.offeringName || "品牌合作",
|
||||
},
|
||||
}),
|
||||
)
|
||||
.catch(() => {});
|
||||
}
|
||||
},
|
||||
viewRecords() {
|
||||
wx.redirectTo({ url: "/pages/records/index" });
|
||||
|
||||
@@ -336,6 +336,9 @@ export class ApiClient {
|
||||
listCustomerInquirySubmissions(): Promise<InquirySubmission[]> {
|
||||
return this.request("/customer/inquiry-submissions");
|
||||
}
|
||||
getCustomerInquirySubmission(id: string): Promise<InquirySubmission> {
|
||||
return this.request(`/customer/inquiry-submissions/${encodeURIComponent(id)}`);
|
||||
}
|
||||
createCustomerSession(code: string): Promise<{ token: string }> {
|
||||
return this.request("/customer/session/wechat", { method: "POST", body: { code } });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user