feat(attendant): 入驻免身份证材料、城市单选、材料后补与订单池同城过滤

入驻申请只收基本信息(身份证选填、材料全可空),服务城市改为单选白名单(北京/上海/天津/西安,默认北京);新增 POST /attendant-application/mine/materials 材料后补与 PATCH /employee/me/service-area 改城市接口;订单池按陪诊师服务城市过滤(本人已接/被共享不限城市),接单与详情二次校验;appId wxapp-escort-admin 更名为 wxapp_companion。
This commit is contained in:
lik
2026-11-10 16:33:47 +08:00
parent 3086a40b4c
commit cd3b109730
14 changed files with 522 additions and 84 deletions
+57
View File
@@ -409,3 +409,60 @@ test("取消共享时订单不存在返回 404", async () => {
})
);
});
test("订单池按服务城市过滤,scope=mine 不带城市条件", async () => {
const employee = buildEmployee({
attendantInfo: { stage: "certified", grade: "bronze", serviceAreas: ["上海市"] },
});
let captured = null;
const recordStub = {
findRecordPage: async (options) => {
captured = options;
return { records: [], total: 0, counts: {} };
},
};
await withModel("Employee", employeeFindOneStub(employee), () =>
withModel("EscortRecord", recordStub, async () => {
const poolCtx = createCtx({ user: { _id: CERT_USER_ID }, query: { scope: "pool" } });
await new HandlerEscortRecord().getAttendantRecords(poolCtx);
assert.equal(poolCtx.body.code, 0);
assert.deepEqual(captured.attendantVisibility.poolCities, ["上海市", "上海"]);
const mineCtx = createCtx({ user: { _id: CERT_USER_ID }, query: { scope: "mine" } });
await new HandlerEscortRecord().getAttendantRecords(mineCtx);
assert.equal(mineCtx.body.code, 0);
// 本人已接订单不受城市限制
assert.equal(captured.attendantVisibility.poolCities, undefined);
assert.equal(captured.attendantVisibility.includeUnassigned, undefined);
})
);
});
test("服务城市匹配兼容「市」后缀,未配置城市保持全部可见", () => {
assert.deepEqual(HandlerEscortRecord.cityVariants(["上海市"]), ["上海市", "上海"]);
assert.equal(
HandlerEscortRecord.matchesServiceArea(
{ hospital: { province: "上海市" } },
{ attendantInfo: { serviceAreas: ["上海"] } }
),
true
);
assert.equal(
HandlerEscortRecord.matchesServiceArea(
{ hospital: { province: "北京市" } },
{ attendantInfo: { serviceAreas: ["上海市"] } }
),
false
);
// 存量档案没配城市:保持原行为,不因城市过滤而看不到订单
assert.equal(
HandlerEscortRecord.matchesServiceArea(
{ hospital: { province: "北京市" } },
{ attendantInfo: {} }
),
true
);
});