|
@@ -1,376 +0,0 @@
|
|
|
-<?php
|
|
|
|
|
-declare (strict_types = 1);
|
|
|
|
|
-
|
|
|
|
|
-namespace app\controller;
|
|
|
|
|
-
|
|
|
|
|
-use app\BaseController;
|
|
|
|
|
-use app\model\MerchantDailyModel;
|
|
|
|
|
-use app\model\GameDailyModel;
|
|
|
|
|
-use app\model\MerchantHistoryModel;
|
|
|
|
|
-use think\facade\Request;
|
|
|
|
|
-
|
|
|
|
|
-class DailyStatistics extends BaseController
|
|
|
|
|
-{
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取商户每日数据列表
|
|
|
|
|
- */
|
|
|
|
|
- public function merchantDailyList()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- // 获取查询参数
|
|
|
|
|
- $page = Request::get('page', 1, 'intval');
|
|
|
|
|
- $limit = Request::get('limit', 10, 'intval');
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-7 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取商户每日数据
|
|
|
|
|
- $result = MerchantDailyModel::getMerchantDailyList(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $startDate,
|
|
|
|
|
- $endDate,
|
|
|
|
|
- $page,
|
|
|
|
|
- $limit
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 格式化数据
|
|
|
|
|
- foreach ($result['list'] as &$item) {
|
|
|
|
|
- $item['game_profit'] = round($item['game_profit'], 2);
|
|
|
|
|
- $item['bet_amount'] = round($item['bet_amount'], 2);
|
|
|
|
|
- $item['commission_amount'] = round($item['commission_amount'], 2);
|
|
|
|
|
- $item['platform_fee'] = round($item['platform_fee'], 2);
|
|
|
|
|
- $item['merchant_name'] = $userInfo['merchant_name'] ?? '商户' . $userInfo['merchant_id'];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return json_success($result, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取商户每日数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取游戏每日数据列表
|
|
|
|
|
- */
|
|
|
|
|
- public function gameDailyList()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- // 获取查询参数
|
|
|
|
|
- $page = Request::get('page', 1, 'intval');
|
|
|
|
|
- $limit = Request::get('limit', 10, 'intval');
|
|
|
|
|
- $gameId = Request::get('game_id', 0, 'intval');
|
|
|
|
|
- $gameName = Request::get('game_name', '', 'trim');
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-7 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- $filters = [
|
|
|
|
|
- 'merchant_id' => $userInfo['merchant_id'],
|
|
|
|
|
- 'game_id' => $gameId,
|
|
|
|
|
- 'game_name' => $gameName,
|
|
|
|
|
- 'start_date' => $startDate,
|
|
|
|
|
- 'end_date' => $endDate
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取游戏每日数据
|
|
|
|
|
- $result = GameDailyModel::getGameDailyList($filters, $page, $limit);
|
|
|
|
|
-
|
|
|
|
|
- // 格式化数据
|
|
|
|
|
- foreach ($result['list'] as &$item) {
|
|
|
|
|
- $item['game_profit'] = round($item['game_profit'], 2);
|
|
|
|
|
- $item['bet_amount'] = round($item['bet_amount'], 2);
|
|
|
|
|
- $item['commission_amount'] = round($item['commission_amount'], 2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return json_success($result, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取游戏每日数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取商户汇总统计
|
|
|
|
|
- */
|
|
|
|
|
- public function merchantSummary()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-30 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $summary = MerchantDailyModel::getMerchantSummary(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $startDate,
|
|
|
|
|
- $endDate
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- return json_success($summary, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取商户汇总统计失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取游戏列表
|
|
|
|
|
- */
|
|
|
|
|
- public function getGameList()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $games = GameDailyModel::getGameList($userInfo['merchant_id']);
|
|
|
|
|
-
|
|
|
|
|
- return json_success($games, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取游戏列表失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取商户历史数据统计
|
|
|
|
|
- */
|
|
|
|
|
- public function merchantHistory()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- // 获取过滤参数
|
|
|
|
|
- $filters = [
|
|
|
|
|
- 'start_date' => Request::get('start_date', '', 'trim'),
|
|
|
|
|
- 'end_date' => Request::get('end_date', '', 'trim')
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $history = MerchantHistoryModel::getMerchantHistoryStatistics(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $filters
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- return json_success($history, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取商户历史数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取商户历史数据列表(按月或按天)
|
|
|
|
|
- */
|
|
|
|
|
- public function merchantHistoryList()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- // 获取查询参数
|
|
|
|
|
- $page = Request::get('page', 1, 'intval');
|
|
|
|
|
- $limit = Request::get('limit', 10, 'intval');
|
|
|
|
|
- $groupBy = Request::get('group_by', 'month', 'trim'); // month 或 day
|
|
|
|
|
-
|
|
|
|
|
- $filters = [
|
|
|
|
|
- 'start_date' => Request::get('start_date', '', 'trim'),
|
|
|
|
|
- 'end_date' => Request::get('end_date', '', 'trim')
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $result = MerchantHistoryModel::getMerchantHistoryList(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $groupBy,
|
|
|
|
|
- $page,
|
|
|
|
|
- $limit,
|
|
|
|
|
- $filters
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- return json_success($result, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取商户历史数据列表失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 导出商户历史数据
|
|
|
|
|
- */
|
|
|
|
|
- public function exportMerchantHistory()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- $groupBy = Request::get('group_by', 'month', 'trim');
|
|
|
|
|
- $filters = [
|
|
|
|
|
- 'start_date' => Request::get('start_date', '', 'trim'),
|
|
|
|
|
- 'end_date' => Request::get('end_date', '', 'trim')
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取所有数据
|
|
|
|
|
- $result = MerchantHistoryModel::getMerchantHistoryList(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $groupBy,
|
|
|
|
|
- 1,
|
|
|
|
|
- 100000,
|
|
|
|
|
- $filters
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 生成CSV数据
|
|
|
|
|
- $csvData = "时间,RTP(%),注单数,注单金额(THB),游戏输赢(THB),注单金额(USDT),游戏输赢(USDT),登录用户,注册用户,投注用户,抽水额度(USDT),购买免费游戏次数\n";
|
|
|
|
|
-
|
|
|
|
|
- foreach ($result['list'] as $item) {
|
|
|
|
|
- $csvData .= sprintf(
|
|
|
|
|
- "%s,%.2f,%d,%.2f,%.2f,%.4f,%.4f,%d,%d,%d,%.4f,%d\n",
|
|
|
|
|
- $item['period'],
|
|
|
|
|
- $item['rtp'],
|
|
|
|
|
- $item['total_orders'],
|
|
|
|
|
- $item['total_bet_thb'],
|
|
|
|
|
- $item['game_profit_thb'],
|
|
|
|
|
- $item['total_bet_usdt'],
|
|
|
|
|
- $item['game_profit_usdt'],
|
|
|
|
|
- $item['login_users'],
|
|
|
|
|
- $item['register_users'],
|
|
|
|
|
- $item['bet_users'],
|
|
|
|
|
- $item['commission_usdt'],
|
|
|
|
|
- $item['free_game_count']
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 返回CSV数据
|
|
|
|
|
- return response($csvData)
|
|
|
|
|
- ->header(['Content-Type' => 'text/csv; charset=utf-8'])
|
|
|
|
|
- ->header(['Content-Disposition' => 'attachment; filename="merchant_history_' . date('YmdHis') . '.csv"'])
|
|
|
|
|
- ->header(['Cache-Control' => 'no-cache, must-revalidate']);
|
|
|
|
|
-
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '导出商户历史数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取游戏汇总统计
|
|
|
|
|
- */
|
|
|
|
|
- public function gameSummary()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-30 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $summary = GameDailyModel::getGameSummary(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $startDate,
|
|
|
|
|
- $endDate
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 格式化数据
|
|
|
|
|
- foreach ($summary as &$item) {
|
|
|
|
|
- $item['total_profit'] = round($item['total_profit'], 2);
|
|
|
|
|
- $item['avg_rtp'] = round($item['avg_rtp'], 2);
|
|
|
|
|
- $item['total_bet_amount'] = round($item['total_bet_amount'], 2);
|
|
|
|
|
- $item['total_commission'] = round($item['total_commission'], 2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return json_success($summary, '获取成功');
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '获取游戏汇总统计失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 导出商户每日数据
|
|
|
|
|
- */
|
|
|
|
|
- public function exportMerchantDaily()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-30 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取所有数据
|
|
|
|
|
- $result = MerchantDailyModel::getMerchantDailyList(
|
|
|
|
|
- $userInfo['merchant_id'],
|
|
|
|
|
- $startDate,
|
|
|
|
|
- $endDate,
|
|
|
|
|
- 1,
|
|
|
|
|
- 100000
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 生成CSV数据
|
|
|
|
|
- $csvData = "日期,商户,游戏输赢,游戏RTP(%),注单金额,注单数,投注用户,注册用户,登录用户,抽水额度,平台费用(USDT),购买免费游戏次数\n";
|
|
|
|
|
-
|
|
|
|
|
- foreach ($result['list'] as $item) {
|
|
|
|
|
- $csvData .= sprintf(
|
|
|
|
|
- "%s,%s,%.2f,%.2f,%.2f,%d,%d,%d,%d,%.2f,%.2f,%d\n",
|
|
|
|
|
- $item['date'],
|
|
|
|
|
- $userInfo['merchant_name'] ?? '商户' . $userInfo['merchant_id'],
|
|
|
|
|
- $item['game_profit'],
|
|
|
|
|
- $item['game_rtp'],
|
|
|
|
|
- $item['bet_amount'],
|
|
|
|
|
- $item['bet_count'],
|
|
|
|
|
- $item['bet_users'],
|
|
|
|
|
- $item['register_users'],
|
|
|
|
|
- $item['login_users'],
|
|
|
|
|
- $item['commission_amount'],
|
|
|
|
|
- $item['platform_fee'],
|
|
|
|
|
- $item['free_game_count']
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 返回CSV数据
|
|
|
|
|
- return response($csvData)
|
|
|
|
|
- ->header(['Content-Type' => 'text/csv; charset=utf-8'])
|
|
|
|
|
- ->header(['Content-Disposition' => 'attachment; filename="merchant_daily_' . date('YmdHis') . '.csv"'])
|
|
|
|
|
- ->header(['Cache-Control' => 'no-cache, must-revalidate']);
|
|
|
|
|
-
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '导出商户每日数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 导出游戏每日数据
|
|
|
|
|
- */
|
|
|
|
|
- public function exportGameDaily()
|
|
|
|
|
- {
|
|
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
-
|
|
|
|
|
- $startDate = Request::get('start_date', date('Y-m-d', strtotime('-30 days')), 'trim');
|
|
|
|
|
- $endDate = Request::get('end_date', date('Y-m-d'), 'trim');
|
|
|
|
|
-
|
|
|
|
|
- $filters = [
|
|
|
|
|
- 'merchant_id' => $userInfo['merchant_id'],
|
|
|
|
|
- 'start_date' => $startDate,
|
|
|
|
|
- 'end_date' => $endDate
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取所有数据
|
|
|
|
|
- $result = GameDailyModel::getGameDailyList($filters, 1, 100000);
|
|
|
|
|
-
|
|
|
|
|
- // 生成CSV数据
|
|
|
|
|
- $csvData = "日期,游戏名称,游戏输赢,游戏RTP(%),注单金额,注单数,投注用户,注册用户,登录用户,抽水额度,购买免费游戏次数\n";
|
|
|
|
|
-
|
|
|
|
|
- foreach ($result['list'] as $item) {
|
|
|
|
|
- $csvData .= sprintf(
|
|
|
|
|
- "%s,%s,%.2f,%.2f,%.2f,%d,%d,%d,%d,%.2f,%d\n",
|
|
|
|
|
- $item['date'],
|
|
|
|
|
- $item['game_name'],
|
|
|
|
|
- $item['game_profit'],
|
|
|
|
|
- $item['game_rtp'],
|
|
|
|
|
- $item['bet_amount'],
|
|
|
|
|
- $item['bet_count'],
|
|
|
|
|
- $item['bet_users'],
|
|
|
|
|
- $item['register_users'],
|
|
|
|
|
- $item['login_users'],
|
|
|
|
|
- $item['commission_amount'],
|
|
|
|
|
- $item['free_game_count']
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 返回CSV数据
|
|
|
|
|
- return response($csvData)
|
|
|
|
|
- ->header(['Content-Type' => 'text/csv; charset=utf-8'])
|
|
|
|
|
- ->header(['Content-Disposition' => 'attachment; filename="game_daily_' . date('YmdHis') . '.csv"'])
|
|
|
|
|
- ->header(['Cache-Control' => 'no-cache, must-revalidate']);
|
|
|
|
|
-
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
- return json_error([], '导出游戏每日数据失败:' . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|