<?php
/**
 * 每天9点钟开始跑
 * 用于创建积分和成长值变化记录表
 * 每天创建一张，并删除前七天的记录表
 * 表名：growth_credit_record_20140220  growth_exp_record_20140220
 */
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';

//创建下一天的记录表
$createDate = date('Ymd', strtotime('1 day'));
//清空前七天的数据
$clearDate = date('Ymd', strtotime('-7 day'));

$arrType = array('credit', 'exp');
foreach($arrType as $type) {
    if ($type == 'credit') {
        $creditTable = 'growth_credit_record_';
        $growthCreditRecord = new GrowthCreditRecord();
        $createCreditTable = $growthCreditRecord->createTable($creditTable . $createDate);
		/***
        if ($createCreditTable) {
           //echo '创建积分记录表成功-表名' . $creditTable . $createDate; 
        }***/
        $clearCreditTable = $growthCreditRecord->dropTable($creditTable . $clearDate);
        if ($createCreditTable && $clearCreditTable) {
			insertJobData("createBrokerCreditTable", '创建积分足迹表' . $createDate);
            //echo '删除积分值记录表成功-表名' . $creditTable . $clearDate; 
        }
    }
    if ($type == 'exp') {
        $expTable = 'growth_exp_record_';
        $growthExpRecord = new GrowthExpRecord();
        $createExpTable = $growthExpRecord->createTable($expTable  . $createDate);
		/***
        if ($createExpTable) {
           //echo '创建成长值记录表成功-表名' . $expTable . $createDate; 
        }***/
        $clearExpTable = $growthExpRecord->dropTable($expTable . $clearDate);
        if ($clearExpTable && $createExpTable) {
			insertJobData("createBrokerCreditTable", '创建经纪人成长足迹表' . $createDate);
            //echo '删除成长值记录表成功-表名' . $expTable . $clearDate; 
        }
    }
}




