UnsetController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?php
  2. /**
  3. * 游戏未结算注单
  4. */
  5. namespace App\Http\Controllers\Admin;
  6. use App\Http\Controllers\Controller;
  7. use Illuminate\Http\Request as Req;
  8. use Illuminate\Support\Facades\DB;
  9. use Request;
  10. class UnsetController extends Controller {
  11. public $point = [
  12. '1001'=>'pc投注',
  13. '1002'=>'wap投注',
  14. '1003'=>'长龙投注'
  15. ];
  16. /**
  17. * 游戏开关
  18. */
  19. function Index() {
  20. // $game = Request::has('game') ? Request::get('game') : '';
  21. // $data = Request::has('data') ? Request::get('data') : '';
  22. // $no = Request::has('no') ? Request::get('no') : '';
  23. // $name = Request::has('name') ? Request::get('name') : '';
  24. $request=array();
  25. $request['game'] = Request::has('game') ? Request::get('game') : 'xy28';
  26. $request['account_name'] = Request::has('account_name') ? Request::get('account_name') : '';
  27. $request['order_id'] = Request::has('order_id') ? Request::get('order_id') : '';
  28. // $request['game'] = Request::get('name') ? Request::get('name') : $name;
  29. $request['game_no'] = Request::has('game_no') ? Request::get('game_no') : '';
  30. $request['bet_small'] = Request::has('bet_small') ? Request::get('bet_small') : '';
  31. $request['bet_big'] = Request::has('bet_big') ? Request::get('bet_big') : '';
  32. $request['winfail_small'] = Request::has('winfail_small') ? Request::get('winfail_small') : '';
  33. $request['winfail_big'] = Request::has('winfail_big') ? Request::get('winfail_big') : '';
  34. $request['money_big'] = Request::has('money_big') ? Request::get('money_big') : '';
  35. $request['money_small'] = Request::has('money_small') ? Request::get('money_small') : '';
  36. $request['star_time'] = Request::has('star_time') ?Request::get('star_time'): trans('status.default_time.seven_day');
  37. $request['end_time'] = Request::has('end_time') ? Request::get('end_time') : trans('status.default_time.etime');
  38. $request['status'] = Request::has('status') ? Request::get('status') : '';
  39. $request['game_point'] = Request::has('game_point') ? Request::get('game_point') : '';
  40. $request['gameList']=\App\Models\GameType::getGameType();
  41. $dt = \App\Lib\DataTable\DataTable::init();
  42. $dt->enableCheckBox();
  43. $dt->setDataSource('/admin/Unset/dataSource?game=' . $request['game'] . '&account_name=' . $request['account_name'] . '&game_no=' . $request['game_no'] . '&game_status=0');
  44. $dt->setLang('bet_order');
  45. $dt->addColsFields('name', array('sort' => false, 'width' => 130));
  46. $dt->addColsFields('game_no', array('width' => 120, 'templet' => '#game_no'));
  47. $dt->addColsFields('money_time', array('sort' => true, 'width' => 235));
  48. // $dt->addColsFields('prizes_code', array('width' => 220));
  49. $dt->addColsFields('money', array('width' => 120,'templet' => '#moneynew'));
  50. $dt->addColsFields('get_money', array('width' => 120, 'templet' => '#money'));
  51. $dt->addColsFields('winmoney', array('sort' => false,'width' => 120));
  52. // $dt->addColsFields('money_time', array('width' => 160));
  53. $dt->addColsFields('account_getw', array('sort' => false, 'templet' => '#account', 'width' => 145));
  54. $dt->addColsFields('game_status', array('templet' => '#acc', 'sort' => false, 'width' => 100));
  55. $dt->addColsFields('bet_', array('sort' => false));
  56. //加在表头
  57. // $table = new \App\Lib\Biz\Game\Table\GameTable;
  58. // $table->gameTable($dt, $game);
  59. //$dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));
  60. $dt->addColsFields('tool',array('width'=>110,'templet'=>'#tool','sort' => false));
  61. if (!empty($data)) {
  62. return responseToJson($dt->render());
  63. }
  64. return view('admin.unset/index', $dt->render($request));
  65. }
  66. function dataSource(Req $req) {
  67. $game = Request::has('game') ? Request::get('game') : '';
  68. $page = Request::has('page') ? Request::get('page') : '';
  69. $list = Request::has('limit') ? Request::get('limit') : '';
  70. $field = !empty(Request::get('field')) ? Request::get('field') : 'money_time';
  71. $order = !empty(Request::get('order')) ? Request::get('order') : 'desc';
  72. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  73. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  74. // $game = Request::has('name') ? Request::get('name') : '';
  75. $game_no = Request::has('game_no') ? Request::get('game_no') : '';
  76. $bet_small = Request::has('bet_small') ? Request::get('bet_small') : '';
  77. $bet_big = Request::has('bet_big') ? Request::get('bet_big') : '';
  78. $winfail_small = Request::has('winfail_small') ? Request::get('winfail_small') : '';
  79. $winfail_big = Request::has('winfail_big') ? Request::get('winfail_big') : '';
  80. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  81. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  82. $game_status = !empty(Request::get('game_status')) ? Request::get('game_status') : 0;
  83. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  84. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  85. $status = !empty(Request::get('status')) ? Request::get('status') : '';
  86. $game_point = Request::get('game_point') ? Request::get('game_point') : '';
  87. $where = array();
  88. $where[] = array('status', '<>', 4);
  89. //排除六合彩
  90. $where[]=array('game_name','<>','sixlottery');
  91. // if (!empty($name)) {
  92. // $game = $name;
  93. // $where[] = array('game_name', '=', $name);
  94. // }
  95. //权限检测
  96. if(!checkRriv('/bet/game/'.$game)){
  97. return \App\Lib\DataTable\DataTable::init()->toJson(array(), 1, 0, $where);
  98. }
  99. if (!empty($game)) {
  100. $where[] = array('game_name', '=', $game);
  101. }
  102. if (!empty($bet_small)) {
  103. $where[] = array('money', '>=', $bet_small);
  104. }
  105. if (!empty($bet_big)) {
  106. $where[] = array('money', '<=', $bet_big);
  107. }
  108. if (!empty($winfail_small)) {
  109. $where[] = array('get_money', '>=', $winfail_small);
  110. }
  111. if (!empty($winfail_big)) {
  112. $where[] = array('get_money', '<=', $winfail_big);
  113. }
  114. if (!empty($money_small)) {
  115. $where[] = array('prize_money', '>=', $money_small);
  116. }
  117. if (!empty($money_big)) {
  118. $where[] = array('prize_money', '<=', $money_big);
  119. }
  120. if (is_numeric($game_status)) {
  121. $where[] = array('game_status', '=', $game_status);
  122. }
  123. if (!empty($star_time)) {
  124. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  125. $where[] = array('money_time', '>=', $star_time);
  126. }
  127. if (!empty($end_time)) {
  128. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  129. $where[] = array('money_time', '<=', $end_time);
  130. }
  131. if (!empty($status)) {
  132. $where[] = array('status', '=', $status);
  133. }
  134. if (!empty($order_id)) {
  135. $where = array(array('order_id', '=', $order_id));
  136. }
  137. if (!empty($game_no)) {
  138. $where = array(array('game_no', '=', $game_no));
  139. }
  140. if (!empty($account_name)) {
  141. $where[] = array('account_name', 'like', '%' . $account_name . '%');
  142. }
  143. if(!empty($game_point)){
  144. $where[] = array('remark', 'like', '%|'.$game_point.'|%');
  145. }
  146. // $where[] = array('status', '!=', 4);
  147. $db = new \App\Models\MoneyBuy();
  148. $data = $db->getBuy($where, $list, $page, $field, $order);
  149. $gameParse = new \App\Lib\Biz\Game\Parse\GameParse;
  150. // $total = array('total_bet_money' => 0, 'win_money' => 0);
  151. foreach ($data['data'] as $k => $v) {
  152. $data['data'][$k] = $gameParse->packbet($v, $v['game_name']); //开奖号码解析
  153. $data['data'][$k]['winmoney'] = $gameParse->winMomey($v['codes']); //可盈金额
  154. $data['data'][$k]['money_time'] = $v['order_id'] . '<br>' . $v['money_time'];
  155. $data['data'][$k]['game_no_prize'] = $v['game_no'] . '<br/>';
  156. if(isset($data['data'][$k]['prizes_code'])){
  157. $data['data'][$k]['game_no_prize'].=$data['data'][$k]['prizes_code'];
  158. }
  159. // $total['total_bet_money'] += $v['money'];
  160. // $total['win_money'] += $v['get_money'];
  161. }
  162. $data['data'] = arrayToNumber($data['data'], ['money', 'get_money', 'winmoney']);
  163. $long = $this->getLongtype();
  164. foreach ($data['data'] as $k => $v) {
  165. if(!empty($v['remark'])){
  166. $remark = explode('|', $v['remark']);
  167. if(isset($remark[3]) && isset($long[$remark[3]])){
  168. $data['data'][$k]['remark'] = $long[$remark[3]];
  169. }else if(isset($remark[1]) && !empty($remark[1])){
  170. $data['data'][$k]['remark'] = $this->point[$remark[1]];
  171. }else{
  172. $data['data'][$k]['remark'] = '';
  173. }
  174. }else{
  175. $data['data'][$k]['remark'] = '';
  176. }
  177. }
  178. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  179. // return responseToJson($data);
  180. }
  181. //获取投注来源
  182. private function getLongtype(){
  183. return $long = array(
  184. '3' => '长龙助手',
  185. '4' => '路珠长龙',
  186. );
  187. }
  188. function Code(Req $req) {
  189. $game = isset($req->game) ? $req->game : '';
  190. $no = $req->no;
  191. if (empty($game)) {
  192. abort(404);
  193. }
  194. $path = '\App\Models\Game' . ucfirst($game);
  195. $db = new $path;
  196. $prize_data = $db->getPrizeCodes($no);
  197. if ($prize_data < 0) {
  198. echo '没有该期开奖数据';
  199. }
  200. $parse = new \App\Lib\Biz\Game\Parse\GameParse;
  201. $data = $parse->prizeParse($prize_data, $game);
  202. return view('admin.unset/prizeCode', ['data' => $data]);
  203. }
  204. //整期作废
  205. function Cancel(Req $req) {
  206. $type = $req->type;
  207. if (!$req->isMethod('post')) {
  208. return view('admin.unset/unset_del', ['type' => $type]);
  209. } else {
  210. $game = $req->game;
  211. $info_no = $req->no;
  212. $password = $req->password;
  213. if (!is_numeric($info_no)) {
  214. return responseToJson(-5030013022);
  215. }
  216. if (empty($password)) {
  217. return responseToJson(-7010000622);
  218. }
  219. if (empty($game)) {
  220. return responseToJson(-5040000201);
  221. }
  222. //验证密码
  223. $admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
  224. if (!$admin_info) {
  225. return responseToJson(-7010100202);
  226. }
  227. $admin_info = $admin_info->toArray();
  228. if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
  229. return responseToJson(-7010001622);
  230. }
  231. if (($check = $this->checkNo($game, $info_no)) < 0) {
  232. return responseToJson($check);
  233. }
  234. DB::beginTransaction();
  235. $path = '\App\Models\Game' . ucfirst($game) . '_Buy';
  236. $game_buy_table = new $path;
  237. $where[] = array('no', '=', $info_no);
  238. $res = $game_buy_table->Cancel($where);
  239. if ($res < 0) {
  240. DB::rollBack();
  241. return responseToJson($res);
  242. }
  243. $buy_table = new \App\Models\MoneyBuy;
  244. $whe[] = array('game_name', '=', $game);
  245. $whe[] = array('game_no', '=', $info_no);
  246. $res2 = $buy_table->Cancel($whe);
  247. if ($res2 < 0) {
  248. DB::rollBack();
  249. return responseToJson($res2);
  250. }
  251. DB::commit();
  252. return responseToJson(1);
  253. }
  254. }
  255. //检测改期是否开奖
  256. private function checkNo($game, $info_no) {
  257. $path = '\App\Models\Game' . ucfirst($game);
  258. $game_table = new $path;
  259. $res = $game_table->where('info_no', $info_no)->where('status', 0)->frist();
  260. if (!$res) {
  261. return 1;
  262. }
  263. return -5051263522;
  264. }
  265. //批量作废
  266. function delete(Req $req) {
  267. $id = $req->id;
  268. if (!$req->isMethod('post')) {
  269. return view('admin.game/unset_del', ['id' => $id]);
  270. } else {
  271. $password = $req->password;
  272. if (empty($password)) {
  273. return responseToJson(-7010000622);
  274. }
  275. $ids = explode(',', $id);
  276. //验证密码
  277. $admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
  278. if (!$admin_info) {
  279. return responseToJson(-7010100202);
  280. }
  281. $admin_info = $admin_info->toArray();
  282. if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
  283. return responseToJson(-7010001622);
  284. }
  285. //撤销的订单
  286. DB::beginTransaction();
  287. $buy_table = new \App\Models\MoneyBuy;
  288. $res2 = $buy_table->CancelByids($ids);
  289. if ($res2 < 0) {
  290. DB::rollBack();
  291. return responseToJson($res2);
  292. }
  293. DB::commit();
  294. return responseToJson(1);
  295. }
  296. }
  297. //查看投注详情
  298. function view(Req $req) {
  299. $dt = \App\Lib\DataTable\DataTable::init();
  300. $id = $req->id;
  301. $game_no = $req->game_no;
  302. $game_name = $req->game_name;
  303. if (empty($id)) {
  304. abort(404);
  305. }
  306. $db = new \App\Models\MoneyBuy();
  307. $data = $db->getInfoByID($id);
  308. $dt->setDataSource('/admin/game/CodeDetails?id=' . $id."&game_no=".$game_no."&game_name=".$game_name);
  309. $dt->setlang($data['game_name']);
  310. $dt->addColsFields('gameType', array('sort' => false, 'width' => 100));
  311. $dt->addColsFields('codes', array('sort' => false));
  312. $dt->addColsFields('money', array('sort' => false, 'width' => 100));
  313. $dt->addColsFields('odds', array('sort' => false, 'width' => 100));
  314. $dt->addColsFields('back', array('sort' => false, 'width' => 100));
  315. $dt->addColsFields('maybe', array('sort' => false, 'width' => 100));
  316. $dt->addColsFields('get_money', array('sort' => false, 'templet' => '#getMoney', 'width' => 100));
  317. $dt->addColsFields('prize_status', array('sort' => false, 'templet' => '#status', 'width' => 110));
  318. $dt->addColsFields('remark',array('sort'=>false,'width'=> '200','title'=>'备注'));
  319. return view('admin.unset/betdatial', $dt->render());
  320. }
  321. }