<?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';
//起拍积分，参与等级 
$growthBidStartSetting = new GrowthBidStartSetting();
$growthBidLowLevel = new GrowthBidLowLevel();
$bidPeriods = new GrowthBidPeriods();
$arrType = array('blockExpert', 'house');
$growthBidLowLevel->emptyTable();
foreach($arrType as $type) {
    if ($type == 'blockExpert') {
        $periods = $bidPeriods->currentBidPeriods(1);
        //竞投未开始
        if ($periods&&$periods['status']==2) {
            $data_info = $growthBidStartSetting->getData();
            $minBidBlockLevel = '';
            $bidBlockLevels = '';
            foreach ($data_info as $key => $value) {
               //subclass = 1 小区竞投  subclass 2 房源竞投
               if ($value['subclass'] == 1) {
                   $bidBlockLevels .= str_replace('LV', '', $value['levelnames']) . ',';
               }
            }
            $bidBlockLevels = rtrim($bidBlockLevels, ',');
            $minBidBlockLevel = min(explode(',', $bidBlockLevels));
            $bolUpdateBlock = $growthBidLowLevel->updateBlockExpertLevel('LV' . $minBidBlockLevel);
            if ($bolUpdateBlock) {
                echo '更新小区专家最低竞投等级成功';
            }
        } else {
            echo '更新小区专家最低竞投等级成功';
        }
    } 
    if ($type == 'house') {
        $periods = $bidPeriods->currentBidPeriods(2);
        if ($periods&&$periods['status']==2) {
            $data_info = $growthBidStartSetting->getData();
            $minBidHouseLevel = '';
            $bidHouseLevels = '';
            foreach ($data_info as $key => $value) {
               if ($value['subclass'] == 2) {
                   $bidHouseLevels .= str_replace('LV', '', $value['levelnames']) . ',';
               }
            }
            $bidHouseLevels = rtrim($bidHouseLevels, ',');
            $minBidHouseLevel = min(explode(',', $bidHouseLevels));
            $bolUpdateHouse = $growthBidLowLevel->updateHouseLevel('LV' . $minBidHouseLevel);
            if ($bolUpdateHouse) {
                echo '<br>更新房源最低竞投等级成功';
            }
        } else {
            echo '<br>更新房源最低竞投等级成功';
        }
    }
}


