更新
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\order;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\order\OrderLists;
|
||||
use app\adminapi\logic\order\OrderLogic;
|
||||
use app\adminapi\validate\order\OrderValidate;
|
||||
|
||||
/**
|
||||
* 订单管理控制器
|
||||
* Class OrderController
|
||||
* @package app\adminapi\controller\order
|
||||
*/
|
||||
class OrderController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('detail');
|
||||
$detail = OrderLogic::detail($params['id']);
|
||||
|
||||
if (!$detail) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 创建订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('create');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
|
||||
$result = OrderLogic::create($params);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('创建成功', $result->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('edit');
|
||||
|
||||
$result = OrderLogic::edit($params['id'], $params);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('pay');
|
||||
|
||||
$result = OrderLogic::pay($params['id'], $params['payment_method']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('支付成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('cancel');
|
||||
|
||||
$result = OrderLogic::cancel($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('取消成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退款订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function refund()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('refund');
|
||||
|
||||
$result = OrderLogic::refund($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('退款成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('delete');
|
||||
|
||||
$result = OrderLogic::delete($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出订单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
}
|
||||
@@ -283,4 +283,38 @@ class DiagnosisController extends BaseAdminController
|
||||
$result = DiagnosisLogic::generateMiniProgramQrcode($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索患者(用于创建订单等场景)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function searchPatient()
|
||||
{
|
||||
$keyword = $this->request->get('keyword', '');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$page_size = $this->request->get('page_size', 10);
|
||||
|
||||
if (empty($keyword)) {
|
||||
return $this->success('', ['lists' => [], 'count' => 0]);
|
||||
}
|
||||
|
||||
$offset = ($page_no - 1) * $page_size;
|
||||
|
||||
$lists = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
||||
->field(['id', 'patient_name', 'patient_phone', 'patient_id_card', 'gender', 'age'])
|
||||
->limit($offset, $page_size)
|
||||
->order('id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
||||
->count();
|
||||
|
||||
return $this->success('', [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $page_no,
|
||||
'page_size' => $page_size
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,38 @@ class UserController extends BaseAdminController
|
||||
return $this->fail($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索用户(用于创建订单等场景)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$keyword = $this->request->get('keyword', '');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$page_size = $this->request->get('page_size', 10);
|
||||
|
||||
if (empty($keyword)) {
|
||||
return $this->success('', ['lists' => [], 'count' => 0]);
|
||||
}
|
||||
|
||||
$offset = ($page_no - 1) * $page_size;
|
||||
|
||||
$lists = \app\common\model\user\User::where('nickname|mobile|account', 'like', '%' . $keyword . '%')
|
||||
->field(['id', 'nickname', 'mobile', 'account', 'avatar'])
|
||||
->limit($offset, $page_size)
|
||||
->order('id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = \app\common\model\user\User::where('nickname|mobile|account', 'like', '%' . $keyword . '%')
|
||||
->count();
|
||||
|
||||
return $this->success('', [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $page_no,
|
||||
'page_size' => $page_size
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\lists\order;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Order;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* Class OrderLists
|
||||
* @package app\adminapi\lists\order
|
||||
*/
|
||||
class OrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return array
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['order_type', 'status'],
|
||||
'like' => ['order_no'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$where = $this->searchWhere;
|
||||
|
||||
// 处理患者关键词搜索
|
||||
if (!empty($this->params['patient_keyword'])) {
|
||||
$where[] = ['patient_id', 'in', function ($query) {
|
||||
$query->table('user')
|
||||
->where('nickname|mobile', 'like', '%' . $this->params['patient_keyword'] . '%')
|
||||
->field('id');
|
||||
}];
|
||||
}
|
||||
|
||||
// 处理创建时间范围
|
||||
if (!empty($this->params['create_time_start'])) {
|
||||
$where[] = ['create_time', '>=', $this->params['create_time_start'] . ' 00:00:00'];
|
||||
}
|
||||
|
||||
if (!empty($this->params['create_time_end'])) {
|
||||
$where[] = ['create_time', '<=', $this->params['create_time_end'] . ' 23:59:59'];
|
||||
}
|
||||
|
||||
return Order::where($where)
|
||||
->with(['patient', 'creator', 'details'])
|
||||
->order(['create_time' => 'desc'])
|
||||
->limit($this->limitOffset, $this->pageSize)
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$where = $this->searchWhere;
|
||||
|
||||
// 处理患者关键词搜索
|
||||
if (!empty($this->params['patient_keyword'])) {
|
||||
$where[] = ['patient_id', 'in', function ($query) {
|
||||
$query->table('user')
|
||||
->where('nickname|mobile', 'like', '%' . $this->params['patient_keyword'] . '%')
|
||||
->field('id');
|
||||
}];
|
||||
}
|
||||
|
||||
// 处理创建时间范围
|
||||
if (!empty($this->params['create_time_start'])) {
|
||||
$where[] = ['create_time', '>=', $this->params['create_time_start'] . ' 00:00:00'];
|
||||
}
|
||||
|
||||
if (!empty($this->params['create_time_end'])) {
|
||||
$where[] = ['create_time', '<=', $this->params['create_time_end'] . ' 23:59:59'];
|
||||
}
|
||||
|
||||
return Order::where($where)->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\logic\order;
|
||||
|
||||
use app\common\model\Order;
|
||||
use app\common\model\OrderDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 订单业务逻辑
|
||||
* Class OrderLogic
|
||||
* @package app\adminapi\logic\order
|
||||
*/
|
||||
class OrderLogic
|
||||
{
|
||||
/**
|
||||
* @notes 生成订单号
|
||||
* @return string
|
||||
*/
|
||||
public static function generateOrderNo(): string
|
||||
{
|
||||
return 'ORD' . date('YmdHis') . mt_rand(100000, 999999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 创建订单
|
||||
* @param array $params
|
||||
* @return Order|false
|
||||
*/
|
||||
public static function create(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$order = new Order();
|
||||
$order->order_no = self::generateOrderNo();
|
||||
$order->patient_id = $params['patient_id'];
|
||||
$order->creator_id = $params['creator_id'];
|
||||
$order->order_type = $params['order_type'];
|
||||
$order->amount = $params['amount'];
|
||||
$order->status = 1; // 待支付
|
||||
$order->remark = $params['remark'] ?? '';
|
||||
$order->save();
|
||||
|
||||
// 创建订单详情
|
||||
if (!empty($params['details'])) {
|
||||
foreach ($params['details'] as $detail) {
|
||||
$orderDetail = new OrderDetail();
|
||||
$orderDetail->order_id = $order->id;
|
||||
$orderDetail->related_type = $detail['related_type'];
|
||||
$orderDetail->related_id = $detail['related_id'];
|
||||
$orderDetail->quantity = $detail['quantity'] ?? 1;
|
||||
$orderDetail->unit_price = $detail['unit_price'];
|
||||
$orderDetail->total_price = $detail['total_price'];
|
||||
$orderDetail->save();
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return $order;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑订单
|
||||
* @param int $id
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit(int $id, array $params): bool
|
||||
{
|
||||
try {
|
||||
$order = Order::find($id);
|
||||
if (!$order) {
|
||||
self::setError('订单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($params['remark'])) {
|
||||
$order->remark = $params['remark'];
|
||||
}
|
||||
|
||||
$order->save();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付订单
|
||||
* @param int $id
|
||||
* @param string $paymentMethod
|
||||
* @return bool
|
||||
*/
|
||||
public static function pay(int $id, string $paymentMethod): bool
|
||||
{
|
||||
try {
|
||||
$order = Order::find($id);
|
||||
if (!$order) {
|
||||
self::setError('订单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order->status != 1) {
|
||||
self::setError('订单状态不允许支付');
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->status = 2; // 已支付
|
||||
$order->payment_method = $paymentMethod;
|
||||
$order->payment_time = date('Y-m-d H:i:s');
|
||||
$order->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function cancel(int $id): bool
|
||||
{
|
||||
try {
|
||||
$order = Order::find($id);
|
||||
if (!$order) {
|
||||
self::setError('订单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order->status != 1) {
|
||||
self::setError('只有待支付的订单才能取消');
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->status = 3; // 已取消
|
||||
$order->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退款订单
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function refund(int $id): bool
|
||||
{
|
||||
try {
|
||||
$order = Order::find($id);
|
||||
if (!$order) {
|
||||
self::setError('订单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order->status != 2) {
|
||||
self::setError('只有已支付的订单才能退款');
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->status = 4; // 已退款
|
||||
$order->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete(int $id): bool
|
||||
{
|
||||
try {
|
||||
$order = Order::find($id);
|
||||
if (!$order) {
|
||||
self::setError('订单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 删除订单详情
|
||||
OrderDetail::where('order_id', $id)->delete();
|
||||
|
||||
// 删除订单
|
||||
$order->delete();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取订单详情
|
||||
* @param int $id
|
||||
* @return array|null
|
||||
*/
|
||||
public static function detail(int $id): ?array
|
||||
{
|
||||
$order = Order::with(['patient', 'creator', 'details'])
|
||||
->find($id);
|
||||
|
||||
if (!$order) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $order->toArray();
|
||||
}
|
||||
|
||||
private static $error = '';
|
||||
|
||||
public static function setError(string $error): void
|
||||
{
|
||||
self::$error = $error;
|
||||
}
|
||||
|
||||
public static function getError(): string
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
try {
|
||||
// 获取配置
|
||||
$config = self::getTrtcConfig();
|
||||
|
||||
|
||||
if (!$config) {
|
||||
self::setError('请先配置腾讯云TRTC参数');
|
||||
return false;
|
||||
@@ -1197,4 +1197,158 @@ class DiagnosisLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取就诊卡列表(供小程序调用)
|
||||
* @param int $patientId
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getCardList(int $patientId)
|
||||
{
|
||||
try {
|
||||
if (!$patientId) {
|
||||
self::setError('患者ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该患者的所有诊单
|
||||
$cardList = Diagnosis::where('patient_id', $patientId)
|
||||
->where('delete_time', null)
|
||||
->field([
|
||||
'id', 'patient_id', 'patient_name', 'gender', 'age',
|
||||
'diagnosis_date', 'diagnosis_type', 'syndrome_type',
|
||||
'status', 'create_time', 'update_time'
|
||||
])
|
||||
->order('create_time', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理数据格式
|
||||
foreach ($cardList as &$card) {
|
||||
// 转换诊断日期为时间戳和格式化文本
|
||||
if ($card['diagnosis_date']) {
|
||||
$card['diagnosis_date_text'] = date('Y-m-d', $card['diagnosis_date']);
|
||||
} else {
|
||||
$card['diagnosis_date_text'] = '-';
|
||||
}
|
||||
|
||||
// 添加性别描述
|
||||
$card['gender_desc'] = $card['gender'] == 1 ? '男' : '女';
|
||||
|
||||
// 添加状态描述
|
||||
$card['status_desc'] = $card['status'] == 1 ? '启用' : '禁用';
|
||||
|
||||
// 格式化创建时间
|
||||
if ($card['create_time']) {
|
||||
$card['create_time'] = date('Y-m-d H:i:s', $card['create_time']);
|
||||
}
|
||||
|
||||
// 格式化更新时间
|
||||
if ($card['update_time']) {
|
||||
$card['update_time'] = date('Y-m-d H:i:s', $card['update_time']);
|
||||
}
|
||||
}
|
||||
|
||||
return $cardList;
|
||||
} catch (\Exception $e) {
|
||||
\think\facade\Log::error('获取就诊卡列表失败 - patient_id: ' . $patientId . ', error: ' . $e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新就诊卡(供小程序调用)
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateCard(array $params)
|
||||
{
|
||||
try {
|
||||
$diagnosisId = $params['id'] ?? 0;
|
||||
$patientId = $params['patient_id'] ?? 0;
|
||||
|
||||
if (!$diagnosisId) {
|
||||
self::setError('诊单ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$patientId) {
|
||||
self::setError('患者ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取诊单信息
|
||||
$diagnosis = Diagnosis::find($diagnosisId);
|
||||
|
||||
if (!$diagnosis) {
|
||||
self::setError('诊单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 权限验证:只能修改自己的诊单
|
||||
if ($diagnosis->patient_id != $patientId) {
|
||||
\think\facade\Log::warning('非法修改诊单 - diagnosis_id: ' . $diagnosisId . ', patient_id: ' . $patientId . ', actual_patient_id: ' . $diagnosis->patient_id);
|
||||
self::setError('无权限修改此诊单');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 准备更新数据
|
||||
$updateData = [
|
||||
'patient_name' => $params['patient_name'] ?? '',
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'age' => $params['age'] ?? 0,
|
||||
'diagnosis_type' => $params['diagnosis_type'] ?? '',
|
||||
'syndrome_type' => $params['syndrome_type'] ?? '',
|
||||
'diabetes_type' => $params['diabetes_type'] ?? '',
|
||||
// 现病史字段
|
||||
'appetite' => $params['appetite'] ?? '',
|
||||
'water_intake' => $params['water_intake'] ?? '',
|
||||
'diet_condition' => $params['diet_condition'] ?? '',
|
||||
'weight_change' => $params['weight_change'] ?? '',
|
||||
'body_feeling' => $params['body_feeling'] ?? '',
|
||||
'sleep_condition' => $params['sleep_condition'] ?? '',
|
||||
'eye_condition' => $params['eye_condition'] ?? '',
|
||||
'head_feeling' => $params['head_feeling'] ?? '',
|
||||
'sweat_condition' => $params['sweat_condition'] ?? '',
|
||||
'skin_condition' => $params['skin_condition'] ?? '',
|
||||
'urine_condition' => $params['urine_condition'] ?? '',
|
||||
'stool_condition' => $params['stool_condition'] ?? '',
|
||||
'kidney_condition' => $params['kidney_condition'] ?? '',
|
||||
'fatty_liver_degree' => $params['fatty_liver_degree'] ?? '',
|
||||
// 既往史字段
|
||||
'past_history' => $params['past_history'] ?? '',
|
||||
'trauma_history' => $params['trauma_history'] ?? 0,
|
||||
'surgery_history' => $params['surgery_history'] ?? 0,
|
||||
'allergy_history' => $params['allergy_history'] ?? 0,
|
||||
'family_history' => $params['family_history'] ?? 0,
|
||||
'pregnancy_history' => $params['pregnancy_history'] ?? 0,
|
||||
// 临床信息
|
||||
'symptoms' => $params['symptoms'] ?? '',
|
||||
'tongue_coating' => $params['tongue_coating'] ?? '',
|
||||
'pulse' => $params['pulse'] ?? '',
|
||||
'treatment_principle' => $params['treatment_principle'] ?? '',
|
||||
'prescription' => $params['prescription'] ?? '',
|
||||
'doctor_advice' => $params['doctor_advice'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
// 处理诊断日期
|
||||
if (!empty($params['diagnosis_date'])) {
|
||||
$updateData['diagnosis_date'] = strtotime($params['diagnosis_date']);
|
||||
}
|
||||
|
||||
// 执行更新
|
||||
$diagnosis->save($updateData);
|
||||
|
||||
\think\facade\Log::info('诊单更新成功 - diagnosis_id: ' . $diagnosisId . ', patient_id: ' . $patientId);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\think\facade\Log::error('更新诊单失败 - error: ' . $e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\order;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 订单验证
|
||||
* Class OrderValidate
|
||||
* @package app\adminapi\validate\order
|
||||
*/
|
||||
class OrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'patient_id' => 'require|integer',
|
||||
'creator_id' => 'require|integer',
|
||||
'order_type' => 'require|in:1,2,3',
|
||||
'amount' => 'require|float',
|
||||
'status' => 'require|in:1,2,3,4',
|
||||
'payment_method' => 'in:alipay,wechat,bank',
|
||||
'remark' => 'string|max:500',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'patient_id.require' => '患者ID必填',
|
||||
'creator_id.require' => '创建人ID必填',
|
||||
'order_type.require' => '订单类型必填',
|
||||
'order_type.in' => '订单类型不正确',
|
||||
'amount.require' => '订单金额必填',
|
||||
'status.require' => '订单状态必填',
|
||||
'status.in' => '订单状态不正确',
|
||||
'payment_method.in' => '支付方式不正确',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['patient_id', 'creator_id', 'order_type', 'amount'],
|
||||
'edit' => ['id', 'remark'],
|
||||
'detail' => ['id'],
|
||||
'pay' => ['id', 'payment_method'],
|
||||
'cancel' => ['id'],
|
||||
'refund' => ['id'],
|
||||
'delete' => ['id'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user