コード例 #1
0
ファイル: AloneMethod.php プロジェクト: wuwenhan/huoqiwang
 public static function trade_date_log($date)
 {
     //判断是否存在当日记录
     $t_date = strtotime($date);
     if (strtotime(date('Y-m-d')) == $t_date || strtotime(date("Y-m-d", strtotime("-1 day"))) == $t_date) {
         TradeLog::deleteAll('t_date=' . $t_date);
     }
     $is_tradelog = TradeLog::find()->andwhere(['=', 't_date', $t_date])->asArray()->one();
     if (!$is_tradelog) {
         $max_time = strtotime(date('Y-m-d', strtotime("+1 day", strtotime($date))));
         $min_time = strtotime($date);
         //获取昨日总充值金额
         $t_recharge = Log::find()->Where(['status' => Log::STATUS_RECHAR_SUC])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->sum('step');
         if (empty($t_recharge)) {
             $t_recharge = 0.0;
         }
         //获取昨日总投资金额
         $t_invest = Log::find()->Where(['status' => Log::STATUS_INVEST_SUC])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->sum('step');
         if (empty($t_invest)) {
             $t_invest = 0.0;
         }
         //获取昨日总赎回金额
         $t_redeem = Log::find()->Where(['status' => Log::STATUS_REDEM_SUC])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->sum('step');
         if (empty($t_redeem)) {
             $t_redeem = 0.0;
         }
         //获取网站总提现金额
         $t_withdraw = Log::find()->Where(['status' => Log::STATUS_WITHDRAW_SUC])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->sum('step');
         if (empty($t_withdraw)) {
             $t_withdraw = 0.0;
         }
         //获取网站昨日在投收益金额
         $t_profit = Income::find()->andWhere(['>=', 'created_at', $min_time])->andWhere(['<', 'created_at', $max_time])->sum('iincome');
         if (empty($t_profit)) {
             $t_profit = 0.0;
         }
         //获取网站昨日体验金收益金额
         $t_gold = Income::find()->andWhere(['>=', 'created_at', $min_time])->andWhere(['<', 'created_at', $max_time])->sum('goldincome');
         if (empty($t_gold)) {
             $t_gold = 0.0;
         }
         //获取网站昨日发放红包金额
         $t_red = Income::find()->andWhere(['>=', 'created_at', $min_time])->andWhere(['<', 'created_at', $max_time])->sum('railscard');
         if (empty($t_red)) {
             $t_red = 0.0;
         }
         //将其记录到网站金额汇总表里:
         $tradelog = new TradeLog();
         $tradelog->t_recharge = $t_recharge;
         $tradelog->t_invest = $t_invest;
         $tradelog->t_redeem = $t_redeem;
         $tradelog->t_withdraw = $t_withdraw;
         $tradelog->t_profit = $t_profit;
         $tradelog->t_gold = $t_gold;
         $tradelog->t_red = $t_red;
         $tradelog->t_date = $t_date;
         $tradelog = $tradelog->save();
         if (!$tradelog) {
             $tasklog = new Tasklog();
             $tasklog->remark = date('Y-m-d H:i:s', time()) . '执行计划任务写入网站昨日各项总金额(充值,投资,赎回,投资等昨日总额)记录失败';
             $tasklog->url = 'AloneMethod/trade_log';
             $tasklog->save();
         }
     }
 }