Service/Calc/Bonus/Override/Calc.php
private function mapByGeneration($mapByDepthDesc, $mapById)
    {
        $result = []; // [ $custId=>[$genId => $totalPv, ...], ... ]
        foreach ($mapByDepthDesc as $depth => $ids) {
            foreach ($ids as $custId) {
                /** @var EBonDwnl $entry */
                $entry = $mapById[$custId];
                $path = $entry->getPath();
                $parents = $this->hlpTree->getParentsFromPathReversed($path);
                $level = 0;
                foreach ($parents as $parentId) {
                    $level += 1;
                    if (!isset($result[$parentId])) {
                        $result[$parentId] = [];
                    }
                    if (!isset($result[$parentId][$level])) {
                        $result[$parentId][$level] = [];
                    }
                    $result[$parentId][$level][] = $custId;
                }
            }
        }
        return $result;
    }
private function mapByGeneration($mapByDepthDesc, $mapById)
    {
        $result = []; // [ $custId=>[$genId => $totalPv, ...], ... ]
        foreach ($mapByDepthDesc as $depth => $ids) {
            foreach ($ids as $custId) {
                /** @var EBonDwnl $entry */
                $entry = $mapById[$custId];
                $path = $entry->getPath();
                $parents = $this->hlpTree->getParentsFromPathReversed($path);
                $level = 0;
                foreach ($parents as $parentId) {
                    $level += 1;
                    if (!isset($result[$parentId])) {
                        $result[$parentId] = [];
                    }
                    if (!isset($result[$parentId][$level])) {
                        $result[$parentId][$level] = [];
                    }
                    $result[$parentId][$level][] = $custId;
                }
            }
        }
        return $result;
    }
Generate map of the customer generations.

@param $mapByDepthDesc
@param $mapById
@param $mapById

@return array [$custId=>[$genNum=>[$childId, ...], ...], ...]