This commit is contained in:
Your Name
2026-09-09 12:18:17 +08:00
parent 0cea43b027
commit 40319eea41
76 changed files with 4821 additions and 268 deletions
@@ -2,7 +2,8 @@
namespace app\adminapi\logic\doctor;
use app\common\logic\BaseLogic;
use app\common\logic\BaseLogic;
use app\common\enum\AppointmentTypeEnum;
use app\common\model\doctor\Appointment;
use app\common\model\doctor\Roster;
use app\common\service\doctor\RosterSegmentService;
@@ -46,7 +47,7 @@ class AppointmentLogic extends BaseLogic
/**
* @param array<int|string, mixed> $cols Db::name('doctor_appointment')->getTableFields()
*/
private static function assertAppointmentChannelWritable(array $cols, string $chSrc): ?string
private static function assertAppointmentChannelWritable(array $cols, string $chSrc): ?string
{
$hasChannelSource = in_array('channel_source', $cols, true);
$hasChannels = in_array('channels', $cols, true);
@@ -86,9 +87,12 @@ class AppointmentLogic extends BaseLogic
*
* @return array<string, mixed>
*/
private static function filterAppointmentRowByExistingColumns(array $row, array $cols): array
{
$out = [];
private static function filterAppointmentRowByExistingColumns(array $row, array $cols): array
{
if (array_key_exists('appointment_type', $row) && !in_array('appointment_type', $cols, true)) {
throw new \RuntimeException('挂号表缺少 appointment_type 字段,无法保存问诊类型');
}
$out = [];
foreach ($row as $k => $v) {
if (in_array((string) $k, $cols, true)) {
$out[$k] = $v;
@@ -273,9 +277,15 @@ class AppointmentLogic extends BaseLogic
* @param array $params
* @return array|bool
*/
public static function create(array $params, int $operatorAdminId = 0, array $operatorAdminInfo = [])
{
try {
public static function create(array $params, int $operatorAdminId = 0, array $operatorAdminInfo = [])
{
$params = AppointmentTypeEnum::withDefault($params);
if (!AppointmentTypeEnum::isWritable($params['appointment_type'])) {
self::setError('问诊类型仅支持图文问诊或视频问诊');
return false;
}
try {
Db::startTrans();
// 同一诊单患者在「所选预约日」仅允许一条「已预约」或「已过号」记录(与 appointment_date 一致,不能误用服务器当天拦其它日期)
@@ -345,7 +355,7 @@ class AppointmentLogic extends BaseLogic
'doctor_id' => (int) $params['doctor_id'],
'appointment_date' => $params['appointment_date'],
'appointment_time' => $appointmentTime,
'appointment_type' => $params['appointment_type'] ?? 'video',
'appointment_type' => $params['appointment_type'],
'remark' => $params['remark'] ?? '',
'status' => 1,
'create_time' => time(),
@@ -491,12 +501,8 @@ class AppointmentLogic extends BaseLogic
];
$appointment['status_desc'] = $statusMap[$appointment['status']] ?? '未知';
$typeMap = [
'video' => '视频问诊',
'text' => '图文问诊',
'phone' => '电话问诊',
];
$appointment['appointment_type_desc'] = $typeMap[$appointment['appointment_type']] ?? '未知';
$appointment['appointment_type'] = AppointmentTypeEnum::normalizeStored($appointment['appointment_type'] ?? null);
$appointment['appointment_type_desc'] = AppointmentTypeEnum::description($appointment['appointment_type']);
// 格式化时间戳为日期时间
if (isset($appointment['create_time']) && is_numeric($appointment['create_time'])) {
@@ -969,9 +975,14 @@ class AppointmentLogic extends BaseLogic
*
* @param array<string, mixed> $params
*/
public static function adminEdit(array $params, int $adminId, array $adminInfo): bool
{
try {
public static function adminEdit(array $params, int $adminId, array $adminInfo): bool
{
if (!AppointmentTypeEnum::isWritable($params['appointment_type'] ?? null)) {
self::setError('问诊类型仅支持图文问诊或视频问诊');
return false;
}
try {
$id = (int) ($params['id'] ?? 0);
if ($id <= 0) {
self::setError('参数错误');
@@ -1023,12 +1034,7 @@ class AppointmentLogic extends BaseLogic
return false;
}
$appointmentType = trim((string) ($params['appointment_type'] ?? ''));
if (!in_array($appointmentType, ['video', 'text', 'phone'], true)) {
self::setError('预约类型无效');
return false;
}
$appointmentType = $params['appointment_type'];
$remark = isset($params['remark']) ? trim((string) $params['remark']) : '';
if (mb_strlen($remark) > 500) {