<?php

/**
 * 创建下一期竞投,并且清空竞投中记录表
 * //每天23：59：59
 * 参数，days 下期间隔天数,默认值1；type blockExpert or house 是创建房源竞投还是小区专家竞投
 */
//数据库只保留四期竞投数据
set_time_limit(0);
error_reporting(7);
ini_set("display_errors",false);
$conf_basedir = "../../../../"; //相对主目录的位置
define('WEB_ROOT', $conf_basedir);
$conf_where = "admin"; //选择调用相应模块
$directory = basename(dirname(__FILE__)); //定义当前所在的目录，引入模块公用函数
include_once(  "./base.inc.php");
require_once '../function_crontab1.php';
//$time = time();
//echo $week = date("N", $time);
$bidPeriods = new GrowthBidPeriods();
//exit;
$days = intval($_GET['days'])?intval($_GET['days']):1;
//$days = 1;


$arrType = array('blockExpert','house');
foreach($arrType as $type) {
    if($type == 'blockExpert') {
        //小区专家竞投
        $periods = $bidPeriods->currentBidPeriods(1);
        if($periods&&$periods['status']==1) {//如果是结束的，创建下一期
			/******
            $startTimePrev = $periods['start_time']; 
            $endTimePrev = $periods['end_time']; 
            $tgStartTimePrev = $periods['tg_start_time']; 
            $tgEndTimePrev = $periods['tg_end_time'];
            $startTime = getNextBidDateFromBidDate($startTimePrev,$days);//date("Y-m-d H:i:s",strtotime("+".$days." days", strtotime($startTimePrev)));
            $endTime = getNextBidDateFromBidDate($endTimePrev,$days);//strtotime("+".$days."days", $endTimePrev);
            $tgStartTime = getNextBidDateFromBidDate($tgStartTimePrev,$days);//strtotime("+".$days."days", $tgStartTimePrev);
            $tgEndTime = getNextBidDateFromBidDate($tgEndTimePrev,$days);//strtotime("+".$days."days", $tgEndTimePrev);
            createNextBidBlockExpert($startTime, $endTime, $tgStartTime, $tgEndTime);***/
			if ($createStatus) {
				//insertJobData("createNextBidBlockExpert", "成功创建下一期小区专家竞投数据");
			}
            //清空竞投中记录表
			$bidFinish = getJobState('bidFinishHandleBlockExpert');
			if ($bidFinish) {
				$growthBidRecord = new GrowthBidBlockExpertRecordOn();
				//$growthBidRecord->emptyAll();
			}
			//更新竞投小区专家的最低等级
			//updateBidBlockExpertLowLevel();
        }
    } 


    if($type == 'house') {
       //创建房源竞投
        $periods = $bidPeriods->currentBidPeriods(2);
        if($periods&&$periods['status']==3) {//如果是结束的，创建下一期
            $startTimePrev = $periods['start_time']; 
            $endTimePrev = $periods['end_time']; 
            $tgStartTimePrev = $periods['tg_start_time']; 
            $tgEndTimePrev = $periods['tg_end_time'];
            $startTime = getNextBidDateFromBidDate($startTimePrev,$days);
            $endTime = getNextBidDateFromBidDate($endTimePrev,$days);
            $tgStartTime = getNextBidDateFromBidDate($tgStartTimePrev,$days);
            $tgEndTime = getNextBidDateFromBidDate($tgEndTimePrev,$days);
            createNextBidHouse($startTime,$endTime,$tgStartTime,$tgEndTime);

            //清空竞投中记录表
            $growthBidRecord = new GrowthBidHouseRecordOn();
            //$growthBidRecord->emptyAll();
			
			//更新兑投房源的最低等级
			updateBidHouseLowLevel();
			
			//更新竞投小区词和热搜词时的等级
			updateBidHouseLevel();
        } 
    }
}

?>
