<?php
/**
 * 每晚10点以后
 * 用于执行竞投小区专家和房源经纪人所需要的最低等级
 * 竞投结束后的处理执行此脚本 
 */
$conf_basedir = "../../../../"; //相对主目录的位置
define('WEB_ROOT', $conf_basedir);
$conf_where = "admin"; //选择调用相应模块
$directory = basename(dirname(__FILE__)); //定义当前所在的目录，引入模块公用函数
include_once(  "./base.inc.php");
require_once '../function_crontab.php';
//起拍积分，参与等级 
$growthBidStartSetting = new GrowthBidStartSetting();
$growthBidLowLevel = new GrowthBidLowLevel();
$bidPeriods = new GrowthBidPeriods();
$arrType = array('blockExpert', 'house');
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>更新房源最低竞投等级成功';
        }
    }
}


