SportswqController.php 7.7 KB

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