<?php

/**
 * model\growth\GrowthCreditSetting.php
 */

/**
 * 积分设置类，组合积分方式，积分获取方式分值和套餐类。
 *
 * @author wxj
 */
class GrowthCreditSetting {
    //put your code here
    /**
     *
     * @var array 包含调整过的数据 
     */
    private $dataInfo;
    
    public function __construct() {
        
    }
    
    /**
     * 获取积分设置数据
     * @return type
     */
    public function getData() {
        if($this->dataInfo) {
            return $this->dataInfo;
        } else {
            $growthCredit = new GrowthCredit();
        $growthCreditWay = new GrowthCreditWay();
        $growthCreditWayPackage = new GrowthCreditWayPackage();
        $brokerGroup = new BrokerGroup();
        $packages = $brokerGroup->getCreditBrokerGroup();
        /*$packages = array();
        $packages[] = array('id'=>'8','groupname'=>'免费经纪人');
        $packages[] = array('id'=>'9','groupname'=>'精英型（90）');
        $packages[] = array('id'=>'10','groupname'=>'标准型（60）');
        $packages[] = array('id'=>'11','groupname'=>'基础型（40）');
        */
        $data_info = $growthCreditWay->findByDisplayable();
        if($data_info) {
            foreach ($data_info as $key => &$value) {
                $wayAlias = $value['alias'];
                $value['typeString'] = GrowthCreditWay::$type[$value['type']];
				if ($packages) {
					 foreach($packages as $package) {
						$packageId = $package['id'];
						$value['packageScore'.$packageId] = $growthCreditWayPackage->getScoreByWayAliasAndPackageId($wayAlias,$packageId);
					}
				}
            
            }
        }
        $this->dataInfo = $data_info;
        return $this->dataInfo;
        }
        
    }
        
}

?>
