0 && $end_unixtime > $start_unixtime) { $condition['time_stamp'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and']; } elseif ($start_unixtime > 0) { $condition['time_stamp'] = ['egt', $start_unixtime]; } elseif ($end_unixtime > 0) { $condition['time_stamp'] = ['lt', $end_unixtime]; } $stats_list = $model_refill_order->getOrderStatsList($condition, 50, '*', 'time_stamp desc, cname asc'); if ($type == 'provider') { $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.store_id,store.store_name')->join('inner') ->on('store.store_id=refill_provider.store_id')->limit(1000)->select(); Tpl::output('provider_list', $provider_list); } elseif ($type == 'merchant') { $merchant_list = Model('')->table('merchant')->limit(1000)->select(); Tpl::output('merchant_list', $merchant_list); } $total_stats = $this->stats($stats_list); $order_time_type_text = ['notify_time' => '回调时间', 'order_time' => '下单时间']; Tpl::output('total_stats', $total_stats); Tpl::output('stats_list', $stats_list); Tpl::output('order_time_type_text', $order_time_type_text); Tpl::output('show_page', $model_refill_order->showpage()); Tpl::showpage($page); } public function ExportDataOp() { $type = $_GET['type'] ? $_GET['type'] : 'system'; $model_refill_order = Model('refill_order'); $condition['type'] = $type; if (!empty($_GET['cid'])) { $condition['cid'] = $_GET['cid']; } if (!empty($_GET['order_time_type'])) { $condition['order_time_type'] = $_GET['order_time_type']; } $start_unixtime = intval($_GET['query_start_time']); $end_unixtime = intval($_GET['query_end_time']); if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) { $condition['time_stamp'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and']; } elseif ($start_unixtime > 0) { $condition['time_stamp'] = ['egt', $start_unixtime]; } elseif ($end_unixtime > 0) { $condition['time_stamp'] = ['lt', $end_unixtime]; } $stats_list = $model_refill_order->getOrderStatsList($condition,'','*','time_stamp asc'); $total_stats = $this->stats($stats_list); $stats = $total_stats[$_GET['order_time_type']]; if(empty($stats)) { $stats = $total_stats['notify_time']; } $result['data'] = $stats_list; $result['total_stats'] = $stats; echo(json_encode($result)); exit; } private function stats($stats_list): array { $order_time_type = ['notify_time','order_time']; foreach ($order_time_type as $type){ $success_count_total = $success_refill_amounts_total = $success_mch_amounts_total = $success_channel_amounts_total = $profit_amounts_total = 0; foreach ($stats_list as $stats) { if($stats['order_time_type'] != $type) continue; $success_count_total += $stats['success_count']; $success_refill_amounts_total += $stats['success_refill_amounts']; $success_mch_amounts_total += $stats['success_mch_amounts']; $success_channel_amounts_total += $stats['success_channel_amounts']; $profit_amounts_total += $stats['profit_amounts']; } $total_stats[$type] = [ 'success_count_total' => $success_count_total, 'success_refill_amounts_total' => $success_refill_amounts_total, 'success_mch_amounts_toatl' => $success_mch_amounts_total, 'success_channel_amounts_total' => $success_channel_amounts_total, 'profit_amounts_total' => $profit_amounts_total ]; } return $total_stats; } }