<?php

$conf_basedir = "../../../"; //相对主目录的位置
$conf_where = "admin"; //选择调用相应模块
$directory = basename(dirname(__FILE__)); //定义当前所在的目录，引入模块公用函数
include_once($conf_basedir . "base.inc.php");
include_once WEB_MODULE . '/growth/base.inc.php';

$container = Container::getInstance();
$dbback = $container->get('dbback');

$growthBidPeriods = new GrowthBidPeriods();
$growthBid = new GrowthBidStreetWords();
//竞投小区专家期次
$fieldData = array(
    'type' => 4,
    'name' => '板块词竞投',
    'start_time'=>'2014-03-07 08:00:00',
    'end_time'=>'2014-03-07 22:00:00',
    'tg_start_time'=>'2014-03-08 00:00:00',
    'tg_end_time'=>'2014-03-14 23:59:59');
$bidPeriodsId = $growthBidPeriods->insert($fieldData);
if($bidPeriodsId) {
    echo "创建板块词竞投期次，id=".$bidPeriodsId."。"."时间：".$fieldData['tg_start_time']."到".$fieldData['tg_end_time'];
    echo "<br/>";
} else {
    echo "创建板块词竞投期次，失败";
}

//小区板块词
$sreet = new Street();
$arrStreet = $street->findAll();

//起拍积分，参与等级
$growthBidStartSetting = new GrowthBidStartSetting();
$data_info = $growthBidStartSetting->getData();
$data_info1 = array();
foreach ($data_info as $key => $value) {
    $data_info1[$value['alias']] = $value; 
}
$bidData = array();
if($arrStreet) {
    foreach ($arrStreet as $key => $value) {
        $temp = array();
        $temp['bid_periods_id'] = $bidPeriodsId;
        $temp['street_id'] = $value['id'];
        $temp['broker_level'] = $data_info1['bidHouseStreetWord']['levelnames'];
        $temp['min_score'] = $data_info1['bidHouseStreetWord']['start_credit'];
        $temp['valid'] = 1;
        $temp['max_win_number'] = 4;
        $temp['ctime'] = date("Y-m-d H:i:s");
        $inid = $growthBid->insert($temp);
        if($inid) {
            echo "创建板块词竞投成功，id=".$inid."。板块id为".$value['id'];
        } else {
            echo "失败，板块id为".$value['id'];
        }
        echo "<br/>";
    }
}
?>
