This commit is contained in:
lik
2026-06-02 12:21:54 +08:00
parent 43aa9ac844
commit 9758dc2d7b
2 changed files with 29 additions and 28 deletions

View File

@@ -110,7 +110,7 @@ class HandlerEscortRecord {
} }
const updatedRecord = await DBModel.EscortRecord.updateRecord(id, { const updatedRecord = await DBModel.EscortRecord.updateRecord(id, {
"escort.status": status, "status": status,
}); });
if (!updatedRecord) { if (!updatedRecord) {

View File

@@ -24,11 +24,11 @@ const EscortRecordSchema = mongoose.Schema(
* @type {ObjectId} * @type {ObjectId}
* @ref user * @ref user
*/ */
userId: { userId: {
type: mongoose.Schema.Types.ObjectId, type: mongoose.Schema.Types.ObjectId,
ref: "user", ref: "user",
index: true, index: true,
comment: "提交订单用户ID" comment: "提交订单用户ID"
}, },
/** /**
@@ -39,6 +39,8 @@ const EscortRecordSchema = mongoose.Schema(
mobile: { type: String, default: "", unique: true, index: true, comment: "患者联系电话" }, mobile: { type: String, default: "", unique: true, index: true, comment: "患者联系电话" },
sex: { type: String, enum: ["male", "female"], comment: "患者性别" }, sex: { type: String, enum: ["male", "female"], comment: "患者性别" },
age: { type: Number, default: 0, 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: "患者身份证号" }, idnumber: { type: String, default: "", comment: "患者身份证号" },
}, },
@@ -48,6 +50,19 @@ const EscortRecordSchema = mongoose.Schema(
escort: { escort: {
serviceId: { type: Number, default: -1, comment: "陪诊服务ID" }, serviceId: { type: Number, default: -1, comment: "陪诊服务ID" },
serviceName: { type: String, default: "", comment: "陪诊服务名称" }, 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: "陪诊时长(分钟)" }, 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) { EscortRecordSchema.statics.findRecordsByUser = async function (userId, options = {}, cb) {
const { page = 1, pageSize = 20, status } = options; const { page = 1, pageSize = 20, status } = options;
const filter = { userId }; const filter = { userId };
if (status) { if (status) {
filter.status = status; filter.status = status;
} }
const skip = (page - 1) * pageSize; const skip = (page - 1) * pageSize;
return await this.find(filter) return await this.find(filter)
.sort({ "schedule.date": -1 }) .sort({ "schedule.date": -1 })
.skip(skip) .skip(skip)
@@ -182,13 +183,13 @@ EscortRecordSchema.statics.findRecordsByUser = async function (userId, options =
EscortRecordSchema.statics.findRecordsByAttendant = async function (attendantId, options = {}, cb) { EscortRecordSchema.statics.findRecordsByAttendant = async function (attendantId, options = {}, cb) {
const { page = 1, pageSize = 20, status } = options; const { page = 1, pageSize = 20, status } = options;
const filter = { "attendant.id": attendantId }; const filter = { "attendant.id": attendantId };
if (status) { if (status) {
filter.status = status; filter.status = status;
} }
const skip = (page - 1) * pageSize; const skip = (page - 1) * pageSize;
return await this.find(filter) return await this.find(filter)
.sort({ "schedule.date": -1 }) .sort({ "schedule.date": -1 })
.skip(skip) .skip(skip)
@@ -208,7 +209,7 @@ EscortRecordSchema.statics.createRecord = async function (record, cb) {
createtime: Date.now(), createtime: Date.now(),
updatetime: Date.now(), updatetime: Date.now(),
}; };
const newRecord = new this(record); const newRecord = new this(record);
return await newRecord.save(cb); return await newRecord.save(cb);
}; };
@@ -255,7 +256,7 @@ EscortRecordSchema.statics.findRecordById = async function (id, cb) {
EscortRecordSchema.statics.findRecordsByStatus = async function (status, options = {}, cb) { EscortRecordSchema.statics.findRecordsByStatus = async function (status, options = {}, cb) {
const { page = 1, pageSize = 20 } = options; const { page = 1, pageSize = 20 } = options;
const skip = (page - 1) * pageSize; const skip = (page - 1) * pageSize;
return await this.find({ status }) return await this.find({ status })
.sort({ "schedule.date": -1 }) .sort({ "schedule.date": -1 })
.skip(skip) .skip(skip)