| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\App;
- use Illuminate\Support\Facades\DB;
- /**
- *
- */
- class IndexController extends Controller
- {
- function welcome()
- {
- $total = array(
- 'total_user' => $this->countTodayUser(),
- 'total_bet' => $this->countBet(),
- 'today_take' => $this->countTodayTake(),
- 'today_recharge' => $this->countTodayRecharge(),
- 'today_return' => $this->countTodayReturn(),
- 'today_rimit' => $this->countTodayRimt(),
- );
- if (\App\Models\Role::hasRoot('/enable/show/get_money_count') < 0) {
- $get_money_count = "*****";
- } else {
- $get_money_count = $total['today_recharge']['count'];
- }
- $notice = $this->getNotice();
- $message = $this->Message();
- return view('admin/welcome', ['total' => $total, 'notice' => $notice, 'message' => $message, 'get_money_count' => $get_money_count]);
- }
- //返回用户数量
- function countUser()
- {
- return \App\Models\Account_detailed::count();
- }
- //今日注册用户数量
- function countTodayUser()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/today_user') < 0) {
- $user_data['today_user'] = "*****";
- } else {
- $user_data['today_user'] = \App\Models\Account_detailed::whereBetween('register_time', $timearea)->join('account', 'account_detailed.account_identity', '=', 'account.identity')->where('status', '1')->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/last_online') < 0) {
- $user_data['last_online'] = "*****";
- } else {
- $user_data['last_online'] = \App\Models\Account_Token::whereBetween('last_time', $timearea)->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
- $user_data['user_count'] = "*****";
- } else {
- $user_data['user_count'] = \App\Models\Account_detailed::count();
- }
- return $user_data;
- }
- //注单总数量
- function countBet()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/bet_count') < 0) {
- $bet_count['count'] = "*****";
- } else {
- //串式投注
- $numstr = \App\Models\MoneyBuyStr::where('money_buy_str.status', '<>', 4)->join('account', 'money_buy_str.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type', '1')->whereBetween('money_time', $timearea)->count();
- //单式投注
- $numsimplex = \App\Models\MoneyBuySimplex::where('money_buy_simplex.status', '<>', 4)->join('account', 'money_buy_simplex.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type', '1')->whereBetween('money_buy_simplex.money_time', $timearea)->count();
- $bet_count['count'] = $numstr+$numsimplex;
- }
- if (\App\Models\Role::hasRoot('/enable/show/bet_money') < 0) {
- $bet_count['money_count'] = "*****";
- } else {
- //串式投注
- $str_bet_money = \App\Models\MoneyBuyStr::where('money_buy_str.status', '<>', 4)->join('account', 'money_buy_str.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type', '1')->whereBetween('money_time', $timearea)->sum('money');
- //单式投注
- $simplex_bet_money = \App\Models\MoneyBuySimplex::where('money_buy_simplex.status', '<>', 4)->join('account', 'money_buy_simplex.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type', '1')->whereBetween('money_time', $timearea)->sum('money');
- $bet_money = $str_bet_money+$simplex_bet_money;
- $bet_count['money_count'] = round($bet_money, 2);
- }
- // DB::connection()->enableQueryLog();
- if (\App\Models\Role::hasRoot('/enable/show/countBet') < 0) {
- $bet_count['user_count'] = "*****";
- } else {
- $db = new \App\Models\MoneyBuyStr;
- $db1 = new \App\Models\MoneyBuySimplex;
- //串式投注
- $str = $db->countUser($timearea);
- //单式投注
- $simplex = $db1->countUser($timearea);
- if($str && $simplex){
- for($i=0;$i<count($str);$i++){
- for($j=0;$j<count($simplex);$j++){
- if($str[$i]['account_identity'] == $simplex[$j]['account_identity']){
- unset($str[$i]);
- unset($simplex[$j]);
- }
- }
- }
- }
- $bet_count['user_count'] = count($str)+count($simplex);
- }
- // $queries = DB::getQueryLog();
- // print_r($queries);
- return $bet_count;
- }
- //今日提现
- function countTodayTake()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/count') < 0) {
- $take_count['count'] = "*****";
- } else {
- $take_count['count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/money_count') < 0) {
- $take_count['money_count'] = "*****";
- } else {
- $take_count['money_count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->sum('money');
- }
- // DB::connection()->enableQueryLog();
- if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
- $db = new \App\Models\Money_take;
- $take_count['user_count'] = "*****";
- } else {
- $db = new \App\Models\Money_take;
- $take_count['user_count'] = $db->countUser($timearea);
- }
- // $queries = DB::getQueryLog();
- // dump($queries);
- // dump($take_count);
- return $take_count;
- }
- //今日充值笔数
- function countTodayRecharge()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- // DB::connection()->enableQueryLog();
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge') < 0) {
- $rech_data['count'] = "*****";
- } else {
- $rech_data['count'] = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->count();
- }
- // $queries = DB::getQueryLog();
- // print_r($queries);
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_money') < 0) {
- $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
- $rech_data['money_count'] = "*****";
- } else {
- $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
- $rech_data['money_count'] = round($money_count, 2);
- }
- // DB::connection()->enableQueryLog();
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_user') < 0) {
- $db = new \App\Models\Money_details;
- $count = $db->countUser($timearea, array(6, 11));
- $rech_data['user_count'] = "*****";
- } else {
- $db = new \App\Models\Money_details;
- $count = $db->countUser($timearea, array(6, 11));
- $rech_data['user_count'] = $count;
- }
- // $queries = DB::getQueryLog();
- // dump($queries);
- return $rech_data;
- }
- // 今日回水笔数
- function countTodayReturn()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn') < 0) {
- $return['count'] = "*****";
- } else {
- $return['count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_money') < 0) {
- $return['money_count'] = "*****";
- } else {
- $return['money_count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->sum('money');
- }
- // $return['user_count'] = \App\Model\Money_return::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
- if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_user') < 0) {
- $db = new \App\Models\Money_return;
- $return['user_count'] = "*****";
- } else {
- $db = new \App\Models\Money_return;
- $return['user_count'] = $db->countUser($timearea);
- }
- return $return;
- }
- // 今日反水笔数
- function countTodayBack()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/countTodayBack') < 0) {
- $return['count'] = "*****";
- } else {
- $return['count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_money') < 0) {
- $return['money_count'] = "*****";
- } else {
- $return['money_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->sum('money');
- }
- if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_user') < 0) {
- $return['user_count'] = "*****";
- } else {
- $return['user_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
- }
- return $return;
- }
- //今日汇款
- function countTodayRimt()
- {
- $time1 = date('Y-m-d 00:00:00'); //今日0时
- $time2 = date('Y-m-d 23:59:59'); //
- $timearea = [$time1, $time2];
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt') < 0) {
- $rimit['count'] = "*****";
- } else {
- $rimit['count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->count();
- }
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_money') < 0) {
- $rimit['money_count'] = "*****";
- } else {
- $rimit['money_count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->sum('money');
- }
- if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_user') < 0) {
- $db = new \App\Models\Money_recharge;
- $rimit['user_count'] = "*****";
- } else {
- $db = new \App\Models\Money_recharge;
- $rimit['user_count'] = $db->countRimitUser($timearea);
- }
- return $rimit;
- }
- //公告信息
- function getNotice()
- {
- $db = new \App\Models\Article();
- $data = $db->getMsg(2, 2);
- return $data;
- }
- //当前在线用户饼状图
- function onlineUser()
- {
- // $db = new \App\Model\Logfile;
- // $db=new \App\Model\Account_Token;
- $db = new \App\Models\Account_detailed;
- $data_log = $db->getOnlineUser();
- // $data_log = $db->getUser();
- $array['data'] = $data_log;
- if (empty($data_log)) {
- $array['data'][0]['name'] = '没有';
- $array['data'][0]['value'] = 0;
- }
- //组装标
- $count = 0;
- foreach ($array['data'] as $k => $v) {
- $array['title'][$k] = trim($v['name']);
- $array['data'][$k]['name'] = trim($v['name']);
- $count += $v['value'];
- }
- //总在线数量、
- $array['text'] = date('Y-m-d') . trans('common.today_user_num') . $count;
- return responseToJson($array);
- // dump($array);
- }
- //今日投注统计饼状图
- function getBetUrl()
- {
- // $db = new \App\Models\OrderUrl;
- // $data = $db->getUrlBet();
- $count = $this->countBet();
- //$array['data'] = $data;
- if ($count['count'] == 0) {
- $array['data'][0]['name'] = '没有';
- $array['data'][0]['value'] = 0;
- }
- else{
- $array['data'][0]['name'] = '今日注单数量';
- $array['data'][0]['value'] = $count['count'];
- }
- //组装标
- foreach ($array['data'] as $k => $v) {
- $array['title'][$k] = $v['name'];
- }
- //添加标题
- //总投注数量
- $count = $this->countBet();
- $count = $count['count'];
- $array['text'] = date('Y-m-d') . trans('common.today_bet_num') . $count;
- // dump($array);
- return responseToJson($array);
- }
- //时间区
- function getTime()
- {
- $time = array(
- 'addrss' => date_default_timezone_get(),
- 'time' => date("Y-m-d H:i:s", time() + 3600 * 8),
- );
- // print_r($time['time']);die;
- return responseToJson($time);
- }
- //最近7天会员注册情况
- function regUser()
- {
- /*
- $time2 = date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 30);
- $time1 = date('Y-m-d H:i:s', time());
- $timearea = [$time2, $time1];
- $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();
- $rimit = \App\Models\Account_list::where('account_status', 1)
- ->select(DB::Raw('date(register_time) as name, count(identity) as value'))
- ->whereBetween('register_time', $timearea)->orderBy(DB::Raw('date(register_time)'))->groupBy(DB::Raw('date(register_time)'))->get();
- $data = $rimit->toArray();
- */
- //统计七天内注册用户数量按天进行分组
- $start_time = date('Y-m-d', strtotime('-7 days'));
- $end_time = date('Y-m-d', time());
- $user = DB::select('select rtime as name ,count(rtime) as value from (SELECT to_char( "register_time",\'YYYY-MM-DD\') as rtime FROM "account_detailed" where "register_time">=CURRENT_DATE-7) as tmp group by rtime order by name asc');
- if (!empty($user)) {
- $userData = [];
- foreach ($user as $k => $v) {
- $userData[$k]['name'] = $v->name;
- $userData[$k]['value'] = $v->value;
- }
- }
- //计算日期内天数
- $stimestamp = strtotime($start_time);
- $etimestamp = strtotime($end_time);
- //计算日期段内有多少天
- $days = ($etimestamp - $stimestamp) / 86400;
- //保存每天日期
- $date = array();
- for ($i = 1; $i <= $days; $i++) {
- $date[] = date('Y-m-d', $stimestamp + (86400 * $i));
- }
- //循环补全日期
- foreach ($date as $key => $val) {
- $data[$key] = [
- 'name' => $val,
- 'value' => 0
- ];
- foreach ($userData as $item => $value) {
- if ($val == $value['name']) {
- $data[$key] = $value;
- }
- }
- }
- foreach ($data as $k => $v) {
- $array['title'][$k] = $v['name'];
- $array['data']['num'][$k] = $v['value'];
- }
- $array['legend'][] = '最近7天注册用户记录';
- return responseToJson($array);
- }
- //最近7天财务情况
- function money()
- {
- $res_array = array();
- for ($i = 6; $i >= 0; $i--) {
- $secondes = $i * 24 * 60 * 60;
- $res_array['title'][] = date('Y-m-d', (time() - $secondes));
- $res_array['data']['money_with'][] = 0;
- $res_array['data']['money_recharge'][] = 0;
- $res_array['data']['money_remittance'][] = 0;
- $res_array['data']['money_trans'][] = 0;
- $res_array['data']['profit'][] = 0;
- }
- $res_array['legend']['money_with'] = trans('user.money_with');
- $res_array['legend']['money_recharge'] = trans('user.money_recharge');
- $res_array['legend']['money_remittance'] = trans('user.money_remittance');
- $res_array['legend']['money_trans'] = trans('user.money_trans');
- $res_array['legend']['profit'] = '盈利';
- $db = new \App\Models\Money_details;
- $data = $db->getBet();
- if ($data < 0) {
- return responseToJson($res_array);
- }
- $trade_type = $this->getTradetype();
- foreach ($data as $k => $v) {
- foreach ($res_array['title'] as $tk => $tv) {
- if ($v['date'] == $tv) {
- $res_array['data'][$trade_type[$v['trade_type']]][$tk] += $v['value'];
- $res_array['data'][$trade_type[1]][$tk] += ($v['trade_type'] == 5) ? -$v['value'] : +$v['value'];
- break;
- }
- }
- }
- return responseToJson($res_array);
- /*print_r($data);exit;
- $i = 0;
- $array['title']=array();
- foreach ($data as $k => $v) {
- if (is_array($v) && count($v) > 0) {
- foreach ($v as $ka => $va) {
- $array['title'][$i] = $va['date'];
- $temp[$k][$va['date']] = $va['value'];
- $i++;
- }
- } else {
- $temp[$k] = array();
- }
- $array['legend'][$k] = trans('user.' . $k);
- }
- $array['title']=array_unique($array['title']);
- asort($array['title']);
- $tem=array();
- foreach($array['title'] as $v){
- $tem[]=$v;
- }
- $array['title']=$tem;
- $te = array();
- foreach ($array['title'] as $k => $v) {
- if (array_key_exists($v, $temp['money_with'])) {
- $te['money_with'][] = $temp['money_with'][$v];
- $money_with=$temp['money_with'][$v];
- } else {
- $te['money_with'][] = 0;
- $money_with=0;
- }
- if (array_key_exists($v, $temp['money_recharge'])) {
- $te['money_recharge'][] = $temp['money_recharge'][$v];
- $money_recharge=$temp['money_recharge'][$v];
- } else {
- $te['money_recharge'][] = 0;
- $money_recharge=0;
- }
- if (array_key_exists($v, $temp['money_remittance'])) {
- $te['money_remittance'][] = $temp['money_remittance'][$v];
- $money_remittance=$temp['money_remittance'][$v];
- } else {
- $te['money_remittance'][] = 0;
- $money_remittance=0;
- }
- if (array_key_exists($v, $temp['money_trans'])) {
- $te['money_trans'][] = $temp['money_trans'][$v];
- $money_trans=$temp['money_trans'][$v];
- } else {
- $te['money_trans'][] = 0;
- $money_trans=0;
- }
- $te['profit'][]=$money_trans+$money_remittance+$money_recharge-$money_with;
- }
- $array['legend']['profit']='盈利';
- $array['data'] = $te;
- return responseToJson($array);*/
- }
- private function getTradetype()
- {
- $tradetype = array(
- '5' => 'money_with',
- '6' => 'money_recharge',
- '11' => 'money_trans',
- '14' => 'money_remittance',
- '1' => 'profit',
- );
- return $tradetype;
- }
- //每天每个游戏注单数
- function TodayGameNote()
- {
- $time1 = date('Y-m-d 00:00:00');//今日零时
- $time2 = date('Y-m-d 23:59:59');//今日末时
- // $time1='2017-09-14 00:00:00';
- // $time2='2017-09-14 23:59:59';
- $timearea = [$time1, $time2];
- $data = \App\Models\MoneyBuy::select('game_name as name', DB::Raw('count(id) as value'))->whereBetween('money_time', $timearea)->groupBy('game_name')->get();
- $data = $data->toArray();
- if (count($data) == 0) {
- $data = array(array('name' => 'no_bet', 'value' => 0));
- }
- $array = array();
- foreach ($data as $k => $v) {
- $data[$k]['name'] = trans('common.' . $v['name']);
- $array['title'][$k] = trans('common.' . $v['name']);
- }
- $array['data'] = $data;
- $array['text'] = '今日游戏注单数量:' . date('Y-m-d');
- return responseToJson($array);
- }
- //拉时间
- function pullTime()
- {
- //获取前台域名
- $setInfo = new \App\Models\Setinfo();
- $info = $setInfo->getInfo(18);
- if ($info < 0) {
- return responseToJson($info);
- }
- //$a=file_get_contents($info['infocontent'].'api-common/getTime');
- $url = $info['infocontent'] . 'api-common/getTime';
- $timeout = 30;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 2);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //避免data数据过长问题
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, array());
- $a = curl_exec($ch);
- curl_close($ch);
- echo $a;
- }
- //通知消息
- function Message()
- {
- $admin_id = session('adminInfo.admin_id');
- $db = new \App\Models\MessageRead;
- $dbs = new \App\Models\Manager;
- $where = [
- 'type',
- '4'
- ];
- $datas = $dbs->getlistd($where);
- $data = $db->getlist($admin_id);
- if (!empty($data)) {
- foreach ($datas as $k => $v) {
- foreach ($data as $val) {
- if ($v['id'] == $val['message_id']) {
- $datas[$k]['status'] = '1';
- }
- }
- }
- }
- return $datas;
- }
- //刷新缓存
- public function refresh()
- {
- return view('admin.refresh');
- }
- }
|