feat(attendant): 入驻免身份证材料、城市单选、材料后补与订单池同城过滤
入驻申请只收基本信息(身份证选填、材料全可空),服务城市改为单选白名单(北京/上海/天津/西安,默认北京);新增 POST /attendant-application/mine/materials 材料后补与 PATCH /employee/me/service-area 改城市接口;订单池按陪诊师服务城市过滤(本人已接/被共享不限城市),接单与详情二次校验;appId wxapp-escort-admin 更名为 wxapp_companion。
This commit is contained in:
@@ -2,6 +2,7 @@ import mongoose from "mongoose";
|
||||
import { DBModel } from "../models/index.js";
|
||||
import { MY_EMPLOYEE_SELECT } from "../models/schema/employee.js";
|
||||
import ResponseUtil from "../utils/responseUtil.js";
|
||||
import { SERVICE_AREAS } from "../resource/services.js";
|
||||
|
||||
/**
|
||||
* 陪诊师公示:面向 C 端患者的公开信息展示
|
||||
@@ -329,6 +330,50 @@ class HandlerEmployee {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 陪诊师本人修改服务城市
|
||||
*
|
||||
* 只允许在职陪诊师操作;城市必须来自服务目录白名单(与入驻申请同一份)。
|
||||
* 变更只影响订单池可见范围,不改写入驻申请单里的历史快照。
|
||||
*/
|
||||
async updateMyServiceArea(ctx) {
|
||||
try {
|
||||
const userId = ctx.state.user?._id;
|
||||
if (!userId) {
|
||||
return ResponseUtil.unauthorized(ctx, "登录已失效");
|
||||
}
|
||||
|
||||
const serviceArea = String(ctx.request.body?.serviceArea || "").trim();
|
||||
if (!serviceArea) return ResponseUtil.badRequest(ctx, "请选择服务城市");
|
||||
if (!SERVICE_AREAS.includes(serviceArea)) {
|
||||
return ResponseUtil.badRequest(ctx, "服务城市不在可选范围");
|
||||
}
|
||||
|
||||
const updated = await DBModel.Employee.findOneAndUpdate(
|
||||
{ userId, role: "attendant", status: "active" },
|
||||
{
|
||||
$set: {
|
||||
"attendantInfo.serviceAreas": [serviceArea],
|
||||
"meta.updatetime": Date.now(),
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
.select(MY_EMPLOYEE_SELECT)
|
||||
.lean()
|
||||
.exec();
|
||||
if (!updated) return ResponseUtil.forbidden(ctx, "仅在职陪诊师可修改服务城市");
|
||||
|
||||
return ResponseUtil.success(
|
||||
ctx,
|
||||
{ employee: HandlerEmployee.decorateMyEmployee(updated) },
|
||||
"服务城市已更新"
|
||||
);
|
||||
} catch (err) {
|
||||
return ResponseUtil.internalError(ctx, err);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 管理端 CRUD ====================
|
||||
// 与上面的公示接口完全分开:管理端要真实姓名、身份证号、证书编号等内部字段,
|
||||
// 但写入仍走白名单,避免 strict:false 的 schema 被塞入任意字段
|
||||
|
||||
Reference in New Issue
Block a user