Files
zyt/server/app/common/service/assistantservice/WecomArchiveScope.php
T
2026-11-26 15:46:20 +08:00

33 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace app\common\service\assistantservice;
use think\facade\Db;
final class WecomArchiveScope
{
/** 当前业务实例关联的归档租户,仅接受服务端配置。 */
public static function tenant(): string
{
$tenant = (string) config('assistant_service.wecom_archive_tenant', '');
return preg_match('/\A[A-Za-z0-9_-]{1,64}\z/D', $tenant) === 1 ? $tenant : '';
}
/** 企业微信账号必须唯一归属有效员工。重复、停用及未绑定账号不能授权。 */
public static function accountOwners(): array
{
$owners = [];
$rows = Db::name('admin')->whereNull('delete_time')
->field('id,work_wechat_userid,root,disable')->select()->toArray();
foreach ($rows as $row) {
$account = trim((string) $row['work_wechat_userid']);
if ($account === '') { continue; }
$owners[$account] = isset($owners[$account]) || (int) $row['root'] || (int) $row['disable']
? 0 : (int) $row['id'];
}
return $owners;
}
}