更新
This commit is contained in:
@@ -131,6 +131,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$apt = $appointmentMap[$item['patient_id']] ?? null;
|
||||
if ($apt) {
|
||||
$item['has_appointment'] = 1;
|
||||
$item['appointment_id'] = $apt['id'];
|
||||
$item['appointment_doctor_id'] = $apt['doctor_id'];
|
||||
$item['appointment_doctor_name'] = $doctorNames[$apt['doctor_id']] ?? '-';
|
||||
$timePart = $apt['appointment_time'] ?? '';
|
||||
@@ -140,6 +141,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$item['appointment_time_text'] = trim(($apt['appointment_date'] ?? '') . ' ' . $timePart);
|
||||
} else {
|
||||
$item['has_appointment'] = 0;
|
||||
$item['appointment_id'] = null;
|
||||
$item['appointment_doctor_id'] = null;
|
||||
$item['appointment_doctor_name'] = '';
|
||||
$item['appointment_time_text'] = '';
|
||||
@@ -148,6 +150,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
} else {
|
||||
foreach ($lists as &$item) {
|
||||
$item['has_appointment'] = 0;
|
||||
$item['appointment_id'] = null;
|
||||
$item['appointment_doctor_id'] = null;
|
||||
$item['appointment_doctor_name'] = '';
|
||||
$item['appointment_time_text'] = '';
|
||||
|
||||
@@ -52,6 +52,16 @@ class AdminLogic extends BaseLogic
|
||||
$defaultAvatar = config('project.default_image.admin_avatar');
|
||||
$avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
|
||||
|
||||
// 处理资质图片:如果是数组则转为JSON字符串
|
||||
$qualificationImages = '';
|
||||
if (isset($params['qualification_images'])) {
|
||||
if (is_array($params['qualification_images'])) {
|
||||
$qualificationImages = json_encode($params['qualification_images'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
} else {
|
||||
$qualificationImages = $params['qualification_images'];
|
||||
}
|
||||
}
|
||||
|
||||
$admin = Admin::create([
|
||||
'name' => $params['name'],
|
||||
'account' => $params['account'],
|
||||
@@ -71,6 +81,7 @@ class AdminLogic extends BaseLogic
|
||||
'experience' => $params['experience'] ?? null,
|
||||
'honors' => $params['honors'] ?? null,
|
||||
'license_no' => $params['license_no'] ?? '',
|
||||
'qualification_images' => $qualificationImages,
|
||||
'enable_image_consult' => $params['enable_image_consult'] ?? 1,
|
||||
'enable_video_consult' => $params['enable_video_consult'] ?? 1,
|
||||
'enable_charge' => $params['enable_charge'] ?? 0,
|
||||
@@ -107,6 +118,16 @@ class AdminLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 处理资质图片:如果是数组则转为JSON字符串
|
||||
$qualificationImages = '';
|
||||
if (isset($params['qualification_images'])) {
|
||||
if (is_array($params['qualification_images'])) {
|
||||
$qualificationImages = json_encode($params['qualification_images'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
} else {
|
||||
$qualificationImages = $params['qualification_images'];
|
||||
}
|
||||
}
|
||||
|
||||
// 基础信息
|
||||
$data = [
|
||||
'id' => $params['id'],
|
||||
@@ -125,6 +146,7 @@ class AdminLogic extends BaseLogic
|
||||
'experience' => $params['experience'] ?? null,
|
||||
'honors' => $params['honors'] ?? null,
|
||||
'license_no' => $params['license_no'] ?? '',
|
||||
'qualification_images' => $qualificationImages,
|
||||
'enable_image_consult' => $params['enable_image_consult'] ?? 1,
|
||||
'enable_video_consult' => $params['enable_video_consult'] ?? 1,
|
||||
'enable_charge' => $params['enable_charge'] ?? 0,
|
||||
@@ -262,10 +284,23 @@ class AdminLogic extends BaseLogic
|
||||
'multipoint_login', 'avatar',
|
||||
'gender', 'age', 'phone', 'title', 'department',
|
||||
'specialty', 'education', 'experience', 'honors',
|
||||
'license_no', 'enable_image_consult', 'enable_video_consult', 'enable_charge',
|
||||
'license_no', 'qualification_images', 'enable_image_consult', 'enable_video_consult', 'enable_charge',
|
||||
'work_wechat_userid'
|
||||
])->findOrEmpty($params['id'])->toArray();
|
||||
|
||||
// 将资质图片JSON字符串转换为数组,供前端组件使用
|
||||
if (!empty($admin['qualification_images'])) {
|
||||
try {
|
||||
$images = json_decode($admin['qualification_images'], true);
|
||||
if (is_array($images)) {
|
||||
$admin['qualification_images'] = $images;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 解析失败时保持原值
|
||||
Log::error('解析资质图片失败: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'detail') {
|
||||
$roleIds = AdminRole::where('admin_id', $params['id'])->column('role_id');
|
||||
if (in_array(2, $roleIds)) {
|
||||
|
||||
@@ -1014,6 +1014,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
|
||||
// 获取小程序配置
|
||||
$config = self::getMiniProgramConfig();
|
||||
|
||||
if (!$config) {
|
||||
throw new \Exception('小程序配置未设置');
|
||||
}
|
||||
@@ -1022,7 +1023,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
|
||||
// 调用微信接口生成小程序码
|
||||
$qrcodeUrl = self::generateWxQrcode($config, $page, $scene);
|
||||
|
||||
|
||||
if (!$qrcodeUrl) {
|
||||
throw new \Exception('生成小程序码失败: ' . self::getError());
|
||||
}
|
||||
@@ -1122,7 +1123,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
if (!$accessToken) {
|
||||
throw new \Exception('获取access_token失败: ' . self::getError());
|
||||
}
|
||||
|
||||
|
||||
// 调用微信接口生成小程序码
|
||||
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$accessToken}";
|
||||
|
||||
@@ -1213,7 +1214,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
// 从微信服务器获取
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appId}&secret={$appSecret}";
|
||||
$response = self::httpGet($url);
|
||||
|
||||
|
||||
// 记录原始响应用于调试
|
||||
\think\facade\Log::info('微信AccessToken响应: ' . $response);
|
||||
|
||||
@@ -1383,7 +1384,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
'user_id' => $userId,
|
||||
'diagnosis_id' => $diagnosisId
|
||||
])->find();
|
||||
|
||||
|
||||
$now = time();
|
||||
|
||||
if ($record) {
|
||||
@@ -1434,16 +1435,26 @@ class DiagnosisLogic extends BaseLogic
|
||||
* @param int $patientId
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getCardList(int $patientId)
|
||||
public static function getCardList(int $user_id)
|
||||
{
|
||||
try {
|
||||
if (!$patientId) {
|
||||
self::setError('患者ID不能为空');
|
||||
if (!$user_id) {
|
||||
self::setError('用户ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该患者的所有诊单
|
||||
$cardList = Diagnosis::where('patient_id', $patientId)
|
||||
// 从诊断查看记录表中获取该用户查看过的诊断ID列表
|
||||
$viewRecords = \think\facade\Db::name('diagnosis_view_records')
|
||||
->where('user_id', $user_id)
|
||||
->where('delete_time', null)
|
||||
->column('diagnosis_id');
|
||||
|
||||
if (empty($viewRecords)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 根据诊断ID列表查询诊单详情
|
||||
$cardList = Diagnosis::whereIn('id', $viewRecords)
|
||||
->where('delete_time', null)
|
||||
->field([
|
||||
'id', 'patient_id', 'patient_name', 'gender', 'age',
|
||||
@@ -1482,7 +1493,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
|
||||
return $cardList;
|
||||
} catch (\Exception $e) {
|
||||
\think\facade\Log::error('获取就诊卡列表失败 - patient_id: ' . $patientId . ', error: ' . $e->getMessage());
|
||||
\think\facade\Log::error('获取就诊卡列表失败 - user_id: ' . $user_id . ', error: ' . $e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class PrescriptionLogic
|
||||
'pulse' => $params['pulse'] ?? $diagnosis->pulse ?? '',
|
||||
'tongue' => $params['tongue'] ?? $diagnosis->tongue_coating ?? '',
|
||||
'clinical_diagnosis' => $params['clinical_diagnosis'] ?? '',
|
||||
'case_record' => $params['case_record'] ?? null,
|
||||
'herbs' => $herbs,
|
||||
'dose_count' => (int)($params['dose_count'] ?? 1),
|
||||
'dose_unit' => $params['dose_unit'] ?? '剂',
|
||||
|
||||
@@ -33,7 +33,6 @@ class DiagnosisValidate extends BaseValidate
|
||||
'age' => 'require|number|between:0,150',
|
||||
'diagnosis_date' => 'require',
|
||||
'diagnosis_type' => 'require',
|
||||
'syndrome_type' => 'require',
|
||||
'status' => 'in:0,1',
|
||||
];
|
||||
|
||||
@@ -51,7 +50,6 @@ class DiagnosisValidate extends BaseValidate
|
||||
'age.between' => '年龄范围0-150',
|
||||
'diagnosis_date.require' => '请选择诊断日期',
|
||||
'diagnosis_type.require' => '请选择诊断类型',
|
||||
'syndrome_type.require' => '请选择证型',
|
||||
'status.in' => '状态参数错误',
|
||||
];
|
||||
|
||||
|
||||
@@ -136,14 +136,14 @@ class TcmController extends BaseApiController
|
||||
*/
|
||||
public function getCardList()
|
||||
{
|
||||
$patientId = $this->request->get('patient_id');
|
||||
$user_id =$this->userId;
|
||||
|
||||
if (!$patientId) {
|
||||
if (!$user_id) {
|
||||
return $this->fail('患者ID不能为空');
|
||||
}
|
||||
|
||||
try {
|
||||
$result = DiagnosisLogic::getCardList($patientId);
|
||||
$result = DiagnosisLogic::getCardList($user_id);
|
||||
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
|
||||
@@ -104,7 +104,7 @@ class DoctorLogic extends BaseLogic
|
||||
|
||||
$doctor = Admin::where('id', $doctorId)
|
||||
->where('disable', 0)
|
||||
->field(['id', 'name', 'account', 'avatar','specialty','license_no','enable_image_consult','enable_video_consult','enable_charge'])
|
||||
->field(['id', 'name', 'account', 'qualification_images','avatar','specialty','license_no','qualification_images','enable_image_consult','enable_video_consult','enable_charge'])
|
||||
->find();
|
||||
|
||||
if (!$doctor) {
|
||||
@@ -127,6 +127,7 @@ class DoctorLogic extends BaseLogic
|
||||
'mobile' => $doctorData['mobile'] ?? '',
|
||||
'email' => $doctorData['email'] ?? '',
|
||||
'license_no' => $doctorData['license_no'] ?? '',
|
||||
'qualification_images' => $doctorData['qualification_images'] ?? '',
|
||||
'enable_image_consult' => $doctorData['enable_image_consult'] ?? 1,
|
||||
'enable_video_consult' => $doctorData['enable_video_consult'] ?? 1,
|
||||
'enable_charge' => $doctorData['enable_charge'] ?? 0,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\command;
|
||||
|
||||
use app\common\model\doctor\Appointment;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 挂号单状态自动更新
|
||||
* - 预约时间已过:status -> 4(已过号)
|
||||
* - 预约时间已过超过8小时:status -> 2(已取消)
|
||||
* - 不处理:status=3(已完成)、未到时间的单子
|
||||
*/
|
||||
class UpdateAppointmentStatus extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('update_appointment_status')
|
||||
->setDescription('自动更新挂号单状态:过号->4,超8小时->2(已取消)')
|
||||
->addOption('dry', null, Option::VALUE_NONE, '仅预览不执行');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$dryRun = $input->getOption('dry');
|
||||
$now = time();
|
||||
$table = (new Appointment())->getTable();
|
||||
|
||||
// 1. 超过8小时 -> 已取消(status=2)
|
||||
$cancelWhere = "status = 1 AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) <= DATE_SUB(NOW(), INTERVAL 8 HOUR)";
|
||||
$cancelSql = "UPDATE {$table} SET status = 2, update_time = ? WHERE {$cancelWhere}";
|
||||
$cancelCount = $dryRun ? 0 : Db::execute($cancelSql, [$now]);
|
||||
|
||||
// 2. 已过时间但未超8小时 -> 已过号(status=4)
|
||||
$missedWhere = "status = 1 AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) < NOW() AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) > DATE_SUB(NOW(), INTERVAL 8 HOUR)";
|
||||
$missedSql = "UPDATE {$table} SET status = 4, update_time = ? WHERE {$missedWhere}";
|
||||
$missedCount = $dryRun ? 0 : Db::execute($missedSql, [$now]);
|
||||
|
||||
if ($dryRun) {
|
||||
$cancelPreview = Db::query("SELECT id FROM {$table} WHERE {$cancelWhere}");
|
||||
$missedPreview = Db::query("SELECT id FROM {$table} WHERE {$missedWhere}");
|
||||
$output->writeln('[预览] 将改为已取消: ' . count($cancelPreview) . ' 条');
|
||||
$output->writeln('[预览] 将改为已过号: ' . count($missedPreview) . ' 条');
|
||||
return;
|
||||
}
|
||||
|
||||
$output->writeln("已取消(超8小时): {$cancelCount} 条");
|
||||
$output->writeln("已过号: {$missedCount} 条");
|
||||
Log::info("update_appointment_status: 已取消 {$cancelCount}, 已过号 {$missedCount}");
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ class Appointment extends BaseModel
|
||||
1 => '已预约',
|
||||
2 => '已取消',
|
||||
3 => '已完成',
|
||||
4 => '已过号',
|
||||
];
|
||||
return $statusMap[$data['status']] ?? '未知';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Prescription extends BaseModel
|
||||
protected $deleteTime = 'delete_time';
|
||||
protected $dateFormat = false;
|
||||
|
||||
protected $json = ['herbs'];
|
||||
protected $json = ['herbs', 'case_record'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
public function getGenderDescAttr($value, $data)
|
||||
|
||||
Reference in New Issue
Block a user