SportsbqController.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Illuminate\Support\Facades\DB;
  6. use App\Models;
  7. use Request;
  8. /**
  9. *
  10. */
  11. class SportsbqController extends Controller {
  12. //棒球结果列表
  13. function outcome(Req $req) {
  14. $request=array();
  15. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  16. $request['source'] = isset($req->source) ? $req->source : null;
  17. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  18. $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
  19. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
  20. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
  21. $dt = \App\Lib\DataTable\DataTable::init();
  22. $dt->setDataSource('/admin/Sportsbq/info');
  23. $dt->setLang('Sportsbq');
  24. $dt->addColsFields('newtime', array('templet' => '#home_team', 'sort' => false, 'width' => 200));
  25. $dt->addColsFields('home_team', array('templet' => '#home_team', 'sort' => false, 'width' => 80));
  26. $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
  27. $dt->addColsFields('dsnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
  28. $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
  29. $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 80));
  30. $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
  31. $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
  32. return view('admin.Sportsbq/outcome', $dt->render($request));
  33. }
  34. function info(){
  35. $page = Request::has('page') ? Request::get('page') : '';
  36. $list = Request::has('limit') ? Request::get('limit') : 10;
  37. $home_team = Request::has('home_team') ? Request::get('home_team') : '';
  38. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  39. $status = Request::has('status') ? Request::get('status') : '';
  40. $source = Request::has('source') ? Request::get('source') : 'hg3535';
  41. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  42. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  43. $where = array();
  44. if ($status != -1) {
  45. $where[] = array('st_bq_result.status', '=', $status);
  46. }
  47. if (!empty($source)) {
  48. $where[] = array('st_bq_result.source', '=', $source);
  49. }
  50. if (!empty($star_time)) {
  51. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  52. $where[] = array('st_bq_result.start_time', '>', $star_time);
  53. }
  54. if (!empty($end_time)) {
  55. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  56. $where[] = array('st_bq_result.start_time', '<', $end_time);
  57. }//var_dump($where);die;
  58. $newapp = new \App\Models\Stbqresult();
  59. $data = $newapp->getinfo($list, $page, $where);
  60. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  61. }
  62. //作废
  63. function revoke(Req $req){
  64. $match_id = $req->match_id;//赛事id
  65. $model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
  66. $model->status = 4;
  67. $model->save();
  68. $smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
  69. if($smodel){
  70. $smodel->status = 4;
  71. $smodel->save();
  72. }
  73. $upapp = new \App\Models\SportsNoteList();
  74. $data = $upapp->updatesimplex($match_id,'bq');//修改单式状态
  75. //单式撤单返现
  76. $newapp = new \App\Models\MoneyBuyMatch();
  77. $all = $newapp->allsimplexorder($match_id,'bq');
  78. for ($i=0; $i < count($all); $i++) {
  79. $appgx = new \App\Lib\Settlement\SettlementOrder();
  80. $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'bq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
  81. }
  82. //串式撤单只改状态
  83. $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  84. $csapp = new \App\Models\MoneyBuyStr();
  85. $csapp->updatestatus($str_ids);//var_dump($ss);die;
  86. //修改money_buy_match 投注结果result=2为平
  87. $newapp->updatast($match_id);
  88. return responseToJson(1);
  89. }
  90. //结算
  91. function Settlement(Req $req){
  92. //查询赛事下所有订单
  93. $ssid = $req->match_id;//赛事id
  94. $type = $req->type;//是否再结算1,首次结算2,再次结算
  95. $newapp = new \App\Models\MoneyBuyMatch();
  96. $simplex_ids = array_column($newapp->allsimplexorder($ssid,'bq'),'order_id');
  97. $str_ids = array_column($newapp->allstrorder($ssid),'order_id');
  98. $update = $this->addcomendnotice($ssid);
  99. if($update['status']==1){
  100. $SettlementOrder = new SettlementOrder();
  101. $SettlementOrder->reSettlement($str_ids, 2,$type,'bq',$ssid);//串式
  102. $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'bq',$ssid);//单式注单
  103. return responseToJson($data);
  104. }else{
  105. return responseToJson($update);
  106. }
  107. }
  108. //查询赛事结果
  109. function Matchresult(Req $req){
  110. $match_id = $req->match_id;
  111. $newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
  112. $array =array(
  113. 'corner_ball' => json_decode($newapp['corner_ball'],true),
  114. 'penalty_card' => json_decode($newapp['penalty_card'],true),
  115. 'newapp' => $newapp,
  116. );
  117. return $array;
  118. }
  119. function onlyresult(Req $req){
  120. $match_id = $req->matchid;
  121. $newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
  122. return $newapp;
  123. }
  124. //结果添加
  125. function addend(Req $req){
  126. $match_id = $req->matchid;
  127. $model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
  128. $penaltycard = array(
  129. 'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
  130. 'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
  131. 'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
  132. 'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
  133. );
  134. $cornerball = array(
  135. 'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
  136. 'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
  137. 'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
  138. 'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
  139. );
  140. $model->first_score = $req->firstscore;
  141. $model->last_score = $req->lastscore;
  142. $model->match_winer = $req->matchwiner;
  143. $model->penalty_card = json_encode($penaltycard);
  144. $model->corner_ball = json_encode($cornerball);
  145. $model->save();
  146. return responseToJson(1);
  147. }
  148. }