更新
This commit is contained in:
@@ -7,7 +7,9 @@ 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\DoctorEsignIdentityService;
|
||||
use app\common\service\esign\PrescriptionEsignService;
|
||||
use app\common\service\esign\PrescriptionReviewEsignService;
|
||||
|
||||
/**
|
||||
* 中医处方单控制器
|
||||
@@ -171,12 +173,14 @@ class PrescriptionController extends BaseAdminController
|
||||
*/
|
||||
public function void()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->fail('请使用 POST 作废处方');
|
||||
}
|
||||
$id = (int)($this->request->post('id') ?? 0);
|
||||
if (!$id) {
|
||||
if ($id <= 0) {
|
||||
return $this->fail('处方ID不能为空');
|
||||
}
|
||||
$admin = $this->adminInfo;
|
||||
$ok = PrescriptionLogic::void($id, (int)$this->adminId, $admin['name'] ?? '');
|
||||
$ok = PrescriptionLogic::void($id, $this->adminId, $this->adminInfo);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
@@ -193,6 +197,11 @@ class PrescriptionController extends BaseAdminController
|
||||
return $this->esignOperation('status', false);
|
||||
}
|
||||
|
||||
public function esignIdentityStatus()
|
||||
{
|
||||
return $this->esignOperation('identityStatus', false);
|
||||
}
|
||||
|
||||
public function esignStart()
|
||||
{
|
||||
return $this->esignOperation('start', true);
|
||||
@@ -203,11 +212,102 @@ class PrescriptionController extends BaseAdminController
|
||||
return $this->esignOperation('complete', true);
|
||||
}
|
||||
|
||||
/** @notes 验证处方签署短信 */
|
||||
public function esignVerifyWillingness()
|
||||
{
|
||||
return $this->esignOperation('verifyWillingness', true);
|
||||
}
|
||||
|
||||
public function esignDownload()
|
||||
{
|
||||
return $this->esignOperation('download', false);
|
||||
}
|
||||
|
||||
public function esignReviewStatus()
|
||||
{
|
||||
return $this->esignReviewOperation(false);
|
||||
}
|
||||
|
||||
public function esignReviewConfirm()
|
||||
{
|
||||
return $this->esignReviewOperation(true);
|
||||
}
|
||||
|
||||
private function esignReviewOperation(bool $confirm)
|
||||
{
|
||||
if ($confirm ? !$this->request->isPost() : !$this->request->isGet()) {
|
||||
return $this->fail($confirm ? '请使用 POST 请求' : '请使用 GET 请求');
|
||||
}
|
||||
$params = $confirm ? $this->request->post() : $this->request->get();
|
||||
$id = (int) ($params['id'] ?? 0);
|
||||
$orderId = (int) ($params['order_id'] ?? 0);
|
||||
$actor = (int) $this->adminId;
|
||||
$verifyOnly = $params['verify_only'] ?? false;
|
||||
if ($id <= 0 || $orderId < 0 || !is_bool($verifyOnly)) {
|
||||
return $this->fail('审核签署参数无效');
|
||||
}
|
||||
if ($confirm && (int) ($params['actor_id'] ?? 0) !== $actor) {
|
||||
return $this->fail('登录账号已切换,请刷新并由当前审核人确认');
|
||||
}
|
||||
try {
|
||||
if ($confirm) {
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(360);
|
||||
}
|
||||
$data = $confirm
|
||||
? PrescriptionReviewEsignService::confirm($id, $orderId, $actor, $this->adminInfo, $verifyOnly)
|
||||
: PrescriptionReviewEsignService::status($id, $orderId, $actor, $this->adminInfo);
|
||||
return $this->data($data)->header(['Cache-Control' => 'private, no-store']);
|
||||
} catch (\app\common\service\esign\DoctorEsignAuthorizationRequired) {
|
||||
return $this->fail('审核人快捷签授权需要开通或续期,请在「审核签署身份」中处理');
|
||||
} catch (\Throwable $error) {
|
||||
return $this->fail($error instanceof \DomainException || $error instanceof \app\common\service\esign\EsignProviderException
|
||||
? $error->getMessage() : '审核签署暂不可用,请刷新状态后重试');
|
||||
}
|
||||
}
|
||||
|
||||
/** @notes 查询医师电子签署认证 */
|
||||
public function esignDoctorStatus()
|
||||
{
|
||||
return $this->esignDoctorOperation('status', false);
|
||||
}
|
||||
|
||||
/** @notes 发起医师电子签署认证 */
|
||||
public function esignDoctorStart()
|
||||
{
|
||||
return $this->esignDoctorOperation('start', true, 'mobile');
|
||||
}
|
||||
|
||||
/** @notes 完成医师电子签署认证 */
|
||||
public function esignDoctorComplete()
|
||||
{
|
||||
return $this->esignDoctorOperation('complete', true, 'identity_number');
|
||||
}
|
||||
|
||||
private function esignDoctorOperation(string $operation, bool $post, string $field = '')
|
||||
{
|
||||
if ($post ? !$this->request->isPost() : !$this->request->isGet()) {
|
||||
return $this->fail($post ? '请使用 POST 请求' : '请使用 GET 请求');
|
||||
}
|
||||
try {
|
||||
if (!$post) {
|
||||
return $this->data(DoctorEsignIdentityService::status((int) $this->adminId))
|
||||
->header(['Cache-Control' => 'private, no-store']);
|
||||
}
|
||||
$input = $this->request->post($field, '');
|
||||
if (!is_string($input)) {
|
||||
return $this->fail($field === 'mobile' ? '手机号格式无效' : '身份证号码格式无效');
|
||||
}
|
||||
if ($operation === 'complete') {
|
||||
ignore_user_abort(true);
|
||||
}
|
||||
return $this->data(DoctorEsignIdentityService::{$operation}((int) $this->adminId, $input))
|
||||
->header(['Cache-Control' => 'private, no-store']);
|
||||
} catch (\Throwable $error) {
|
||||
return $this->fail($error instanceof \DomainException ? $error->getMessage() : '医师认证暂不可用,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
private function esignOperation(string $operation, bool $post)
|
||||
{
|
||||
if ($post && !$this->request->isPost()) {
|
||||
@@ -223,6 +323,35 @@ class PrescriptionController extends BaseAdminController
|
||||
set_time_limit(300);
|
||||
}
|
||||
try {
|
||||
$body = $post ? $this->request->post(false) : [];
|
||||
if ($operation === 'verifyWillingness') {
|
||||
$code = $this->request->post('auth_code', '');
|
||||
if (!is_string($code)) {
|
||||
return $this->fail('短信验证码格式无效');
|
||||
}
|
||||
return $this->data(PrescriptionEsignService::verifyWillingness($id, (int) $this->adminId,
|
||||
$this->adminInfo, $code));
|
||||
}
|
||||
if ($operation === 'start') {
|
||||
$restartIdentity = array_key_exists('restart_identity', $body) ? $body['restart_identity'] : false;
|
||||
if (!is_bool($restartIdentity)) {
|
||||
return $this->fail('重新核身标记格式无效');
|
||||
}
|
||||
return $this->data(PrescriptionEsignService::start($id, (int) $this->adminId,
|
||||
$this->adminInfo, $restartIdentity));
|
||||
}
|
||||
if ($operation === 'complete') {
|
||||
$verifyOnly = array_key_exists('verify_only', $body) ? $body['verify_only'] : false;
|
||||
if (!is_bool($verifyOnly)) {
|
||||
return $this->fail('验签标记格式无效');
|
||||
}
|
||||
$identityNumber = $this->request->post('identity_number', '');
|
||||
if (!is_string($identityNumber)) {
|
||||
return $this->fail('身份证号码格式无效');
|
||||
}
|
||||
return $this->data(PrescriptionEsignService::complete($id, (int) $this->adminId,
|
||||
$this->adminInfo, $identityNumber, $verifyOnly));
|
||||
}
|
||||
return $this->data(PrescriptionEsignService::{$operation}($id, (int) $this->adminId, $this->adminInfo));
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail($e instanceof \DomainException ? $e->getMessage() : '电子签署暂不可用,请联系管理员');
|
||||
|
||||
Reference in New Issue
Block a user