BaseNoteListController.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 BaseNoteListController 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['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
  24. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
  25. $dt = \App\Lib\DataTable\DataTable::init();
  26. $dt->setDataSource('/admin/BaseNoteList/info');
  27. $dt->setLang('sportsnotelist');
  28. $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  29. $dt->addColsFields('order_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
  30. $dt->addColsFields('game', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  31. $dt->addColsFields('game_no', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  32. $dt->addColsFields('prize_note', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  33. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  34. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  35. $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  36. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  37. $dt->addColsFields('water_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  38. //$dt->addColsFields('prize', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  39. $dt->addColsFields('settle_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  40. $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  41. $dt->addColsFields('account_name', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
  42. $dt->addColsFields('member_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  43. //$arr[] = 'view';
  44. if (checkRriv('/admin/BaseNoteList/edit')) {
  45. $arr[] = 'edit';
  46. }
  47. $dt->setToolBar($arr, array('width' => 70));
  48. $dt->enableCheckBox();
  49. return view('sports/sports_notelist', $dt->render($request));
  50. }
  51. function info()
  52. {
  53. $type = 'bq';
  54. $page = Request::has('page') ? Request::get('page') : '';
  55. $list = Request::has('limit') ? Request::get('limit') : 10;
  56. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  57. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  58. // $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  59. $where = array();
  60. if (!empty($star_time)) {
  61. if (!empty($end_time)){
  62. $where[] = array('money_buy.money_time', '>', $star_time);
  63. $where[] = array('money_buy.money_time', '<', $end_time);
  64. }else{
  65. $where[] = array('money_buy.money_time', '>', $star_time);
  66. }
  67. }else if(empty($star_time)){
  68. if (!empty($end_time)){
  69. $where[] = array('money_buy.money_time', '<', $end_time);
  70. }
  71. }
  72. $newapp = new \App\Models\SportsNoteList();
  73. $data = $newapp->getinfo($list, $page, $where,$type);
  74. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  75. }
  76. /**
  77. *修改订单
  78. */
  79. function edit(Req $req) {
  80. $id = $req->id;
  81. if (intval($id) < 1) {
  82. return -1;
  83. }
  84. $lange = trans('sportssoccer');
  85. $data = \App\Models\SportsNoteList::where('id',$id)->first();
  86. $data->order_time = $data->order_id.' '.$data->money_time;
  87. //for($i=0;$i<count($data);$i++){
  88. $codes = json_decode($data->codes, true);
  89. $data->content = '';
  90. for($j=0;$j<count($codes);$j++){
  91. $odds_only = $data->odds_only;
  92. $res = DB::table('st_bq_odds_record')->where('odds_only',$odds_only)->first();
  93. $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
  94. //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
  95. $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
  96. $data->content = $data->content.$result['odds_name']. '¥'.$codes[$j]['bet_amount'];
  97. $data->game = $game->game_name;
  98. }
  99. //}
  100. if (!$req->isMethod('post')) {
  101. $data = $data->toArray();
  102. return view('sports/sports_notelist_form', $data);
  103. } else {
  104. $model = new \App\Models\SportsNoteList();
  105. $model->id = $req->input('id');
  106. $model = $model::find($model->id);
  107. $model->water_status = $req->input('water_status');
  108. $model->settle_status = $req->input('settle_status');
  109. $model->game_status = $req->input('game_status');
  110. //$model->utime = date('Y-m-d H:i:s',time());
  111. $model->save();
  112. return responseToJson(1);
  113. }
  114. }
  115. /**
  116. *订单审核
  117. */
  118. public function orderstatus(Req $req) {
  119. $id = $req->input('id');
  120. if (empty($id)) {
  121. return responseToJson(-2001); //id������
  122. }
  123. $ids = explode(',', $id);
  124. if (!is_array($ids) && intval($ids) < 0) {
  125. return responseToJson(-2002); //id����
  126. }
  127. if (is_array($ids) && count($ids) > 0) {
  128. foreach ($ids as $k => $v) {
  129. if (intval($v) < 1) {
  130. unset($ids[$k]);
  131. }
  132. }
  133. }
  134. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  135. if (!$rows) {
  136. return responseToJson(-2003); //id����
  137. }
  138. return responseToJson(1, trans('menu.delete_success')); //id����
  139. }
  140. /**
  141. *删除订单
  142. */
  143. public function delete(Req $req) {
  144. $id = $req->input('id');
  145. if (empty($id)) {
  146. return responseToJson(-2001); //id������
  147. }
  148. $ids = explode(',', $id);
  149. if (!is_array($ids) && intval($ids) < 0) {
  150. return responseToJson(-2002); //id����
  151. }
  152. if (is_array($ids) && count($ids) > 0) {
  153. foreach ($ids as $k => $v) {
  154. if (intval($v) < 1) {
  155. unset($ids[$k]);
  156. }
  157. }
  158. }
  159. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  160. if (!$rows) {
  161. return responseToJson(-2003); //id����
  162. }
  163. return responseToJson(1, trans('menu.delete_success')); //id����
  164. }
  165. }