IndexController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Support\Facades\App;
  5. use Illuminate\Support\Facades\DB;
  6. /**
  7. *
  8. */
  9. class IndexController extends Controller {
  10. function welcome() {
  11. $total = array(
  12. 'total_user' => $this->countTodayUser(),
  13. 'total_bet' => $this->countBet(),
  14. 'today_take' => $this->countTodayTake(),
  15. 'today_recharge' => $this->countTodayRecharge(),
  16. 'today_return' => $this->countTodayReturn(),
  17. 'today_rimit' => $this->countTodayRimt(),
  18. );
  19. if (\App\Models\Role::hasRoot('/enable/show/get_money_count') < 0) {
  20. $get_money_count = "*****";
  21. } else {
  22. $get_money_count = $total['today_recharge']['count'];
  23. }
  24. $notice = $this->getNotice();
  25. $message = $this->Message();
  26. return view('admin/welcome', ['total' => $total, 'notice' => $notice, 'message' => $message, 'get_money_count' => $get_money_count]);
  27. }
  28. //返回用户数量
  29. function countUser() {
  30. return \App\Models\Account_detailed::count();
  31. }
  32. //今日注册用户数量
  33. function countTodayUser() {
  34. $time1 = date('Y-m-d 00:00:00'); //今日0时
  35. $time2 = date('Y-m-d 23:59:59'); //
  36. $timearea = [$time1, $time2];
  37. if (\App\Models\Role::hasRoot('/enable/show/today_user') < 0) {
  38. $user_data['today_user'] = "*****";
  39. } else {
  40. $user_data['today_user'] = \App\Models\Account_detailed::whereBetween('register_time', $timearea)->join('account', 'account_detailed.account_identity', '=', 'account.identity')->where('status', '1')->count();
  41. }
  42. if (\App\Models\Role::hasRoot('/enable/show/last_online') < 0) {
  43. $user_data['last_online'] = "*****";
  44. } else {
  45. $user_data['last_online'] = \App\Models\Account_Token::whereBetween('last_time', $timearea)->count();
  46. }
  47. if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
  48. $user_data['user_count'] = "*****";
  49. } else {
  50. $user_data['user_count'] = \App\Models\Account_detailed::count();
  51. }
  52. return $user_data;
  53. }
  54. //注单总数量
  55. function countBet() {
  56. $time1 = date('Y-m-d 00:00:00'); //今日0时
  57. $time2 = date('Y-m-d 23:59:59'); //
  58. $timearea = [$time1, $time2];
  59. if (\App\Models\Role::hasRoot('/enable/show/bet_count') < 0) {
  60. $bet_count['count'] = "*****";
  61. } else {
  62. $bet_count['count'] = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->count();
  63. }
  64. if (\App\Models\Role::hasRoot('/enable/show/bet_money') < 0) {
  65. $bet_money = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->sum('money');
  66. $bet_count['money_count'] = "*****";
  67. } else {
  68. $bet_money = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->sum('money');
  69. $bet_count['money_count'] = round($bet_money, 2);
  70. }
  71. // DB::connection()->enableQueryLog();
  72. if (\App\Models\Role::hasRoot('/enable/show/countBet') < 0) {
  73. $db = new \App\Models\MoneyBuy;
  74. $bet_count['user_count'] = "*****";
  75. } else {
  76. $db = new \App\Models\MoneyBuy;
  77. $bet_count['user_count'] = $db->countUser($timearea);
  78. }
  79. // $queries = DB::getQueryLog();
  80. // print_r($queries);
  81. return $bet_count;
  82. }
  83. //今日提现
  84. function countTodayTake() {
  85. $time1 = date('Y-m-d 00:00:00'); //今日0时
  86. $time2 = date('Y-m-d 23:59:59'); //
  87. $timearea = [$time1, $time2];
  88. if (\App\Models\Role::hasRoot('/enable/show/count') < 0) {
  89. $take_count['count'] = "*****";
  90. } else {
  91. $take_count['count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->count();
  92. }
  93. if (\App\Models\Role::hasRoot('/enable/show/money_count') < 0) {
  94. $take_count['money_count'] = "*****";
  95. } else {
  96. $take_count['money_count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->sum('money');
  97. }
  98. // DB::connection()->enableQueryLog();
  99. if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
  100. $db = new \App\Models\Money_take;
  101. $take_count['user_count'] = "*****";
  102. } else {
  103. $db = new \App\Models\Money_take;
  104. $take_count['user_count'] = $db->countUser($timearea);
  105. }
  106. // $queries = DB::getQueryLog();
  107. // dump($queries);
  108. // dump($take_count);
  109. return $take_count;
  110. }
  111. //今日充值笔数
  112. function countTodayRecharge() {
  113. $time1 = date('Y-m-d 00:00:00'); //今日0时
  114. $time2 = date('Y-m-d 23:59:59'); //
  115. $timearea = [$time1, $time2];
  116. // DB::connection()->enableQueryLog();
  117. if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge') < 0) {
  118. $rech_data['count'] = "*****";
  119. } else {
  120. $rech_data['count'] = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->count();
  121. }
  122. // $queries = DB::getQueryLog();
  123. // print_r($queries);
  124. if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_money') < 0) {
  125. $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
  126. $rech_data['money_count'] = "*****";
  127. } else {
  128. $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
  129. $rech_data['money_count'] = round($money_count, 2);
  130. }
  131. // DB::connection()->enableQueryLog();
  132. if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_user') < 0) {
  133. $db = new \App\Models\Money_details;
  134. $count = $db->countUser($timearea, array(6, 11));
  135. $rech_data['user_count'] = "*****";
  136. } else {
  137. $db = new \App\Models\Money_details;
  138. $count = $db->countUser($timearea, array(6, 11));
  139. $rech_data['user_count'] = $count;
  140. }
  141. // $queries = DB::getQueryLog();
  142. // dump($queries);
  143. return $rech_data;
  144. }
  145. // 今日回水笔数
  146. function countTodayReturn() {
  147. $time1 = date('Y-m-d 00:00:00'); //今日0时
  148. $time2 = date('Y-m-d 23:59:59'); //
  149. $timearea = [$time1, $time2];
  150. if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn') < 0) {
  151. $return['count'] = "*****";
  152. } else {
  153. $return['count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->count();
  154. }
  155. if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_money') < 0) {
  156. $return['money_count'] = "*****";
  157. } else {
  158. $return['money_count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->sum('money');
  159. }
  160. // $return['user_count'] = \App\Model\Money_return::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
  161. if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_user') < 0) {
  162. $db = new \App\Models\Money_return;
  163. $return['user_count'] = "*****";
  164. } else {
  165. $db = new \App\Models\Money_return;
  166. $return['user_count'] = $db->countUser($timearea);
  167. }
  168. return $return;
  169. }
  170. // 今日反水笔数
  171. function countTodayBack() {
  172. $time1 = date('Y-m-d 00:00:00'); //今日0时
  173. $time2 = date('Y-m-d 23:59:59'); //
  174. $timearea = [$time1, $time2];
  175. if (\App\Models\Role::hasRoot('/enable/show/countTodayBack') < 0) {
  176. $return['count'] = "*****";
  177. } else {
  178. $return['count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->count();
  179. }
  180. if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_money') < 0) {
  181. $return['money_count'] = "*****";
  182. } else {
  183. $return['money_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->sum('money');
  184. }
  185. if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_user') < 0) {
  186. $return['user_count'] = "*****";
  187. } else {
  188. $return['user_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
  189. }
  190. return $return;
  191. }
  192. //今日汇款
  193. function countTodayRimt() {
  194. $time1 = date('Y-m-d 00:00:00'); //今日0时
  195. $time2 = date('Y-m-d 23:59:59'); //
  196. $timearea = [$time1, $time2];
  197. if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt') < 0) {
  198. $rimit['count'] = "*****";
  199. } else {
  200. $rimit['count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->count();
  201. }
  202. if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_money') < 0) {
  203. $rimit['money_count'] = "*****";
  204. } else {
  205. $rimit['money_count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->sum('money');
  206. }
  207. if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_user') < 0) {
  208. $db = new \App\Models\Money_recharge;
  209. $rimit['user_count'] = "*****";
  210. } else {
  211. $db = new \App\Models\Money_recharge;
  212. $rimit['user_count'] = $db->countRimitUser($timearea);
  213. }
  214. return $rimit;
  215. }
  216. //公告信息
  217. function getNotice() {
  218. $db = new \App\Models\Article();
  219. $data = $db->getMsg(2, 2);
  220. return $data;
  221. }
  222. //当前在线用户饼状图
  223. function onlineUser() {
  224. // $db = new \App\Model\Logfile;
  225. // $db=new \App\Model\Account_Token;
  226. $db = new \App\Models\Account_detailed;
  227. $data_log = $db->getOnlineUser();
  228. // $data_log = $db->getUser();
  229. $array['data'] = $data_log;
  230. if (empty($data_log)) {
  231. $array['data'][0]['name'] = '没有';
  232. $array['data'][0]['value'] = 0;
  233. }
  234. //组装标
  235. $count = 0;
  236. foreach ($array['data'] as $k => $v) {
  237. $array['title'][$k] = trim($v['name']);
  238. $array['data'][$k]['name'] = trim($v['name']);
  239. $count += $v['value'];
  240. }
  241. //总在线数量、
  242. $array['text'] = date('Y-m-d') . trans('common.today_user_num') . $count;
  243. return responseToJson($array);
  244. // dump($array);
  245. }
  246. //今日投注统计饼状图
  247. function getBetUrl() {
  248. $db = new \App\Models\OrderUrl;
  249. $data = $db->getUrlBet();
  250. $array['data'] = $data;
  251. if (empty($data)) {
  252. $array['data'][0]['name'] = '没有';
  253. $array['data'][0]['value'] = 0;
  254. }
  255. //组装标
  256. foreach ($array['data'] as $k => $v) {
  257. $array['title'][$k] = $v['name'];
  258. }
  259. //添加标题
  260. //总投注数量
  261. $count = $db->gettotal();
  262. $array['text'] = date('Y-m-d') . trans('common.today_bet_num') . $count;
  263. // dump($array);
  264. return responseToJson($array);
  265. }
  266. //时间区
  267. function getTime() {
  268. $time = array(
  269. 'addrss' => date_default_timezone_get(),
  270. 'time' => date("Y-m-d H:i:s", time() + 3600 * 8),
  271. );
  272. // print_r($time['time']);die;
  273. return responseToJson($time);
  274. }
  275. //最近7天会员注册情况
  276. function regUser() {
  277. $time2 = date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 30);
  278. $time1 = date('Y-m-d H:i:s', time());
  279. $timearea = [$time2, $time1];
  280. // $rech_data['money_with'] = DB::table('account_detailed')->join('account', 'account.identity', '=', 'money_details.account_identity')->select(DB::Raw('sum(money) as with'))->whereBetween('money_time', $timearea)->groupBy('account')->where('trade_type', 5)->get();
  281. $rimit = \App\Models\Account_list::where('account_status', 1)
  282. ->select(DB::Raw('date(register_time) as name, count(identity) as value'))
  283. ->whereBetween('register_time', $timearea)->orderBy(DB::Raw('date(register_time)'))->groupBy(DB::Raw('date(register_time)'))->get();
  284. $data = $rimit->toArray();
  285. foreach ($data as $k => $v) {
  286. $array['title'][$k] = $v['name'];
  287. $array['data']['num'][$k] = $v['value'];
  288. }
  289. $array['legend'][] = '最近注册用户记录';
  290. return responseToJson($array);
  291. }
  292. //最近7天财务情况
  293. function money() {
  294. $res_array = array();
  295. for ($i = 6; $i >= 0; $i--) {
  296. $secondes = $i * 24 * 60 * 60;
  297. $res_array['title'][] = date('Y-m-d', (time() - $secondes));
  298. $res_array['data']['money_with'][] = 0;
  299. $res_array['data']['money_recharge'][] = 0;
  300. $res_array['data']['money_remittance'][] = 0;
  301. $res_array['data']['money_trans'][] = 0;
  302. $res_array['data']['profit'][] = 0;
  303. }
  304. $res_array['legend']['money_with'] = trans('user.money_with');
  305. $res_array['legend']['money_recharge'] = trans('user.money_recharge');
  306. $res_array['legend']['money_remittance'] = trans('user.money_remittance');
  307. $res_array['legend']['money_trans'] = trans('user.money_trans');
  308. $res_array['legend']['profit'] = '盈利';
  309. $db = new \App\Models\Money_details;
  310. $data = $db->getBet();
  311. if ($data < 0) {
  312. return responseToJson($res_array);
  313. }
  314. $trade_type = $this->getTradetype();
  315. foreach ($data as $k => $v) {
  316. foreach ($res_array['title'] as $tk => $tv) {
  317. if ($v['date'] == $tv) {
  318. $res_array['data'][$trade_type[$v['trade_type']]][$tk] += $v['value'];
  319. $res_array['data'][$trade_type[1]][$tk] += ($v['trade_type'] == 5) ? -$v['value'] : +$v['value'];
  320. break;
  321. }
  322. }
  323. }
  324. return responseToJson($res_array);
  325. /*print_r($data);exit;
  326. $i = 0;
  327. $array['title']=array();
  328. foreach ($data as $k => $v) {
  329. if (is_array($v) && count($v) > 0) {
  330. foreach ($v as $ka => $va) {
  331. $array['title'][$i] = $va['date'];
  332. $temp[$k][$va['date']] = $va['value'];
  333. $i++;
  334. }
  335. } else {
  336. $temp[$k] = array();
  337. }
  338. $array['legend'][$k] = trans('user.' . $k);
  339. }
  340. $array['title']=array_unique($array['title']);
  341. asort($array['title']);
  342. $tem=array();
  343. foreach($array['title'] as $v){
  344. $tem[]=$v;
  345. }
  346. $array['title']=$tem;
  347. $te = array();
  348. foreach ($array['title'] as $k => $v) {
  349. if (array_key_exists($v, $temp['money_with'])) {
  350. $te['money_with'][] = $temp['money_with'][$v];
  351. $money_with=$temp['money_with'][$v];
  352. } else {
  353. $te['money_with'][] = 0;
  354. $money_with=0;
  355. }
  356. if (array_key_exists($v, $temp['money_recharge'])) {
  357. $te['money_recharge'][] = $temp['money_recharge'][$v];
  358. $money_recharge=$temp['money_recharge'][$v];
  359. } else {
  360. $te['money_recharge'][] = 0;
  361. $money_recharge=0;
  362. }
  363. if (array_key_exists($v, $temp['money_remittance'])) {
  364. $te['money_remittance'][] = $temp['money_remittance'][$v];
  365. $money_remittance=$temp['money_remittance'][$v];
  366. } else {
  367. $te['money_remittance'][] = 0;
  368. $money_remittance=0;
  369. }
  370. if (array_key_exists($v, $temp['money_trans'])) {
  371. $te['money_trans'][] = $temp['money_trans'][$v];
  372. $money_trans=$temp['money_trans'][$v];
  373. } else {
  374. $te['money_trans'][] = 0;
  375. $money_trans=0;
  376. }
  377. $te['profit'][]=$money_trans+$money_remittance+$money_recharge-$money_with;
  378. }
  379. $array['legend']['profit']='盈利';
  380. $array['data'] = $te;
  381. return responseToJson($array);*/
  382. }
  383. private function getTradetype() {
  384. $tradetype = array(
  385. '5' => 'money_with',
  386. '6' => 'money_recharge',
  387. '11' => 'money_trans',
  388. '14' => 'money_remittance',
  389. '1' => 'profit',
  390. );
  391. return $tradetype;
  392. }
  393. //每天每个游戏注单数
  394. function TodayGameNote() {
  395. $time1 = date('Y-m-d 00:00:00');//今日零时
  396. $time2 = date('Y-m-d 23:59:59');//今日末时
  397. // $time1='2017-09-14 00:00:00';
  398. // $time2='2017-09-14 23:59:59';
  399. $timearea = [$time1, $time2];
  400. $data = \App\Models\MoneyBuy::select('game_name as name', DB::Raw('count(id) as value'))->whereBetween('money_time', $timearea)->groupBy('game_name')->get();
  401. $data = $data->toArray();
  402. if (count($data) == 0) {
  403. $data = array(array('name' => 'no_bet', 'value' => 0));
  404. }
  405. $array = array();
  406. foreach ($data as $k => $v) {
  407. $data[$k]['name'] = trans('common.' . $v['name']);
  408. $array['title'][$k] = trans('common.' . $v['name']);
  409. }
  410. $array['data'] = $data;
  411. $array['text'] = '今日游戏注单数量:' . date('Y-m-d');
  412. return responseToJson($array);
  413. }
  414. //拉时间
  415. function pullTime() {
  416. //获取前台域名
  417. $setInfo = new \App\Models\Setinfo();
  418. $info = $setInfo->getInfo(18);
  419. if ($info < 0) {
  420. return responseToJson($info);
  421. }
  422. //$a=file_get_contents($info['infocontent'].'api-common/getTime');
  423. $url = $info['infocontent'] . 'api-common/getTime';
  424. $timeout = 30;
  425. $ch = curl_init();
  426. curl_setopt($ch, CURLOPT_URL, $url);
  427. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  428. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 2);
  429. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  430. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  431. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //避免data数据过长问题
  432. curl_setopt($ch, CURLOPT_POST, true);
  433. curl_setopt($ch, CURLOPT_POSTFIELDS, array());
  434. $a = curl_exec($ch);
  435. curl_close($ch);
  436. echo $a;
  437. }
  438. //通知消息
  439. function Message() {
  440. $admin_id = session('adminInfo.admin_id');
  441. $db = new \App\Models\MessageRead;
  442. $dbs = new \App\Models\Manager;
  443. $where = [
  444. 'type',
  445. '4'
  446. ];
  447. $datas = $dbs->getlistd($where);
  448. $data = $db->getlist($admin_id);
  449. if (!empty($data)) {
  450. foreach ($datas as $k => $v) {
  451. foreach ($data as $val) {
  452. if ($v['id'] == $val['message_id']) {
  453. $datas[$k]['status'] = '1';
  454. }
  455. }
  456. }
  457. }
  458. return $datas;
  459. }
  460. //刷新缓存
  461. public function refresh() {
  462. return view('admin.refresh');
  463. }
  464. }