Files
zyt/server/app/common/model/tcm/DiagnosisTodo.php
T
2026-05-05 12:42:09 +08:00

100 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台(PHP版)
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,可去除界面版权logo
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
// | github下载:https://github.com/likeshop-github/likeadmin
// | 访问官网:https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\tcm;
use app\common\model\BaseModel;
/**
* 诊单待办事项模型
*
* 状态机:0=待执行 → 1=已发送 / 2=已取消 / 3=发送失败(终态,不重试)
*
* @package app\common\model\tcm
*/
class DiagnosisTodo extends BaseModel
{
protected $name = 'tcm_diagnosis_todo';
// 自动时间戳类型设置为整型
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
// 取出字段保持整型,前端按需要再格式化
protected $dateFormat = false;
/** 状态:待执行 */
public const STATUS_PENDING = 0;
/** 状态:已发送(成功) */
public const STATUS_SENT = 1;
/** 状态:已取消(人工) */
public const STATUS_CANCELLED = 2;
/** 状态:发送失败(终态,不重试) */
public const STATUS_FAILED = 3;
/**
* 状态文本映射
*
* @var array<int,string>
*/
public const STATUS_TEXT_MAP = [
self::STATUS_PENDING => '待执行',
self::STATUS_SENT => '已发送',
self::STATUS_CANCELLED => '已取消',
self::STATUS_FAILED => '发送失败',
];
/**
* @notes 状态文本访问器
*/
public function getStatusTextAttr($value, $data): string
{
$status = (int) ($data['status'] ?? 0);
return self::STATUS_TEXT_MAP[$status] ?? '未知';
}
/**
* @notes 提醒时间格式化(Y-m-d H:i
*/
public function getRemindTimeTextAttr($value, $data): string
{
$ts = (int) ($data['remind_time'] ?? 0);
return $ts > 0 ? date('Y-m-d H:i', $ts) : '';
}
/**
* @notes 推送时间格式化
*/
public function getNotifiedAtTextAttr($value, $data): string
{
$ts = (int) ($data['notified_at'] ?? 0);
return $ts > 0 ? date('Y-m-d H:i', $ts) : '';
}
/**
* @notes 取消时间格式化
*/
public function getCancelledAtTextAttr($value, $data): string
{
$ts = (int) ($data['cancelled_at'] ?? 0);
return $ts > 0 ? date('Y-m-d H:i', $ts) : '';
}
}