WinfailLogic.php 3.7 KB

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