<?php
/**
 * AgentList.php UTF-8
 * 渠道列表
 *
 * @date    : 2018/5/19 17:52
 *
 * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 * @author  : wuyonghong <wyh@huosdk.com>
 * @version : HUOSDK 8.0
 */

namespace huo\controller\agent;

use huo\controller\common\Base;
use huo\logic\agent\AgentListLogic;
use huo\logic\agent\AgentLogic;
use huolib\status\MemberStatus;

class AgentList extends Base {
    /**
     * 获取渠道列表
     *
     * @param        $agent_id
     * @param array  $param
     * @param string $page
     *
     * @return array
     */
    public function getAgentList($agent_id, $param = [], $page = '1,10') {
        $_map = $param;
        $_agent_ids = (new AgentLogic())->getAgentIds($agent_id, true);
        $_map['parent_id'] = $agent_id;
        $_map['agent_id'] = ['in', $_agent_ids];
        $_data = (new AgentListLogic())->getAgentList($_map, $page);
        $_code = MemberStatus::NO_ERROR;

        return $this->huoSuccess($_code, MemberStatus::getMsg($_code), $_data);
    }
}