This commit is contained in:
Your Name
2026-11-17 17:06:05 +08:00
parent 08892f4270
commit 378bf32069
51 changed files with 4656 additions and 103 deletions
@@ -7,6 +7,7 @@ namespace app\adminapi\controller\tcm;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\logic\tcm\PrescriptionLogic;
use app\adminapi\validate\tcm\PrescriptionValidate;
use app\common\service\esign\PrescriptionEsignService;
/**
* 中医处方单控制器
@@ -32,7 +33,7 @@ class PrescriptionController extends BaseAdminController
if ($id === null) {
return $this->fail(PrescriptionLogic::getError());
}
return $this->success('保存成功', ['id' => $id]);
return $this->success('保存成功', ['id' => $id, 'esign' => PrescriptionEsignService::status($id, (int) $this->adminId, $this->adminInfo)]);
}
/**
@@ -45,7 +46,7 @@ class PrescriptionController extends BaseAdminController
if (!$result) {
return $this->fail(PrescriptionLogic::getError());
}
return $this->success('编辑成功');
return $this->success('编辑成功', ['id' => (int) $params['id'], 'esign' => PrescriptionEsignService::status((int) $params['id'], (int) $this->adminId, $this->adminInfo)]);
}
/**
@@ -181,4 +182,50 @@ class PrescriptionController extends BaseAdminController
}
return $this->success('作废成功');
}
public function esignConfig()
{
return $this->data(PrescriptionEsignService::capability());
}
public function esignStatus()
{
return $this->esignOperation('status', false);
}
public function esignStart()
{
return $this->esignOperation('start', true);
}
public function esignComplete()
{
return $this->esignOperation('complete', true);
}
public function esignDownload()
{
return $this->esignOperation('download', false);
}
private function esignOperation(string $operation, bool $post)
{
if ($post && !$this->request->isPost()) {
return $this->fail('请使用 POST 请求');
}
$id = (int) ($post ? $this->request->post('id', 0) : $this->request->get('id', 0));
if ($id <= 0) {
return $this->fail('处方ID无效');
}
if ($operation === 'complete') {
// A browser disconnect must not interrupt archival after signing.
ignore_user_abort(true);
set_time_limit(300);
}
try {
return $this->data(PrescriptionEsignService::{$operation}($id, (int) $this->adminId, $this->adminInfo));
} catch (\Throwable $e) {
return $this->fail($e instanceof \DomainException ? $e->getMessage() : '电子签署暂不可用,请联系管理员');
}
}
}