<?php

/* 
 * 每晚十点执行
 * 生日赠送
 * 必须是身份证认证的付费有效用户
 */
die('暂不施行');
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';



brithdayReward();

function brithdayReward(){    
    $container = Container::getInstance();
    $db = $container->get('db');
    $dbback = $container->get('dbback');   
    $sql = SqlCombinHelper::select_sql('broker', 'uid,groupid,idno', 
                 "idno != '' and p_2_pic != '' and is_pay = 0 and valid_flag = 1");
    $res= $dbback->GetAll($sql);    
    foreach ($res as $value){    
        $brokerBrithDay = getBirthDay($value['idno']);      
        $cdate = getCdate();
        if( $brokerBrithDay == $cdate){   
            $arrBroker = array(
                 'id' => $value['uid'],
                 'groupid' => $value['groupid'],
                ); 
            
              
            $gbc = new GrowthBrokerCredit($arrBroker); 
            $gbe = new GrowthBrokerExp($arrBroker); 
            $gcwp = new GrowthCreditWayPackage;
            $gewp = new GrowthExpWayPackage();	
            $crdeit = $gcwp->getScoreByWayAliasAndPackageId('birthdayReward',$value['groupid']);
            $exp = $gewp->findScoreByWayAliasAndPackageId('birthdayReward',$value['groupid']);
            $gbc->increase('birthdayReward','生日赠送',$crdeit);                           
            $gbe->increase('birthdayReward','生日赠送',$exp);//增长代码					
        } 
    }
}
//获取生日
function getBirthDay($id){
    return substr($id, 10,4);
}

//获取当天时间
function getCdate(){
    return date('md');
}