管理员列表支持解除电子签署身份,处理同一实名绑定冲突
e签宝 对同一证件只签发一个签署账号,同一实名在另一后台账号认证时会绑定冲突。 - 新增 auth.admin/esignUnbind:清除目标账号在当前 e签宝 应用下的签署账号绑定、 在途认证与快捷签授权;有在途操作时拒绝;不注销 e签宝 账号,已签处方不受影响 - 该接口加入 AuthMiddleware 强制鉴权列表,菜单未登记时也不放行; 迁移 2026_11_27_admin_esign_unbind_menu.sql 登记按钮权限,默认仅超级管理员可用 - 管理员列表显示「签署身份」并提供「解除签署」按钮 - 绑定冲突提示指明占用的后台账号(名称 + ID) - 医师认证失败日志把字段写进消息正文(ThinkPHP 不落盘 context) Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5 (1M context)
parent
e4d788ed32
commit
2019f9dca1
@@ -528,13 +528,56 @@ final class DoctorEsignIdentityService
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns doctor_id => signer name for accounts bound under the current eSign application. */
|
||||
public static function signerNames(array $doctorIds): array
|
||||
{
|
||||
$doctorIds = array_values(array_filter(array_map('intval', $doctorIds)));
|
||||
if ($doctorIds === []) {
|
||||
return [];
|
||||
}
|
||||
return Db::name('doctor_esign_account')->where(self::configuredScope())
|
||||
->whereIn('doctor_id', $doctorIds)->column('doctor_name', 'doctor_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员解除某后台账号的签署身份(当前 e签宝 应用),同一实名才能改绑到另一个后台账号。
|
||||
* 已签处方保留原签署证据,不受影响。
|
||||
*/
|
||||
public static function unbind(int $doctorId): void
|
||||
{
|
||||
if ($doctorId <= 0) {
|
||||
throw new DomainException('管理员ID无效');
|
||||
}
|
||||
$scope = ['doctor_id' => $doctorId] + self::configuredScope();
|
||||
Db::transaction(static function () use ($scope): void {
|
||||
$account = Db::name('doctor_esign_account')->where($scope)->lock(true)->find();
|
||||
foreach ([self::IDENTITY_FLOW_TABLE, self::QUICK_FLOW_TABLE] as $table) {
|
||||
if (self::hasLease(Db::name($table)->where($scope)->lock(true)->find())) {
|
||||
throw new DomainException('该账号的签署身份正在处理中,请稍后再试');
|
||||
}
|
||||
}
|
||||
if (!$account) {
|
||||
throw new DomainException('该账号未绑定签署身份');
|
||||
}
|
||||
Db::name('doctor_esign_account')->where($scope)->delete();
|
||||
// 认证与快捷签授权都挂在旧签署账号上,一并清除,避免解绑后继续沿用。
|
||||
Db::name(self::IDENTITY_FLOW_TABLE)->where($scope)->delete();
|
||||
Db::name(self::QUICK_FLOW_TABLE)->where($scope)->delete();
|
||||
});
|
||||
}
|
||||
|
||||
private static function configuredScope(): array
|
||||
{
|
||||
return ['environment' => (string) Config::get('esign.environment', 'sandbox'),
|
||||
'app_id' => (string) Config::get('esign.app_id', '')];
|
||||
}
|
||||
|
||||
private static function scope(int $actor): array
|
||||
{
|
||||
if (!self::enabled()) {
|
||||
throw new DomainException('医师电子签署认证尚未启用');
|
||||
}
|
||||
return ['doctor_id' => $actor, 'environment' => (string) Config::get('esign.environment', 'sandbox'),
|
||||
'app_id' => (string) Config::get('esign.app_id', '')];
|
||||
return ['doctor_id' => $actor] + self::configuredScope();
|
||||
}
|
||||
|
||||
private static function snapshot(array $scope, bool $lock = false, string $flowTable = self::IDENTITY_FLOW_TABLE): array
|
||||
@@ -625,7 +668,14 @@ final class DoctorEsignIdentityService
|
||||
$owner = Db::name('doctor_esign_account')->where('environment', $scope['environment'])
|
||||
->where('app_id', $scope['app_id'])->where('account_id', $newAccountId)->lock(true)->value('doctor_id');
|
||||
if ($owner !== null) {
|
||||
throw new DomainException('签署账号绑定冲突,请联系管理员核实');
|
||||
// e签宝 对同一实名只签发一个签署账号;指明占用方,便于管理员在管理员列表中解除后重试。
|
||||
// 用名称+ID 而非登录账号:账号常为手机号,桌面端会屏蔽含长数字的提示。
|
||||
$holder = (string) Db::name('admin')->where('id', $owner)->value('name');
|
||||
$label = ($holder !== '' ? $holder : '已删除账号') . '(ID ' . (int) $owner . ')';
|
||||
throw new DomainException(sprintf(
|
||||
'该实名的签署账号已绑定后台账号「%s」,请管理员在「管理员」列表解除其签署身份后再确认绑定(刷脸结果 30 分钟内有效)',
|
||||
$label
|
||||
));
|
||||
}
|
||||
Db::name('doctor_esign_account')->insert($scope + [
|
||||
'account_id' => $newAccountId, 'doctor_name' => $snapshot['name'], 'create_time' => time(),
|
||||
|
||||
Reference in New Issue
Block a user