feat: 展示客户咨询状态时间线
This commit is contained in:
1 parent
d6c47ce143
commit
a8a37c179e
11 files changed
+98
-24
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# 咨询状态反馈
|
||||
|
||||
## 目标
|
||||
|
||||
让客户在个人品牌咨询提交后看到真实、可理解的跟进状态和历史轨迹,同时保持品牌和客户身份隔离,不泄露管理员备注等内部信息。
|
||||
|
||||
## 验收
|
||||
|
||||
- 客户列表和详情接口返回状态历史的公开字段。
|
||||
- 客户只能访问自己的记录和历史。
|
||||
- 后台备注仍仅后台可见。
|
||||
- 小程序记录页展示当前状态和时间线。
|
||||
- API、Admin build、miniapp fixture 全部通过。
|
||||
@@ -0,0 +1,13 @@
|
||||
# 进度
|
||||
|
||||
- 任务:咨询状态反馈
|
||||
- 形态:epic
|
||||
- 进度:3/3
|
||||
- 当前:全部子任务完成
|
||||
- 真相文件:`SUBTASKS.csv`
|
||||
|
||||
## 验证
|
||||
|
||||
- API integration tests:26 passed。
|
||||
- Admin production build:通过。
|
||||
- Miniapp fixture 和 visual fixture:通过。
|
||||
@@ -0,0 +1,4 @@
|
||||
id,title,task_type,depends_on,status,task_dir,acceptance_criteria,validation_command,notes
|
||||
1,客户状态历史 API,single-full,,DONE,tasks/api,列表和详情返回公开状态历史且隔离,pnpm --filter @personal-brand/api test:integration,已完成
|
||||
2,小程序状态时间线,single-full,1,DONE,tasks/api,记录页展示当前状态和历史时间线,pnpm --filter @personal-brand/miniapp test:fixture && pnpm --filter @personal-brand/miniapp test:visual-fixture,已完成
|
||||
3,回归收口,single-full,2,DONE,tasks/regression,Admin build 与全量检查通过,pnpm --filter @personal-brand/admin build && git diff --check,已完成
|
||||
|
@@ -0,0 +1,7 @@
|
||||
# 客户状态历史 API
|
||||
|
||||
状态:DONE
|
||||
|
||||
- 客户列表和详情返回状态历史公开字段。
|
||||
- 管理员备注和客户 subject 不向客户端返回。
|
||||
- 品牌与客户身份隔离保持有效。
|
||||
@@ -0,0 +1,8 @@
|
||||
# 回归收口
|
||||
|
||||
状态:DONE
|
||||
|
||||
- API 集成测试:26 passed。
|
||||
- Admin production build:通过。
|
||||
- Miniapp fixture:通过。
|
||||
- Miniapp visual fixture:通过。
|
||||
+33
-22
@@ -282,24 +282,24 @@ export class PublicWorkspaceController {
|
||||
].includes(String(value.type))
|
||||
? (value.type as RuntimeInquiryField["type"])
|
||||
: "text";
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (!option || typeof option !== "object") return [];
|
||||
const item = option as Record<string, unknown>;
|
||||
return typeof item.label === "string" && typeof item.value === "string"
|
||||
? [{ label: item.label, value: item.value }]
|
||||
: [];
|
||||
})
|
||||
: undefined;
|
||||
return [
|
||||
{
|
||||
key: value.key,
|
||||
label: value.label,
|
||||
type,
|
||||
required: value.required === true,
|
||||
...(options?.length ? { options } : {}),
|
||||
},
|
||||
];
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (!option || typeof option !== "object") return [];
|
||||
const item = option as Record<string, unknown>;
|
||||
return typeof item.label === "string" && typeof item.value === "string"
|
||||
? [{ label: item.label, value: item.value }]
|
||||
: [];
|
||||
})
|
||||
: undefined;
|
||||
return [
|
||||
{
|
||||
key: value.key,
|
||||
label: value.label,
|
||||
type,
|
||||
required: value.required === true,
|
||||
...(options?.length ? { options } : {}),
|
||||
},
|
||||
];
|
||||
});
|
||||
const inquiryForm = inquiryForms[0] ?? null;
|
||||
const runtimeWorkspace: RuntimeWorkspace = {
|
||||
@@ -480,11 +480,14 @@ export class PublicInquiryFormController {
|
||||
@Controller("customer/inquiry-submissions")
|
||||
export class CustomerInquirySubmissionController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
private present<T extends { customerSubject: string }>(
|
||||
submission: T,
|
||||
): Omit<T, "customerSubject"> {
|
||||
const { customerSubject: _customerSubject, ...publicSubmission } = submission;
|
||||
private present<T extends { customerSubject: string; adminNote?: string | null }>(submission: T) {
|
||||
const {
|
||||
customerSubject: _customerSubject,
|
||||
adminNote: _adminNote,
|
||||
...publicSubmission
|
||||
} = submission;
|
||||
void _customerSubject;
|
||||
void _adminNote;
|
||||
return publicSubmission;
|
||||
}
|
||||
private identity(request: FastifyRequest): ReturnType<typeof readIdentity> {
|
||||
@@ -509,6 +512,10 @@ export class CustomerInquirySubmissionController {
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
statusHistory: {
|
||||
select: { fromStatus: true, toStatus: true, createdAt: true },
|
||||
orderBy: { createdAt: "asc" },
|
||||
},
|
||||
},
|
||||
});
|
||||
return submissions.map((submission) => this.present(submission));
|
||||
@@ -522,6 +529,10 @@ export class CustomerInquirySubmissionController {
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
statusHistory: {
|
||||
select: { fromStatus: true, toStatus: true, createdAt: true },
|
||||
orderBy: { createdAt: "asc" },
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!submission) throw new NotFoundException("咨询记录不存在");
|
||||
|
||||
@@ -604,6 +604,15 @@ test("admin can create and version an inquiry form", async () => {
|
||||
assert.equal(updatedSubmission.statusCode, 200);
|
||||
assert.equal(JSON.parse(updatedSubmission.body).status, "reviewing");
|
||||
assert.equal(JSON.parse(updatedSubmission.body).adminNote, "已开始评估需求");
|
||||
const customerSubmissionAfterUpdate = await request(
|
||||
`/customer/inquiry-submissions/${savedSubmission.id}`,
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(customerSubmissionAfterUpdate.statusCode, 200);
|
||||
const customerBody = JSON.parse(customerSubmissionAfterUpdate.body);
|
||||
assert.equal(customerBody.adminNote, undefined);
|
||||
assert.equal(customerBody.statusHistory[0].toStatus, "reviewing");
|
||||
assert.equal(customerBody.statusHistory[0].adminNote, undefined);
|
||||
const history = await prisma.inquirySubmissionStatusHistory.findMany({
|
||||
where: { submissionId: savedSubmission.id },
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">还没有咨询记录</text><text>预约一次私享沟通,让我们从你的空间开始。</text><button bindtap="create">开始咨询</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text></view></view></view>
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">还没有咨询记录</text><text>预约一次私享沟通,让我们从你的空间开始。</text><button bindtap="create">开始咨询</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
|
||||
@@ -1 +1 @@
|
||||
.records{margin-top:22rpx}.empty{text-align:center;padding:120rpx 20rpx;color:#99928a;font-size:26rpx;line-height:1.8}.empty-title{display:block;margin-bottom:16rpx;color:#252525;font:40rpx serif}.empty button{margin-top:34rpx;background:#8a6846;color:#fff;border-radius:0}.record{margin-top:18rpx;padding:28rpx;background:#fff;border:1rpx solid #e6ded5}.record-head{display:flex;justify-content:space-between;font:32rpx serif}.status{color:#8a6846;font:23rpx sans-serif}.project{display:block;margin-top:18rpx;color:#77736b;font-size:26rpx}.meta{display:block;margin-top:16rpx;color:#aaa39a;font-size:22rpx}
|
||||
.records{margin-top:22rpx}.empty{text-align:center;padding:120rpx 20rpx;color:#99928a;font-size:26rpx;line-height:1.8}.empty-title{display:block;margin-bottom:16rpx;color:#252525;font:40rpx serif}.empty button{margin-top:34rpx;background:#8a6846;color:#fff;border-radius:0}.record{margin-top:18rpx;padding:28rpx;background:#fff;border:1rpx solid #e6ded5}.record-head{display:flex;justify-content:space-between;font:32rpx serif}.status{color:#8a6846;font:23rpx sans-serif}.project{display:block;margin-top:18rpx;color:#77736b;font-size:26rpx}.meta{display:block;margin-top:16rpx;color:#aaa39a;font-size:22rpx}.timeline{margin-top:24rpx;padding-top:18rpx;border-top:1rpx solid #eee7df}.timeline-item{display:flex;gap:12rpx;margin-top:10rpx;color:#77736b;font-size:22rpx}.timeline-dot{color:#8a6846}
|
||||
@@ -22,6 +22,10 @@ Page({
|
||||
...item,
|
||||
type: item.inquiryForm?.name || "品牌咨询",
|
||||
status: statusLabels[item.status] || item.status,
|
||||
timeline: (item.statusHistory || []).map((entry) => ({
|
||||
status: statusLabels[entry.toStatus] || entry.toStatus,
|
||||
createdAt: new Date(entry.createdAt).toLocaleString("zh-CN"),
|
||||
})),
|
||||
project: "咨询记录",
|
||||
offeringName: item.offering?.name || "品牌合作",
|
||||
createdAt: new Date(item.createdAt).toLocaleDateString("zh-CN"),
|
||||
|
||||
@@ -189,6 +189,11 @@ export interface InquirySubmission {
|
||||
adminNote?: string | null;
|
||||
inquiryForm?: { name: string };
|
||||
offering?: { id: string; name: string } | null;
|
||||
statusHistory?: Array<{
|
||||
fromStatus?: string | null;
|
||||
toStatus: string;
|
||||
createdAt: string;
|
||||
}>;
|
||||
}
|
||||
export interface CapabilityInstallation {
|
||||
id: string | null;
|
||||
|
||||
Reference in new issue
Block a user