public function actionExport()
 {
     $logs = TradeLog::find()->asArray()->orderBy('t_date desc')->all();
     $v = array();
     foreach ($logs as $key => $item) {
         $v[$key]['data'] = date('Y-m-d', $item['t_date']);
         $v[$key]['t_recharge'] = $item['t_recharge'];
         $v[$key]['t_withdraw'] = $item['t_withdraw'];
         $v[$key]['bl'] = $item['t_recharge'] != 0 ? ceil($item['t_withdraw'] / $item['t_recharge'] * 10000) / 100 . '%' : '';
         $v[$key]['t_invest'] = $item['t_invest'];
         $v[$key]['t_redeem'] = $item['t_redeem'];
         $v[$key]['bl1'] = $item['t_invest'] != 0 ? ceil($item['t_redeem'] / $item['t_invest'] * 10000) / 100 . '%' : '';
         $v[$key]['t_profit'] = $item['t_profit'];
         $v[$key]['t_gold'] = $item['t_gold'];
         $v[$key]['t_red'] = $item['t_red'];
         $v[$key]['ztz'] = $item['t_profit'] + $item['t_gold'] + $item['t_red'];
         $v[$key]['create_at'] = date('Y-m-d', $item['create_at']);
     }
     Utils::exportExcel($v, ['时间', '充值金额', '提现金额', '比率', '投资金额', '赎回金额', '比率', '在投收益', '体验金收益', '红包收益', '总收益', '创建时间'], '记录导出' . date('Y.m.d'));
 }
Exemple #2
0
 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();
         }
     }
 }