RankingController.class.php 1.08 KB
<?php

/**
 * 获取指定用户的积分排名.
 *
 * @auther gaoyaqiu
 * @date 2017/05/24
 */

namespace Api\Controller\Integral;

use Common\Common\Department;
use VcySDK\Integral;
use VcySDK\Service;

class RankingController extends AbstractController
{
    public function index()
    {
        // 获取排行数据
        $sdk = new Integral(Service::instance());
        $rankingParams = [
            'memUid' => $this->uid,
            'rankingType' => I('post.ranking_type', $sdk::INTEGRAL_RANKING_TYPE_TOTAL),
        ];

        // 如果部门等于-1时,表示全公司
        $dpId = I('post.dp_id', -1);
        if ($dpId != -1) {
            $department =  new Department();
            // 获取所有子部门,包含自己
            $deps = $department->list_childrens_by_cdid($dpId, true);
            $rankingParams['dpIds'] = empty(array_keys($deps)) ? [] : array_keys($deps);
        }
        // 获取 角色/岗位 筛选条件
        $this->getRankingFilterCond($rankingParams);

        $this->_result = $sdk->getRanking($rankingParams);

        return true;
    }
}