BaccaratController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * Created by IntelliJ IDEA.
  4. * User: solu
  5. * Date: 2019/2/14
  6. * Time: 5:17 PM
  7. */
  8. class BaccaratController extends BaseController {
  9. public function __construct() {
  10. parent::__construct(false);
  11. }
  12. /**
  13. * 游戏结果
  14. * @author solu
  15. * @param $args
  16. * @return array
  17. */
  18. public function actionGameResult($args) {
  19. $rules = [
  20. 'old' => ['int', 'desc' => '旧游戏id'],
  21. 'new' => ['int', 'desc' => '新游戏id'],
  22. 'player' => ['string', 'nullable' => true, 'reg' => '/^[a-z0-9\.]{1,13}$/', 'desc' => '用户名'],
  23. ];
  24. Param::checkParam2($rules, $args);
  25. return (new Game())->info($args['old'], $args['new'], $args['player']);
  26. }
  27. /**
  28. * 游戏信息
  29. * @author solu
  30. * @param $args
  31. * @return array
  32. */
  33. public function actionGameInfo($args) {
  34. $rules = [
  35. 'game_id' => ['int', 'nullable' => true, 'desc' => '游戏id'],
  36. ];
  37. Param::checkParam2($rules, $args);
  38. $objGame = new Game();
  39. $gameId = (int)$args['game_id'];
  40. $keyword = [
  41. '_field' => 'id, game_state, ttl, create_time, update_time_int',
  42. ];
  43. if ($gameId) {
  44. $game = $objGame->objTable->getRow(['id' => $gameId], $keyword);
  45. } else {
  46. $keyword['_sortKey'] = 'id DESC';
  47. $keyword['_limit'] = 1;
  48. $game = $objGame->objTable->getRow($keyword);
  49. $gameId = $game['id'];
  50. }
  51. $game['timeout'] = max(strtotime($game['create_time']) + $game['ttl'] - time(), 0);
  52. // 下注信息
  53. $offers = (new Offer())->getCurrentList($gameId);
  54. // 近50期开奖记录
  55. $winData = $objGame->winData(60);
  56. list($total, $list) = Game::getOnlineInfo();
  57. $online = compact('total', 'list');
  58. //gt汇率
  59. $objSummery = new TableHelper('summery', 'dw_eos');
  60. $info = $objSummery->getRow();
  61. $dig_rate = $info['dig_rate'];
  62. return compact('game', 'offers', 'winData', 'online', 'dig_rate');
  63. }
  64. /**
  65. * 我的下注
  66. * @author solu
  67. * @param $args
  68. * @return array
  69. */
  70. public function actionPlayerOffers($args) {
  71. $rules = [
  72. 'player' => ['string', 'reg' => '/^[a-z0-9\.]{1,13}$/', 'desc' => '用户名'],
  73. 'limit' => ['int', 'nullable' => true, 'range' => '[10,100]', 'default' => 25, 'desc' => '数量'],
  74. 'next' => ['int', 'nullable' => true, 'desc' => '最后一个id'],
  75. ];
  76. Param::checkParam2($rules, $args);
  77. $pageSize = (int)$args['limit'];
  78. $objOffer = new Offer;
  79. $list = $objOffer->getList(Offer::LIST_PLAYER, 0, $pageSize, $args['player'], false, $args['next']);
  80. $more = count($list) >= $pageSize;
  81. return compact('list', 'more');
  82. }
  83. /**
  84. * 所有下注
  85. * @author solu
  86. * @param $args
  87. * @return array
  88. */
  89. public function actionOffers($args) {
  90. $rules = [
  91. 'limit' => ['int', 'nullable' => true, 'range' => '[10,100]', 'default' => 25, 'desc' => '数量'],
  92. 'next' => ['int', 'nullable' => true, 'desc' => '最后一个id'],
  93. ];
  94. Param::checkParam2($rules, $args);
  95. $pageSize = (int)$args['limit'];
  96. $objOffer = new Offer;
  97. $list = $objOffer->getList(Offer::LIST_ALL, 0, $pageSize, '', false, $args['next']);
  98. $more = count($list) >= $pageSize;
  99. return compact('list', 'more');
  100. }
  101. /**
  102. * 巨额奖金
  103. * @author solu
  104. * @param $args
  105. * @return array
  106. */
  107. public function actionRank($args) {
  108. $rules = [
  109. 'limit' => ['int', 'nullable' => true, 'range' => '[10,100]', 'default' => 25, 'desc' => '数量'],
  110. 'page' => ['int', 'nullable' => true, 'default' => 0, 'desc' => '页码'],
  111. ];
  112. Param::checkParam2($rules, $args);
  113. $pageSize = (int)$args['limit'];
  114. $offset = max($args['page'] - 1, 0) * $pageSize;
  115. $objOffer = new Offer;
  116. $list = $objOffer->getList(Offer::LIST_RANK, $offset, $pageSize, '', true);
  117. $more = count($list) >= $pageSize;
  118. return compact('list', 'more');
  119. }
  120. }