feat(attendant): 待审核期间支持修改基本信息

This commit is contained in:
lik
2026-11-10 20:03:15 +08:00
parent cd3b109730
commit c461cdd0ee
2 changed files with 60 additions and 0 deletions
+58
View File
@@ -433,6 +433,64 @@ class HandlerAttendantApplication {
}
}
/**
* 待审核期间修改基本信息
*
* 只允许 pending 状态修改姓名/手机号/性别/服务城市/个人简介;
* 证件材料、状态与审核信息不经过本接口,避免绕开审核流程。
*/
async updateMyApplication(ctx) {
try {
const userId = ctx.state.user?._id;
if (!userId) return ResponseUtil.unauthorized(ctx, "登录已失效");
const application = await DBModel.AttendantApplication.findLatestByUser(userId);
if (!application) return ResponseUtil.notFound(ctx, "没有可修改的入驻申请");
if (application.status !== "pending") {
return ResponseUtil.error(
ctx,
application.status === "approved"
? "申请已通过审核,资料不可修改"
: "申请已驳回,请修改后重新提交",
null,
409
);
}
// 复用提交时的校验;材料部分不参与本次更新,只取 applicant
const result = HandlerAttendantApplication.parsePayload(ctx.request.body);
if (result.error) return ResponseUtil.badRequest(ctx, result.error);
const applicant = result.value.applicant;
// 条件更新兜底并发审核:提交后管理员恰好先审完,这里不会覆盖已通过的申请
const updated = await DBModel.AttendantApplication.findOneAndUpdate(
{ _id: application._id, status: "pending" },
{
$set: {
"applicant.name": applicant.name,
"applicant.mobile": applicant.mobile,
"applicant.sex": applicant.sex,
"applicant.serviceAreas": applicant.serviceAreas,
"applicant.introduction": applicant.introduction,
"meta.updatetime": Date.now(),
},
},
{ new: true }
).exec();
if (!updated) {
return ResponseUtil.error(ctx, "申请状态已变更,请刷新后重试", null, 409);
}
return ResponseUtil.success(
ctx,
{ application: HandlerAttendantApplication.toReceipt(updated) },
"个人信息已更新"
);
} catch (err) {
return ResponseUtil.internalError(ctx, err);
}
}
/**
* 证件材料后补
*