<?php

class GrowthPermission { 

    /**
     * 主数据库
     */
    private $db;

    /**
     * 从数据库
     */
    private $dbback;

    /**
     * 缓存对象
     */
    private $mc;

    public function __construct() {
        $container = Container::getInstance();
        $this->db = $container->get('db');
        $this->dbback = $container->get('dbback');
        $this->mc = $container->get('mc');
    }

	public function buildPermissionTemplate($BK_EXPERT_MANAGE_RUL, $BK_BID_HOUSE_MANAGE_URL,$rule_url) {
	
		//竞投期限类
		$growthBidPeriods = new GrowthBidPeriods();
		
		//经纪人操作等级最低权限
		$growthBidLowLevel = new GrowthBidLowLevel();
		
		//经纪人使用统计类
		$growthBidUserBroker = new GrowthBidUserBroker();


		$bidDetailInfo = array();

		//竞投的等级
		$bidLevel = $growthBidLowLevel->findAll();
		if ($bidLevel) {
			foreach($bidLevel as $v) {
				if ($v['type'] == 1) {
					$lowLevelBlockExpert = $v['level'];
				} else if ($v['type'] == 2) {
					$lowLevelHouse = $v['level'];
				}
			}
		}
		//这块是小区专家的

		//竞投期限的控制
		$periodsInfo = $growthBidPeriods->currentBidPeriods(1);

		//已使用的人数
		$userNumber = $growthBidUserBroker->findCountBidBlockExpert();

		$description = '小区专家【每周一9点至19点开放】7天搜索列表页、小区频道稀缺推广位全部积分换。竞投成功小区专家，热门小区代言人就是你！';
		$bidDetailInfo[] = array(
			'bidname' => '小区专家',
			'lowLevel' => $lowLevelBlockExpert,
			'havePay'    => 'tqXqzjIco.png',
			'nonePay'    => 'tqXqzjIco_none.png',
			'userNumber' => $userNumber,
			'description' => $description,
			'bidSrc'      => $BK_EXPERT_MANAGE_RUL,
			'updateSrc'   => $rule_url['update_level'],
			'perioids'    => $periodsInfo
		);


		//这块是房源竞投的
		
		//竞投期限的控制
		$periodsInfo = $growthBidPeriods->currentBidPeriods(2);

		//已使用的人数
		$userNumber = $growthBidUserBroker->findCountBidHouse();

		//竞投描述
		$description = '房源竞投【每周三9点至19点开放】7天搜索置顶推荐，曝光、流量大幅涨，客户来电接不停！10000点击不是梦，助您立马开单！';
		
		$bidDetailInfo[] = array(
			'bidname' => '房源竞投',
			'lowLevel' => $lowLevelHouse,
			'havePay' => 'tqfyjtIco.png',
			'nonePay' => 'tqfyjtIco_none.png',
			'userNumber' => $userNumber,
			'description' => $description,
			'bidSrc'      => $BK_BID_HOUSE_MANAGE_URL,
			'updateSrc'   => $rule_url['update_level'],
			'perioids'    => $periodsInfo
		);

		return $bidDetailInfo;
	}

}