From 9758dc2d7ba606a2ce55d7157daac2ba45a0bf1f Mon Sep 17 00:00:00 2001 From: lik Date: Tue, 2 Jun 2026 12:21:54 +0800 Subject: [PATCH] tmp --- handler/escort_record.js | 2 +- models/schema/escort_record.js | 55 +++++++++++++++++----------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/handler/escort_record.js b/handler/escort_record.js index 1cd27a4..273051b 100644 --- a/handler/escort_record.js +++ b/handler/escort_record.js @@ -110,7 +110,7 @@ class HandlerEscortRecord { } const updatedRecord = await DBModel.EscortRecord.updateRecord(id, { - "escort.status": status, + "status": status, }); if (!updatedRecord) { diff --git a/models/schema/escort_record.js b/models/schema/escort_record.js index 1e4827d..2c1a9d1 100644 --- a/models/schema/escort_record.js +++ b/models/schema/escort_record.js @@ -24,11 +24,11 @@ const EscortRecordSchema = mongoose.Schema( * @type {ObjectId} * @ref user */ - userId: { - type: mongoose.Schema.Types.ObjectId, - ref: "user", - index: true, - comment: "提交订单用户ID" + userId: { + type: mongoose.Schema.Types.ObjectId, + ref: "user", + index: true, + comment: "提交订单用户ID" }, /** @@ -39,6 +39,8 @@ const EscortRecordSchema = mongoose.Schema( mobile: { type: String, default: "", unique: true, index: true, comment: "患者联系电话" }, sex: { type: String, enum: ["male", "female"], comment: "患者性别" }, age: { type: Number, default: 0, comment: "患者年龄" }, + weight: { type: Number, default: 0, comment: "患者体重(kg)" }, + height: { type: Number, default: 0, comment: "患者身高(cm)" }, idnumber: { type: String, default: "", comment: "患者身份证号" }, }, @@ -48,6 +50,19 @@ const EscortRecordSchema = mongoose.Schema( escort: { serviceId: { type: Number, default: -1, comment: "陪诊服务ID" }, serviceName: { type: String, default: "", comment: "陪诊服务名称" }, + sexRequirement: { type: String, enum: ["none", "male", "female"], comment: "陪诊员性别要求" }, + }, + + /** + * 陪诊员信息 - 为患者提供服务的陪诊员 + */ + attendant: { + id: { + type: mongoose.Schema.Types.ObjectId, index: true, comment: "陪诊员用户ID" + }, + name: { type: String, default: "", comment: "陪诊员姓名" }, + sex: { type: String, enum: ["none", "male", "female"], comment: "陪诊员性别" }, + mobile: { type: String, default: "", comment: "陪诊员联系电话" }, }, /** @@ -72,20 +87,6 @@ const EscortRecordSchema = mongoose.Schema( duration: { type: Number, default: 60, comment: "陪诊时长(分钟)" }, }, - /** - * 陪诊员信息 - 为患者提供服务的陪诊员 - */ - attendant: { - id: { - type: mongoose.Schema.Types.ObjectId, - ref: "user", - index: true, - comment: "陪诊员用户ID" - }, - name: { type: String, default: "", comment: "陪诊员姓名" }, - sex: { type: String, enum: ["none", "male", "female"], comment: "陪诊员性别" }, - }, - /** * 费用信息 - 服务费用相关 */ @@ -154,13 +155,13 @@ const EscortRecordSchema = mongoose.Schema( EscortRecordSchema.statics.findRecordsByUser = async function (userId, options = {}, cb) { const { page = 1, pageSize = 20, status } = options; const filter = { userId }; - + if (status) { filter.status = status; } - + const skip = (page - 1) * pageSize; - + return await this.find(filter) .sort({ "schedule.date": -1 }) .skip(skip) @@ -182,13 +183,13 @@ EscortRecordSchema.statics.findRecordsByUser = async function (userId, options = EscortRecordSchema.statics.findRecordsByAttendant = async function (attendantId, options = {}, cb) { const { page = 1, pageSize = 20, status } = options; const filter = { "attendant.id": attendantId }; - + if (status) { filter.status = status; } - + const skip = (page - 1) * pageSize; - + return await this.find(filter) .sort({ "schedule.date": -1 }) .skip(skip) @@ -208,7 +209,7 @@ EscortRecordSchema.statics.createRecord = async function (record, cb) { createtime: Date.now(), updatetime: Date.now(), }; - + const newRecord = new this(record); return await newRecord.save(cb); }; @@ -255,7 +256,7 @@ EscortRecordSchema.statics.findRecordById = async function (id, cb) { EscortRecordSchema.statics.findRecordsByStatus = async function (status, options = {}, cb) { const { page = 1, pageSize = 20 } = options; const skip = (page - 1) * pageSize; - + return await this.find({ status }) .sort({ "schedule.date": -1 }) .skip(skip)