TrendStatis.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\controller;
  4. use app\BaseController;
  5. use app\model\GameStatisModel;
  6. use app\common\CommonUtils;
  7. use app\model\GameModel;
  8. use think\facade\Request;
  9. class TrendStatis extends BaseController
  10. {
  11. /**
  12. * 在线走势
  13. */
  14. public function Online()
  15. {
  16. $userInfo = $this->request->userInfo;
  17. // 获取查询参数
  18. $page = Request::get('page', 1, 'intval');
  19. $limit = Request::get('limit', 10, 'intval');
  20. // 筛选条件
  21. $filters = [
  22. // 时间筛选
  23. 'start_time' => Request::get('start_time', date('Y-m-d', strtotime('-7 days')), 'trim'),
  24. 'end_time' => Request::get('end_time', date('Y-m-d'), 'trim'),
  25. 'game_id' => Request::get('game_id', '', 'trim'),
  26. ];
  27. try {
  28. // 获取游戏每日数据
  29. $result = GameStatisModel::getGameDailyList(
  30. $userInfo['merchant_id'],
  31. $page,
  32. $limit,
  33. $filters,
  34. );
  35. // 获取游戏信息信息
  36. $game_ids = array_unique(array_column($result['list'], 'game_id'));
  37. $tempGameList = GameModel::where([['merchant_id', '=', $userInfo['merchant_id']], ['game_id', 'in', $game_ids]])->field(['game_id','title','image'])->select()->toArray();
  38. $gameList = [];
  39. foreach ($tempGameList as $item) {
  40. $game_id = $item['game_id'];
  41. $gameList[$game_id] = $item;
  42. }
  43. // 格式化数据
  44. foreach ($result['list'] as &$item) {
  45. $item['game_profit'] = CommonUtils::convertBalance($item['game_profit'], false);
  46. $item['bet_amount'] = CommonUtils::convertBalance($item['bet_amount'], false);
  47. $item['commission_amount'] = CommonUtils::convertBalance($item['game_profit'] * 0.08, false);
  48. $item['platform_fee'] = CommonUtils::convertBalance($item['bet_amount'] * 0.08, false);
  49. $item['buy_free_bet'] = 0;
  50. $item['game_title'] = $gameList[$item['game_id']]['title'] ?? '';
  51. }
  52. return json_success($result, '获取成功');
  53. } catch (\Exception $e) {
  54. return json_error([], '获取游戏每日数据失败:' . $e->getMessage());
  55. }
  56. }
  57. /**
  58. * 游戏走势
  59. */
  60. public function Game() {
  61. }
  62. /**
  63. * 输赢走势
  64. */
  65. public function Win() {
  66. }
  67. /**
  68. * 返奖倍数走势
  69. */
  70. public function PrizeMultiple() {
  71. }
  72. /**
  73. *
  74. */
  75. }