SoccerNoteListController.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. $dt = \App\Lib\DataTable\DataTable::init();
  29. $dt->setDataSource('/admin/SoccerNoteList/info');
  30. $dt->setLang('sportsnotelist');
  31. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  32. $dt->addColsFields('match_id_order', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
  33. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
  34. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
  35. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
  36. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  37. $dt->addColsFields('water_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  38. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  39. //$dt->addColsFields('settle_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  40. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  41. $dt->addColsFields('account', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
  42. //$dt->addColsFields('member_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  43. $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  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. $type = '1';//单式注单
  55. $page = Request::has('page') ? Request::get('page') : '';
  56. $list = Request::has('limit') ? Request::get('limit') : 10;
  57. $account = Request::get('account') ? Request::get('account') : '';
  58. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  59. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  60. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  61. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  62. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  63. $where = array();
  64. if (!empty($account)) {
  65. if (empty($sureblur) || $sureblur == 'off') {
  66. $where[] = array('st_zq_bet.account_name', 'like', '%' . $account . '%');
  67. } else {
  68. $where[] = array('st_zq_bet.account_name', '=', $account);
  69. }
  70. }
  71. if (!empty($star_time)) {
  72. if (!empty($end_time)){
  73. $where[] = array('st_zq_bet.money_time', '>', $star_time);
  74. $where[] = array('st_zq_bet.money_time', '<', $end_time);
  75. }else{
  76. $where[] = array('st_zq_bet.money_time', '>', $star_time);
  77. }
  78. }else if(empty($star_time)){
  79. if (!empty($end_time)){
  80. $where[] = array('st_zq_bet.money_time', '<', $end_time);
  81. }
  82. }
  83. if (!empty($order_id)){
  84. $where[] = array('st_zq_bet.order_id', $order_id);
  85. }
  86. if (!empty($match_id)){
  87. $where[] = array('st_zq_bet.match_id', $match_id);
  88. }
  89. $newapp = new \App\Models\SportsNoteList();
  90. $data = $newapp->getinfo($list, $page, $where,$type);
  91. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  92. }
  93. /**
  94. *修改订单
  95. */
  96. function edit(Req $req) {
  97. $id = $req->id;
  98. if (intval($id) < 1) {
  99. return -1;
  100. }
  101. $lange = trans('sportssoccer');
  102. $data = \App\Models\SportsNoteList::where('id',$id)->first();
  103. $data->order_time = $data->order_id.' '.$data->money_time;
  104. //for($i=0;$i<count($data);$i++){
  105. $codes = json_decode($data->codes, true);
  106. $data->content = '';
  107. for($j=0;$j<count($codes);$j++){
  108. $odds_only = $data->odds_only;
  109. $res = DB::table('st_zq_odds_record')->where('odds_only',$odds_only)->first();
  110. $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
  111. //$result = \App\Models\Matchcode::where('odds_code',$res->odds_code)->first();
  112. $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
  113. $data->content = $data->content.$result['odds_name']. '¥'.$codes[$j]['bet_amount'];
  114. $data->game = $game->game_name;
  115. }
  116. //}
  117. if (!$req->isMethod('post')) {
  118. $data = $data->toArray();
  119. return view('sports/sports_notelist_form', $data);
  120. } else {
  121. $model = new \App\Models\SportsNoteList();
  122. $model->id = $req->input('id');
  123. $model = $model::find($model->id);
  124. $model->water_status = $req->input('water_status');
  125. $model->settle_status = $req->input('settle_status');
  126. $model->game_status = $req->input('game_status');
  127. //$model->utime = date('Y-m-d H:i:s',time());
  128. $model->save();
  129. return responseToJson(1);
  130. }
  131. }
  132. /**
  133. *订单审核
  134. */
  135. public function orderstatus(Req $req) {
  136. $id = $req->input('id');
  137. if (empty($id)) {
  138. return responseToJson(-2001); //id������
  139. }
  140. $ids = explode(',', $id);
  141. if (!is_array($ids) && intval($ids) < 0) {
  142. return responseToJson(-2002); //id����
  143. }
  144. if (is_array($ids) && count($ids) > 0) {
  145. foreach ($ids as $k => $v) {
  146. if (intval($v) < 1) {
  147. unset($ids[$k]);
  148. }
  149. }
  150. }
  151. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  152. if (!$rows) {
  153. return responseToJson(-2003); //id����
  154. }
  155. return responseToJson(1, trans('menu.delete_success')); //id����
  156. }
  157. /**
  158. *删除订单
  159. */
  160. public function delete(Req $req) {
  161. $id = $req->input('id');
  162. if (empty($id)) {
  163. return responseToJson(-2001); //id������
  164. }
  165. $ids = explode(',', $id);
  166. if (!is_array($ids) && intval($ids) < 0) {
  167. return responseToJson(-2002); //id����
  168. }
  169. if (is_array($ids) && count($ids) > 0) {
  170. foreach ($ids as $k => $v) {
  171. if (intval($v) < 1) {
  172. unset($ids[$k]);
  173. }
  174. }
  175. }
  176. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  177. if (!$rows) {
  178. return responseToJson(-2003); //id����
  179. }
  180. return responseToJson(1, trans('menu.delete_success')); //id����
  181. }
  182. /**
  183. * 投注金额统计
  184. */
  185. function moneycount()
  186. {
  187. $type = '1';//单式注单
  188. $where = Request::has('where') ? Request::get('where') : '';
  189. $db = new \App\Models\SportsNoteList;
  190. $data = $db->MoneyCount($where,$type);
  191. return responseToJson($data);
  192. }
  193. }