WinfailLogic.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/7/15
  6. * Time: 16:51
  7. */
  8. namespace App\Logic;
  9. use Illuminate\Database\Capsule\Manager as DB;
  10. use App\Lib\Settlement\Adapter\ZqRule;
  11. use App\Lib\Settlement\Adapter\LqRule;
  12. use App\Lib\Settlement\Adapter\WqRule;
  13. use App\Lib\Settlement\Adapter\BqRule;
  14. use datainf\pplus\Instance;
  15. class WinfailLogic
  16. {
  17. use Instance;
  18. //类型映射
  19. public $gameAllMap = [
  20. 'zq' => 'ZqRule',
  21. 'lq' => 'LqRule',
  22. 'wq' => 'WqRule',
  23. 'bq' => 'BqRule',
  24. ];
  25. public function getNoticeDate($id)
  26. {
  27. $noticeMode = DB::table('comendnotice')->where(['id' => $id])->first();
  28. if (empty($noticeMode)) {
  29. throw new \Exception("没有找到notice记录-" . $id);
  30. }
  31. return $noticeMode;
  32. }
  33. //得到比赛最终结果记录
  34. public function getCompResult($type, $match_id)
  35. {
  36. $model = null;
  37. switch ($type) {
  38. case 'bq':
  39. $model = DB::table('st_bq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
  40. break;
  41. case 'lq':
  42. $model = DB::table('st_lq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
  43. break;
  44. case 'wq':
  45. $model = DB::table('st_wq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
  46. break;
  47. case 'zq':
  48. $model = DB::table('st_zq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
  49. break;
  50. }
  51. if (empty($model)) {
  52. throw new \Exception("没有找到赛事结果记录-" . $type . '-' . $match_id);
  53. }
  54. return $model;
  55. }
  56. //单式订单存在 单独设置比赛结果的情况,要分开处理
  57. public function getSimplexData($type, $match_id)
  58. {
  59. $return = [];
  60. $ret = DB::table("money_buy_simplex")->where(['game_code' => $type, 'match_id' => $match_id])->get();
  61. if (count($ret) <= 0) {
  62. return;
  63. }
  64. foreach ($ret as $val) {
  65. $return[$val->batch_id][$val->match_id] = ['result_flag' => $val->result_flag, 'single_result' => $val->single_result];
  66. }
  67. return $return;
  68. }
  69. //找到订单详细数据
  70. public function getMatchRecords($type, $match_id, $bet_type)
  71. {
  72. $return = [];
  73. $ret = DB::table("money_buy_match")->where(['game_code' => $type, 'match_id' => $match_id, 'bet_type' => $bet_type])->get();
  74. if (count($ret) <= 0) {
  75. return;
  76. }
  77. foreach ($ret as $val) {
  78. $return[] = $val;
  79. }
  80. return $return;
  81. }
  82. public function getAdapterObj($game_type)
  83. {
  84. $game_type = strtolower($game_type);
  85. if (!isset($this->gameAllMap)) {
  86. throw new \Exception('赛事类型错误-' . $game_type, 4002);
  87. return false;
  88. }
  89. switch ($game_type) {
  90. case 'bq':
  91. $apd = new BqRule();
  92. break;
  93. case 'lq':
  94. $apd = new LqRule();
  95. break;
  96. case 'wq':
  97. $apd = new WqRule();
  98. break;
  99. case 'zq':
  100. $apd = new ZqRule();
  101. break;
  102. }
  103. return $apd;
  104. }
  105. //冠军比赛结果
  106. public function getGjDatas($matchModel)
  107. {
  108. $table = 'st_' . $matchModel->game_code . '_league_result';
  109. $where = ['lg_id' => $matchModel->lg_id, 'game_name' => $matchModel->game_code];
  110. $model = DB::table($table)->where($where)->first();
  111. if (empty($model)) {
  112. return false;
  113. }
  114. return $model;
  115. }
  116. }