SoccerNoteListController.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/4/9
  6. * Time: 9:11
  7. */
  8. namespace App\Http\Controllers\Admin;
  9. use App\Http\Controllers\Controller;
  10. use Illuminate\Http\Request as Req;
  11. use Illuminate\Support\Facades\DB;
  12. use App\Models;
  13. use Request;
  14. /**
  15. *
  16. */
  17. class SoccerNoteListController extends Controller
  18. {
  19. public function notelist(Req $req)
  20. {
  21. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  22. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  23. $request['account'] = isset($req->account) ? trim($req->account) :null ;
  24. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
  25. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
  26. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
  27. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
  28. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  29. $dt = \App\Lib\DataTable\DataTable::init();
  30. $dt->setDataSource('/admin/SoccerNoteList/info');
  31. $dt->setLang('sportsnotelist');
  32. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  33. $dt->addColsFields('match_id_order', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
  34. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 130));
  35. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
  36. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 230));
  37. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  38. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  39. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  40. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  41. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  42. $dt->addColsFields('account', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
  43. $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
  44. //$arr[] = 'view';
  45. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  46. // $arr[] = 'edit';
  47. // }
  48. // $dt->setToolBar($arr, array('width' => 70));
  49. $dt->enableCheckBox();
  50. return view('sports/sports_notelist', $dt->render($request));
  51. }
  52. function info()
  53. {
  54. $page = Request::has('page') ? Request::get('page') : '';
  55. $list = Request::has('limit') ? Request::get('limit') : 10;
  56. $account = Request::get('account') ? Request::get('account') : '';
  57. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  58. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  59. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  60. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  61. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  62. $type = Request::has('type') ? Request::get('type') : 'zq';
  63. $where = array();
  64. if (!empty($account)) {
  65. if (empty($sureblur) || $sureblur == 'off') {
  66. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  67. } else {
  68. $where[] = array('money_buy_simplex.account_name', '=', $account);
  69. }
  70. }
  71. if (!empty($star_time)) {
  72. if (!empty($end_time)){
  73. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  74. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  75. }else{
  76. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  77. }
  78. }else if(empty($star_time)){
  79. if (!empty($end_time)){
  80. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  81. }
  82. }
  83. if (!empty($order_id)){
  84. $where[] = array('money_buy_simplex.order_id', $order_id);
  85. }
  86. if (!empty($match_id)){
  87. $where[] = array('money_buy_simplex.match_id', $match_id);
  88. }
  89. $where[] = array('money_buy_simplex.game_code', $type);
  90. $newapp = new \App\Models\SportsNoteList();
  91. $data = $newapp->getinfo($list, $page, $where,$type);
  92. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  93. }
  94. /**
  95. *单式注单重新审核
  96. */
  97. public function reaudit(Req $req) {
  98. $id = $req->id;
  99. if (intval($id) < 1) {
  100. return -1;
  101. }
  102. $order = DB::table('money_buy_simplex')->where('id',$id)->first();
  103. //获取此订单下包含的赛事玩法
  104. $matchs = DB::table('money_buy_match')->where('batch_id',$order->batch_id)->where('match_id',$order->match_id)->where('bet_type','1')->get()->toArray();
  105. $win_money = 0;
  106. //减本金
  107. // for($i=0;$i<count($matchs);$i++){
  108. // $money = $matchs[$i]->bet_money;
  109. // if($matchs[$i]->result == 0){ //未处理
  110. // return "<script>history.go(-1);</script>";
  111. // }else if($matchs[$i]->result == -1){ //输
  112. // $money = 0-$matchs[$i]->bet_money;
  113. // }else if($matchs[$i]->result == 1){ //赢
  114. // $odds = $matchs[$i]->odds;
  115. // $money = $money*$odds-$matchs[$i]->bet_money;
  116. // }else if($matchs[$i]->result == 2){ //平
  117. // $money = 0;
  118. // }else if($matchs[$i]->result == 3){ //赢半平半
  119. // $odds = $matchs[$i]->odds;
  120. // $money = $money/2*$odds+$money/2*1-$matchs[$i]->bet_money;
  121. // }else if($matchs[$i]->result == 4){ //输半平半
  122. // $money = $money/2*1-$matchs[$i]->bet_money;
  123. // }
  124. // $win_money = $win_money+$money;
  125. // }
  126. //不减本金
  127. for($i=0;$i<count($matchs);$i++){
  128. $money = $matchs[$i]->bet_money;
  129. if($matchs[$i]->result == 0){ //未处理
  130. return "<script>history.go(-1);</script>";
  131. }else if($matchs[$i]->result == -1){ //输
  132. $money = 0;
  133. }else if($matchs[$i]->result == 1){ //赢
  134. $odds = $matchs[$i]->odds;
  135. $money = $money*$odds;
  136. }else if($matchs[$i]->result == 2){ //平
  137. $money = $money*1;
  138. }else if($matchs[$i]->result == 3){ //赢半平半
  139. $odds = $matchs[$i]->odds;
  140. $money = $money/2*$odds+$money/2*1;
  141. }else if($matchs[$i]->result == 4){ //输半平半
  142. $money = $money/2*1;
  143. }
  144. $win_money = $win_money+$money;
  145. }
  146. $model = new \App\Models\SportsNoteList();
  147. $model = $model::find($id);
  148. if($win_money < $order->money){
  149. $model->game_status = 2;
  150. }else if($win_money >= $order->money){
  151. $model->game_status = 1;
  152. }
  153. $model->settle_status = 2;
  154. $model->gain_money = $win_money;
  155. $model->save();
  156. return "<script>history.go(-1);</script>";
  157. }
  158. /**
  159. *删除订单
  160. */
  161. public function delete(Req $req) {
  162. $id = $req->input('id');
  163. if (empty($id)) {
  164. return responseToJson(-2001); //id������
  165. }
  166. $ids = explode(',', $id);
  167. if (!is_array($ids) && intval($ids) < 0) {
  168. return responseToJson(-2002); //id����
  169. }
  170. if (is_array($ids) && count($ids) > 0) {
  171. foreach ($ids as $k => $v) {
  172. if (intval($v) < 1) {
  173. unset($ids[$k]);
  174. }
  175. }
  176. }
  177. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  178. if (!$rows) {
  179. return responseToJson(-2003); //id����
  180. }
  181. return responseToJson(1, trans('menu.delete_success')); //id����
  182. }
  183. /**
  184. * 投注金额统计
  185. */
  186. function moneycount()
  187. {
  188. $where = Request::has('where') ? Request::get('where') : '';
  189. $db = new \App\Models\SportsNoteList;
  190. $data = $db->MoneyCount($where);
  191. return responseToJson($data);
  192. }
  193. }