1
This commit is contained in:
@@ -67,7 +67,10 @@ class ConversionLogic
|
||||
$supportsDeptBinding = AccountCost::supportsDeptBinding();
|
||||
$restrictAccountCostByDept = $supportsDeptBinding;
|
||||
$restrictStatsByDept = $supportsDeptBinding && $mediaChannelCode !== '';
|
||||
$eligibleDeptIds = $restrictAccountCostByDept ? self::expandDeptIdsWithDescendants($accountCostDeptIds) : $accountCostDeptIds;
|
||||
$scopeDeptIds = $restrictStatsByDept
|
||||
? self::loadChannelBoundDeptIds($mediaChannelCode)
|
||||
: $accountCostDeptIds;
|
||||
$eligibleDeptIds = $restrictAccountCostByDept ? self::expandDeptIdsWithDescendants($scopeDeptIds) : $scopeDeptIds;
|
||||
|
||||
if ($restrictStatsByDept) {
|
||||
$entities = self::filterEntitiesByChannelDeptScope($entities, $dimension, $eligibleDeptIds, $adminToDeptIds);
|
||||
@@ -440,6 +443,27 @@ class ConversionLogic
|
||||
return array_values($expanded);
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道绑定部门不依赖当前统计区间,避免某天没有录入成本时把统计实体过滤为空。
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private static function loadChannelBoundDeptIds(string $mediaChannelCode): array
|
||||
{
|
||||
$mediaChannelCode = trim($mediaChannelCode);
|
||||
if ($mediaChannelCode === '' || !AccountCost::supportsDeptBinding()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$deptIds = Db::name('account_cost')
|
||||
->where('media_channel_code', $mediaChannelCode)
|
||||
->where('dept_id', '>', 0)
|
||||
->distinct(true)
|
||||
->column('dept_id');
|
||||
|
||||
return array_values(array_unique(array_filter(array_map('intval', $deptIds), static fn (int $deptId): bool => $deptId > 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自媒体渠道选中时,统计范围只允许落在渠道绑定部门及其子部门内。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user