新增功能
This commit is contained in:
@@ -186,6 +186,25 @@ class AppointmentLogic extends BaseLogic
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
// 同一诊单患者在「所选预约日」仅允许一条「已预约」或「已过号」记录(与 appointment_date 一致,不能误用服务器当天拦其它日期)
|
||||
$apptDate = trim((string) ($params['appointment_date'] ?? ''));
|
||||
if ($apptDate === '') {
|
||||
self::setError('预约日期不能为空');
|
||||
Db::rollback();
|
||||
|
||||
return false;
|
||||
}
|
||||
$patientSameDay = Appointment::where('patient_id', (int) $params['patient_id'])
|
||||
->where('appointment_date', $apptDate)
|
||||
->whereIn('status', [1, 4])
|
||||
->find();
|
||||
if ($patientSameDay) {
|
||||
self::setError('该患者在所选日期已有挂号(已预约或已过号),无法重复预约');
|
||||
Db::rollback();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 检查时间段是否已被预约(每个时间段只能预约1次)
|
||||
// 统一时间格式为 HH:MM:SS
|
||||
$appointmentTime = strlen($params['appointment_time']) == 5
|
||||
@@ -214,7 +233,7 @@ class AppointmentLogic extends BaseLogic
|
||||
'appointment_time' => $appointmentTime,
|
||||
'appointment_type' => $params['appointment_type'] ?? 'video',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'channel_source' => $params['channel_source'] ?? '',
|
||||
'channels' => $params['channel_source'] ?? '',
|
||||
'status' => 1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
@@ -245,6 +264,19 @@ class AppointmentLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
$st = (int) $appointment->status;
|
||||
if ($st === 2) {
|
||||
return true;
|
||||
}
|
||||
if ($st === 3) {
|
||||
self::setError('预约已完成,无法取消');
|
||||
return false;
|
||||
}
|
||||
if ($st !== 1 && $st !== 4) {
|
||||
self::setError('当前状态不可取消');
|
||||
return false;
|
||||
}
|
||||
|
||||
$appointment->status = 2; // 已取消
|
||||
$appointment->update_time = time();
|
||||
$appointment->save();
|
||||
@@ -367,12 +399,13 @@ class AppointmentLogic extends BaseLogic
|
||||
self::setError('预约记录不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($appointment->status != 1) {
|
||||
|
||||
|
||||
if ($appointment->status == 3) {
|
||||
self::setError('该预约已处理,无法完成');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$appointment->status = 3; // 已完成
|
||||
$appointment->update_time = time();
|
||||
$appointment->save();
|
||||
|
||||
Reference in New Issue
Block a user