<?php
/**
 * 竞投结束后的处理
 * 1，on表数据移动到history表
 * 2，对竞投成功的，扣除积分，且解冻相应积分
 * 3，加成长值
 * 4, 对竞投成功的，刷成功表
 * //每天10点之后执行
 * 参数 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_crontab.php';

//$container = Container::getInstance();
//$dbback = $container->get('dbback');
$bidPeriods= new GrowthBidPeriods();

$arrType = array('blockExpert','house');
foreach($arrType as $type) {
    if($type=='blockExpert') { 
    /***********刷小区专家竞投***********************/
        $periods = $bidPeriods->currentBidPeriods(1);
        //print_r($periods);
        $periodsStatus = $periods['status'];//echo $periodsStatus;exit;
        //$periodsStatus = 3;
        if($periodsStatus==3) {//结束时刷历史表
            $resultStatus = bidFinishHandle($periods['id'],'blockExpert');
            if ($resultStatus) {
                 insertJobData("bidFinishHandleBlockExpert", "刷小区专家竞投数据成功");
            }
        }
    /***********刷小区专家竞投结束***********************/
    }
    //exit;
    if($type=='house') { 
    /***********刷房源竞投***********************/
        $periods = $bidPeriods->currentBidPeriods(2);
        //print_r($periods);exit;
        $periodsStatus = $periods['status'];
        $periodsId = $periods['id'];
        //$periodsId = 20;
        //$periodsStatus = 3;
        if($periodsStatus==3) {//结束时刷历史表
            $resultStatus = bidFinishHandle($periodsId,'house');
            if ($resultStatus) {
                insertJobData("bidFinishHandleHouse", "刷房源竞投数据成功");
            }
        }
    /***********刷房源竞投结束***********************/    
    }
}
?>
