This commit is contained in:
Your Name
2026-08-28 18:24:37 +08:00
parent 43ad07208f
commit ed48f8be31
383 changed files with 8673 additions and 2222 deletions
@@ -16,7 +16,7 @@ if (!$admin) {
throw new RuntimeException('未找到 root 管理员,无法执行数据范围冒烟测试');
}
$overview = WecomPromotionLogic::overview((int) $admin['id'], $admin, 'https://example.test');
foreach (['meta', 'config', 'summary', 'pools', 'links', 'member_options', 'department_options'] as $key) {
foreach (['meta', 'config', 'summary', 'pools', 'links', 'member_options', 'operator_options', 'department_options'] as $key) {
if (!array_key_exists($key, $overview)) {
throw new RuntimeException("overview 缺少 {$key}");
}
@@ -42,19 +42,40 @@ if ($memberIds !== []) {
if (!is_array($overview['department_options'])) {
throw new RuntimeException('department_options 必须是部门树数组');
}
foreach ($overview['pools'] as $pool) {
foreach (['operators', 'operator_admin_ids', 'can_operate', 'can_manage_access', 'can_delete'] as $key) {
if (!array_key_exists($key, $pool)) {
throw new RuntimeException("pools 缺少共享操作权限字段 {$key}");
}
}
}
$scopedAdmin = Db::name('admin')->where('root', 0)->whereNull('delete_time')->order('id', 'asc')->find();
if ($scopedAdmin) {
$visibleIds = DataScopeService::getVisibleAdminIds((int) $scopedAdmin['id'], $scopedAdmin);
$scopedOverview = WecomPromotionLogic::overview((int) $scopedAdmin['id'], $scopedAdmin, 'https://example.test');
if ($visibleIds !== null) {
$scopedPoolIds = array_values(array_filter(array_map('intval', array_column($scopedOverview['pools'], 'id'))));
$sharedPoolMemberIds = $scopedPoolIds === []
? []
: array_map('intval', Db::name('qywx_promotion_pool_member')
->whereIn('pool_id', $scopedPoolIds)
->whereNull('delete_time')
->column('admin_id'));
foreach ($scopedOverview['member_options'] as $member) {
if (!in_array((int) $member['id'], $visibleIds, true)) {
if (!in_array((int) $member['id'], $visibleIds, true)
&& !in_array((int) $member['id'], $sharedPoolMemberIds, true)) {
throw new RuntimeException('member_options 泄露了当前角色或部门范围外的成员');
}
}
foreach ($scopedOverview['operator_options'] as $operator) {
if (!in_array((int) $operator['id'], $visibleIds, true)) {
throw new RuntimeException('operator_options 泄露了当前角色或部门范围外的账号');
}
}
foreach ($scopedOverview['pools'] as $pool) {
if (!in_array((int) $pool['owner_admin_id'], $visibleIds, true)) {
if (!in_array((int) $pool['owner_admin_id'], $visibleIds, true)
&& !in_array((int) $scopedAdmin['id'], array_map('intval', $pool['operator_admin_ids'] ?? []), true)) {
throw new RuntimeException('pools 泄露了当前角色或部门范围外的数据');
}
}