This commit is contained in:
Your Name
2026-11-26 15:46:20 +08:00
parent db6d327e91
commit be79e09c83
170 changed files with 21159 additions and 13217 deletions
+85 -3
View File
@@ -2,6 +2,16 @@
declare(strict_types=1);
namespace app\common\service\esign {
final class PrescriptionReviewEsignService
{
public static array $calls = [];
public static function confirm(int $id, int $orderId, int $actor, array $info, bool $verifyOnly): array
{
self::$calls[] = [$id, $orderId, $actor, $verifyOnly];
return ['state' => 'signed'];
}
}
final class PrescriptionEsignService
{
public static array $calls = [];
@@ -33,6 +43,30 @@ namespace app\common\model {
public function save(): bool { self::$saved[] = $this->fields; return true; }
}
}
namespace app\adminapi\logic\tcm {
final class PrescriptionLogic
{
public static bool $auditOk = true;
public static ?array $notice = null;
public static function audit(int $id, string $action, string $remark, int $actor, array $info): bool
{
return self::$auditOk;
}
public static function getError(): string
{
return '无审核权限';
}
public static function consumeLastAuditWecomNotify(): ?array
{
$notice = self::$notice;
self::$notice = null;
return $notice;
}
}
}
namespace app\adminapi\controller {
class BaseAdminController
{
@@ -40,8 +74,17 @@ namespace app\adminapi\controller {
public int $adminId = 7;
public array $adminInfo = ['admin_id' => 7, 'name' => '测试医师'];
public function isNotNeedLogin(): bool { return false; }
protected function data(array $data): array { return ['code' => 1, 'data' => $data]; }
protected function data(array $data): \ArrayObject
{
return new class(['code' => 1, 'data' => $data]) extends \ArrayObject {
public function header(array $headers): self { return $this; }
};
}
protected function fail(string $message): array { return ['code' => 0, 'msg' => $message]; }
protected function success(string $message, array $data = []): array
{
return ['code' => 1, 'msg' => $message, 'data' => $data];
}
}
}
namespace {
@@ -68,7 +111,7 @@ namespace {
think\Container::getInstance()->instance('request', $request);
$response = new class($result) {
public function __construct(private array $result) {}
public function __construct(private \ArrayObject $result) {}
public function getContent(): string { return json_encode($this->result); }
};
(new app\adminapi\listener\OperationLog())->handle($response);
@@ -93,6 +136,24 @@ namespace {
$expect($controller->esignStart()['code'] === 0 && count(app\common\service\esign\PrescriptionEsignService::$starts) === 1, 'invalid replacement flag cannot change identity flow');
}
foreach ([false, true] as $verifyOnly) {
$controller->request = (new app\Request())->setMethod('POST')->withPost([
'id' => 42, 'order_id' => 5, 'actor_id' => 7, 'verify_only' => $verifyOnly,
]);
$expect($controller->esignReviewConfirm()['code'] === 1, 'review accepts a JSON boolean without the global trim filter');
}
$expect(app\common\service\esign\PrescriptionReviewEsignService::$calls === [[42, 5, 7, false], [42, 5, 7, true]],
'review confirmation preserves the explicit sign versus verify choice');
foreach ([null, 'false', 'true', 0, 1, []] as $invalid) {
$controller->request = (new app\Request())->setMethod('POST')->withPost([
'id' => 42, 'actor_id' => 7, 'verify_only' => $invalid,
]);
$expect($controller->esignReviewConfirm()['code'] === 0, 'malformed review flag never dispatches');
}
$controller->request = (new app\Request())->setMethod('POST')->withPost(['id' => 42, 'actor_id' => 8, 'verify_only' => false]);
$expect($controller->esignReviewConfirm()['code'] === 0
&& count(app\common\service\esign\PrescriptionReviewEsignService::$calls) === 2, 'actor mismatch cannot dispatch review');
$code = '023941';
$mobile = '13800000000';
$authUrl = 'https://smlt.esign.cn/example/private-auth-url';
@@ -123,5 +184,26 @@ namespace {
$expect(!str_contains($entry, $mobile) && !str_contains($entry, $number) && !str_contains($entry, $code)
&& !str_contains($audit['result'], 'private-auth-url'), "$action audit omits signing secrets and authorization URL");
}
echo "eSign identity controller/privacy: $checks checks passed (isolated doubles, no DB/network)\n";
$auditRequest = (new app\Request())->setMethod('POST');
$controller->request = $auditRequest;
think\Container::getInstance()->instance('request', $auditRequest);
think\Validate::maker(static function (think\Validate $validate) use ($auditRequest, $app): void {
$validate->setRequest($auditRequest);
$validate->setLang(new think\Lang($app));
});
foreach (['approve' => '审核通过', 'reject' => '已驳回并作废处方'] as $action => $message) {
$auditRequest->withPost(['id' => 42, 'action' => $action, 'remark' => '虚构测试']);
app\adminapi\logic\tcm\PrescriptionLogic::$notice = [
'ok' => false, 'errcode' => 81013, 'message' => 'user & party & tag all invalid, private provider diagnostic',
];
$expect($controller->audit() === ['code' => 1, 'msg' => $message, 'data' => ['wecom_notify_ok' => false]],
"$action stays successful and never exposes a WeCom notification error");
}
app\adminapi\logic\tcm\PrescriptionLogic::$notice = ['ok' => true];
$auditRequest->withPost(['id' => 42, 'action' => 'approve']);
$expect($controller->audit()['data'] === ['wecom_notify_ok' => true], 'successful delivery status remains available');
app\adminapi\logic\tcm\PrescriptionLogic::$auditOk = false;
$expect($controller->audit() === ['code' => 0, 'msg' => '无审核权限'], 'actual audit denial is still returned');
echo "eSign identity and prescription audit controller/privacy: $checks checks passed (isolated doubles, no DB/network)\n";
}