<?php
/**
 * 初始化经纪人积分
 */
$conf_basedir	= "../../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
//include_once WEB_MODULE . '/growth_nj/base.inc.php';
//$brokers = array();
$sql = SqlCombinHelper::select_sql("broker", "uid as broker_id,FLOOR( credit /500 ) AS credit");
$dbback = Container::getInstance()->get('dbback');
$dbback->fetchMode = MYSQL_ASSOC;
$brokers = $dbback->getAll($sql);
$growthCredit = new GrowthCredit();

if($brokers) {
    $sql = "TRUNCATE TABLE ".$growthCredit->getTable();
    $db = Container::getInstance()->get('db');
    $db->Execute($sql);
    $number = $growthCredit->insertMutl($brokers);
    foreach ($brokers as $value){
        $arrBroker = array(
		   'id' => $value['broker_id'],
		   'groupid' => 0,
		);  
        $gbc = new GrowthBrokerCredit($arrBroker); 
        $gbc->increase('systemReward','原始积分按500:1兑换为房豆！',$value['credit']);
    }
    echo "初始化".$number."个经纪人";
}
?>

