diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index 6ebe18b4b..b442ad320 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -890,5 +890,31 @@ public function auto_rrdae(){ } } + //根据时间统计玩家充值 + public function userPlayDataCount() + { + $time = strtotime(date('Y-m-d 00:00:00', time() - (3600 * 24))); + $spendMap['pay_status'] = 1; + $spendMap['pay_game_status'] = 1; + $spendMap['game_player_id'] = ['gt', 0]; + $spendMap['pay_time'] = ['between', [$time, strtotime(date('Y-m-d 23:59:59', $time))]]; + + $field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count'; + $spendCostData = M('spend', 'tab_')->field($field) + ->where($spendMap) + ->group('day,game_player_id,server_id,game_id') + ->select(); + $data = []; + foreach ($spendCostData as $list) { + $save['game_id'] = $list['game_id']; + $save['server_id'] = $list['server_id']; + $save['role_id'] = $list['game_player_id']; + $save['recharge_cost'] = $list['recharge_cost']; + $save['recharge_count'] = $list['recharge_count']; + $save['create_time'] = strtotime($list['day']); + $data[] = $save; + } + M('user_play_data_count', 'tab_')->addAll($data); + } } diff --git a/Application/Admin/Controller/AutoPackController.class.php b/Application/Admin/Controller/AutoPackController.class.php index 48f286288..e4a6b4bb1 100644 --- a/Application/Admin/Controller/AutoPackController.class.php +++ b/Application/Admin/Controller/AutoPackController.class.php @@ -297,17 +297,17 @@ class AutoPackController extends Think $map = []; $map['status'] = 1; $map['enable_status'] = ['in', '0,2']; - + $applys = M('apply', 'tab_')->field('id,game_id,game_name,promote_id,promote_account,sdk_version') ->where($map) ->order('bale_sort desc,id desc') ->limit(200) ->select(); - + if (count($applys) == 0) { Printer::export('无等待队列', true); } - + $applyIds = array_column($applys, 'id'); M('apply', 'tab_')->where(['id' => ['in', $applyIds]])->save(['enable_status' => 3]); @@ -353,7 +353,7 @@ class AutoPackController extends Think ->field('a.id,a.game_id,a.game_name,a.promote_account,a.pack_url,a.plist_url,a.promote_id,a.sdk_version,a.enable_status') ->join('tab_apply_launch as al on (al.apply_id=a.id) ') ->where($map) - ->limit(300) + ->limit(300) ->group('a.id') ->select(); foreach ($apply as $key => $value) { @@ -367,7 +367,7 @@ class AutoPackController extends Think $launchmodel -> where(['apply_id' => $value['id']]) -> setField('launch_packge', 0); continue; } - + if (!empty($gameSourceUrl) && is_file($gameSourceUrl)) { $launch = $launchmodel -> where(['apply_id' => $value['id'], 'launch_packge' => array('in', [0, 2, 3])]) -> select(); @@ -1054,6 +1054,4 @@ class AutoPackController extends Think return ''; } } - - } diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 0e1010b0f..dcf6f6503 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -126,4 +126,53 @@ class ConsoleController extends Think { } } } + + public function deleteRepeatUserPlayInfo() + { + // $gameId = 157; + // $gameId = 155; + $gameId = 153; + $sql = 'select id from tab_user_play_info a left join ( + select role_id, server_id, game_id, count(1) from tab_user_play_info where server_id="' . $serverId . '" and game_id = ' . $gameId . ' GROUP BY role_id, server_id, game_id, server_name having count(1) > 1 + ) b on a.role_id=b.role_id where a.server_id=b.server_id and a.game_id=b.game_id and a.server_id="' . $serverId . '" and a.game_id = ' . $gameId . ' order by a.role_id, a.server_id, a.game_id'; + $model = new \Think\Model(); + + $servers = M('server', 'tab_')->field('server_id')->where(['game_id' => $gameId])->group('server_id')->select(); + foreach ($servers as $server) { + $serverId = $server['server_id']; + $sql = 'select a.id, a.role_id, a.server_id, a.game_id, a.role_level from tab_user_play_info a left join ( + select role_id, server_id, game_id, count(1) from tab_user_play_info where server_id="' . $serverId . '" and game_id = ' . $gameId . ' GROUP BY role_id, server_id, game_id, server_name having count(1) > 1 + ) b on a.role_id=b.role_id where a.server_id=b.server_id and a.game_id=b.game_id and a.server_id="' . $serverId . '" and a.game_id = ' . $gameId . ' order by a.role_id, a.server_id, a.game_id'; + // var_dump($sql); + + $result = $model->query($sql); + $uniqueRole = null; + $items = []; + foreach ($result as $item) { + $items[$item['role_id']][] = $item; + } + + $maxRoleIds = []; + $repeatIds = []; + foreach ($items as $roles) { + $maxRole = null; + foreach ($roles as $role) { + if ($maxRole == null) { + $maxRole = $role; + } elseif ($role['role_level'] > $maxRole['role_level']) { + $repeatIds[] = $maxRole['id']; + $maxRole = $role; + } else { + $repeatIds[] = $role['id']; + } + } + $maxRoleIds[] = $maxRole['id']; + } + if (count($repeatIds) > 0) { + M('user_play_info', 'tab_')->where(['id' => ['in', $repeatIds], 'game_id' => $gameId, 'server_id' => $serverId])->delete(); + echo M()->getLastSql(); + echo PHP_EOL; + } + } + } } diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 9333d2a96..965da8b24 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -417,7 +417,133 @@ class PlatformController extends ThinkController $this->assign('total', $total); $this->display(); } + //TODO: function promotepay_statistics($p = 0) + { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $arraypage = $page; + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + $map1['promote_id'] = $map['promote_id'] = array('egt', 0); + $spend = M('Spend', 'tab_'); + if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; + $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " "; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + $pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + unset($_REQUEST['timeend']); + } else { + $pay_time = " between 0 and " . time(); + } + $map1['pay_status'] = $map['pay_status'] = 1; + $today = total(1); + $week = total(2); + $mounth = total(3); + unset( $map['create_time']); + + //获取所有会长 + $promote_map = "`chain` = '/'"; + if (isset($_REQUEST['promote_id'])) { + $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; + } + + $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->select(); + $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->find()['acount']; + + // var_dump( $promote); + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + $dbdata['promote_id'] = $promote[$i]['id']; + } else { + $dbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + $dbdata['promote_id'] = $promote[$i]['id']; + } + $data[] = $dbdata; + } + $count = count($data); + foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; + static $i = 0; + $i++; + $data[$key]['rand'] = $i; + $data[$key]['count'] = $value['count'] / 100; + $data[$key]['today'] = $value['today'] / 100; + $data[$key]['week'] = $value['week'] / 100; + $data[$key]['mounth'] = $value['mounth'] / 100; + } + + $total = $this->data_total($data); + $this->assign('total', $total); + if ($_REQUEST['data_order'] != '') { + $data_order = reset(explode(',', $_REQUEST['data_order'])); + $data_order_type = end(explode(',', $_REQUEST['data_order'])); + $this->assign('userarpu_order', $data_order); + $this->assign('userarpu_order_type', $data_order_type); + } + + $page = set_pagination($pcount, $row); + if ($page) { + $this->assign('_page', $page); + } + + $data = my_sort($data, $data_order_type, (int)$data_order); + + $size = $row;//每页显示的记录数 + $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 + $this->meta_title = '渠道充值统计列表'; + $this->assign('list_data', $data); + $this->display(); + + } + function promotepay_statistics_1($p = 0) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 @@ -504,10 +630,9 @@ class PlatformController extends ThinkController unset($_REQUEST['promote_id']); } $data = $spend->field('t.pid as promote_id,t.promote_account,sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp1.id = tp2.id where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid") + ->join("inner JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid") ->where($condition)->table('(' . $data . ') as a')->group('t.pid')->order('count desc,a.ordertime')->select(); $count = count($data); - foreach ($data as $key => $value) { static $i = 0; $i++; diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 945cc790f..ade87c965 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -100,6 +100,7 @@ class SpendController extends ThinkController $map = '1 = 2'; $map1 = $map; } + echo (D(self::model_name)->where($map1)->fetchSql(true)->sum('pay_amount')); $total = null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); $ttotal = null_to_0(D(self::model_name)->where('pay_time' . total(1))->where(array('pay_status' => 1))->sum('pay_amount')); $ytotal = null_to_0(D(self::model_name)->where('pay_time' . total(5))->where(array('pay_status' => 1))->sum('pay_amount')); diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index 14fac80d8..8c95a0240 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -8,6 +8,7 @@ // +---------------------------------------------------------------------- namespace Admin\Controller; + use User\Api\UserApi; use Com\Wechat; use Com\WechatAuth; @@ -16,32 +17,34 @@ use Com\WechatAuth; * 后台用户控制器 * @author 麦当苗儿 */ -class UserController extends AdminController { +class UserController extends AdminController +{ /** * 用户管理首页 * @author 麦当苗儿 */ - public function index(){ - $nickname = I('nickname'); - if(isset($_REQUEST['status'])){ - $map['status'] = $_REQUEST['status']; - } - if(is_numeric($nickname)){ - $map['uid|nickname']= array(intval($nickname),array('like','%'.$nickname.'%'),'_multi'=>true); - }else{ - $map['nickname'] = array('like', '%'.(string)$nickname.'%'); - } - - $list = $this->lists('Member', $map); + public function index() + { + $nickname = I('nickname'); + if (isset($_REQUEST['status'])) { + $map['status'] = $_REQUEST['status']; + } + if (is_numeric($nickname)) { + $map['uid|nickname'] = array(intval($nickname), array('like', '%' . $nickname . '%'), '_multi' => true); + } else { + $map['nickname'] = array('like', '%' . (string)$nickname . '%'); + } + + $list = $this->lists('Member', $map); int_to_string($list); $this->assign('_list', $list); $this->meta_title = '管理员列表'; - - $this->m_title = '管理员列表'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'User/index','status'=>1])->find()); - + + $this->m_title = '管理员列表'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find()); + $this->display(); } @@ -49,7 +52,8 @@ class UserController extends AdminController { * 修改昵称初始化 * @author huajie */ - public function updateNickname(){ + public function updateNickname() + { $nickname = M('Member')->getFieldByUid(UID, 'nickname'); $this->assign('nickname', $nickname); $this->meta_title = '修改昵称'; @@ -60,7 +64,8 @@ class UserController extends AdminController { * 修改昵称提交 * @author huajie */ - public function submitNickname(){ + public function submitNickname() + { //获取参数 $nickname = I('post.nickname'); $password = I('post.password'); @@ -68,25 +73,25 @@ class UserController extends AdminController { empty($password) && $this->error('请输入密码'); //密码验证 - $User = new UserApi(); - $uid = $User->login(UID, $password, 4); + $User = new UserApi(); + $uid = $User->login(UID, $password, 4); ($uid == -2) && $this->error('密码不正确'); - $Member = D('Member'); - $data = $Member->create(array('nickname'=>$nickname)); - if(!$data){ + $Member = D('Member'); + $data = $Member->create(array('nickname' => $nickname)); + if (!$data) { $this->error($Member->getError()); } - $res = $Member->where(array('uid'=>$uid))->save($data); + $res = $Member->where(array('uid' => $uid))->save($data); - if($res){ - $user = session('user_auth'); - $user['username'] = $data['nickname']; + if ($res) { + $user = session('user_auth'); + $user['username'] = $data['nickname']; session('user_auth', $user); session('user_auth_sign', data_auth_sign($user)); $this->success('修改昵称成功!'); - }else{ + } else { $this->error('修改昵称失败!'); } } @@ -95,7 +100,8 @@ class UserController extends AdminController { * 修改密码初始化 * @author huajie */ - public function updatePassword(){ + public function updatePassword() + { $this->meta_title = '修改密码'; $this->display('updatepassword'); } @@ -104,24 +110,25 @@ class UserController extends AdminController { * 修改密码提交 * @author huajie */ - public function submitPassword(){ + public function submitPassword() + { //获取参数 - $password = I('post.old'); + $password = I('post.old'); empty($password) && $this->error('请输入原密码'); $data['password'] = I('post.password'); empty($data['password']) && $this->error('请输入新密码'); $repassword = I('post.repassword'); empty($repassword) && $this->error('请输入确认密码'); - if($data['password'] !== $repassword){ + if ($data['password'] !== $repassword) { $this->error('您输入的新密码与确认密码不一致'); } - $Api = new UserApi(); - $res = $Api->updateInfo(UID, $password, $data); - if($res['status']){ + $Api = new UserApi(); + $res = $Api->updateInfo(UID, $password, $data); + if ($res['status']) { $this->success('修改密码成功!'); - }else{ + } else { $this->error($res['info']); } } @@ -130,13 +137,14 @@ class UserController extends AdminController { * 用户行为列表 * @author huajie */ - public function action(){ + public function action() + { //获取列表数据 - $Action = M('Action')->where(array('status'=>array('gt',-1))); - $list = $this->lists($Action); + $Action = M('Action')->where(array('status' => array('gt', -1))); + $list = $this->lists($Action); int_to_string($list); // 记录当前列表页的cookie - Cookie('__forward__',$_SERVER['REQUEST_URI']); + Cookie('__forward__', $_SERVER['REQUEST_URI']); $this->assign('_list', $list); $this->meta_title = '用户行为'; @@ -147,9 +155,10 @@ class UserController extends AdminController { * 新增行为 * @author huajie */ - public function addAction(){ + public function addAction() + { $this->meta_title = '新增行为'; - $this->assign('data',null); + $this->assign('data', null); $this->display('editaction'); } @@ -157,12 +166,13 @@ class UserController extends AdminController { * 编辑行为 * @author huajie */ - public function editAction(){ + public function editAction() + { $id = I('get.id'); empty($id) && $this->error('参数不能为空!'); $data = M('Action')->field(true)->find($id); - $this->assign('data',$data); + $this->assign('data', $data); $this->meta_title = '编辑行为'; $this->display('editaction'); } @@ -171,12 +181,13 @@ class UserController extends AdminController { * 更新行为 * @author huajie */ - public function saveAction(){ + public function saveAction() + { $res = D('Action')->update(); - if(!$res){ + if (!$res) { $this->error(D('Action')->getError()); - }else{ - $this->success($res['id']?'更新成功!':'新增成功!', Cookie('__forward__')); + } else { + $this->success($res['id'] ? '更新成功!' : '新增成功!', Cookie('__forward__')); } } @@ -184,23 +195,24 @@ class UserController extends AdminController { * 会员状态修改 * @author 朱亚杰 */ - public function changeUserStatus($method=null){ - $id = array_unique((array)I('id',0)); - if( in_array(C('USER_ADMINISTRATOR'), $id)){ + public function changeUserStatus($method = null) + { + $id = array_unique((array)I('id', 0)); + if (in_array(C('USER_ADMINISTRATOR'), $id)) { $this->error("不允许对超级管理员执行该操作!"); } - $id = is_array($id) ? implode(',',$id) : $id; - if ( empty($id) ) { + $id = is_array($id) ? implode(',', $id) : $id; + if (empty($id)) { $this->error('请选择要操作的数据!'); } - $map['uid'] = array('in',$id); - $map1['id'] = array('in',$id); - $status=I('method')=='forbidUser'?0:1; - $res= M('UcenterMember')->where($map1)->setField('status',$status); - $res1= M('Member')->where($map)->setField('status',$status); - if($res&&$res1){ + $map['uid'] = array('in', $id); + $map1['id'] = array('in', $id); + $status = I('method') == 'forbidUser' ? 0 : 1; + $res = M('UcenterMember')->where($map1)->setField('status', $status); + $res1 = M('Member')->where($map)->setField('status', $status); + if ($res && $res1) { $this->success('更新成功!'); - }else{ + } else { $this->error('更新失败!'); } @@ -211,43 +223,45 @@ class UserController extends AdminController { * 会员状态修改 * @author 朱亚杰 */ - public function changeStatus($method=null){ - $id = array_unique((array)I('id',0)); - if( in_array(C('USER_ADMINISTRATOR'), $id)){ + public function changeStatus($method = null) + { + $id = array_unique((array)I('id', 0)); + if (in_array(C('USER_ADMINISTRATOR'), $id)) { $this->error("不允许对超级管理员执行该操作!"); } - $id = is_array($id) ? implode(',',$id) : $id; - if ( empty($id) ) { + $id = is_array($id) ? implode(',', $id) : $id; + if (empty($id)) { $this->error('请选择要操作的数据!'); } - $map['uid'] = array('in',$id); - switch ( strtolower($method) ){ + $map['uid'] = array('in', $id); + switch (strtolower($method)) { case 'forbiduser': - \Think\Log::actionLog('User/changeStatus?method=forbidUser','user',1); - $this->forbid('Member', $map ); + \Think\Log::actionLog('User/changeStatus?method=forbidUser', 'user', 1); + $this->forbid('Member', $map); break; case 'resumeuser': - \Think\Log::actionLog('User/changeStatus?method=resumeuser','user',1); - $this->resume('Member', $map ); + \Think\Log::actionLog('User/changeStatus?method=resumeuser', 'user', 1); + $this->resume('Member', $map); break; case 'deleteuser': - \Think\Log::actionLog('User/changeStatus?method=deleteuser','user',1); - $this->delete('Member', $map ); + \Think\Log::actionLog('User/changeStatus?method=deleteuser', 'user', 1); + $this->delete('Member', $map); break; default: $this->error('参数非法'); } } - public function add($username = '', $password = '', $repassword = '', $email = '',$second_pwd=''){ + public function add($username = '', $password = '', $repassword = '', $email = '', $second_pwd = '') + { - if(IS_POST){ + if (IS_POST) { /*检测用户名是否为空*/ - if (empty($username)){ + if (empty($username)) { $this->error('管理员账号不能为空!'); } /* 检测密码 */ - if($password != $repassword){ + if ($password != $repassword) { $this->error('管理员密码和确认密码不一致!'); } $usernameUser = M('UcenterMember', 'sys_')->field('username')->where(['username' => $username])->find(); @@ -259,84 +273,87 @@ class UserController extends AdminController { $this->error('邮箱已存在!'); } /* 调用注册接口注册用户 */ - $User = new UserApi; - $uid = $User->register($username, $password, $email,$second_pwd); - if(0 < $uid){ //注册成功 + $User = new UserApi; + $uid = $User->register($username, $password, $email, $second_pwd); + if (0 < $uid) { //注册成功 $user = array('uid' => $uid, 'nickname' => $username, 'status' => 1); $data['uid'] = $uid; $data['group_id'] = I('auth'); M('auth_group_access')->data($data)->add(); - if(!M('Member')->add($user)){ + if (!M('Member')->add($user)) { $this->error('用户添加失败!'); } else { - \Think\Log::actionLog('User/add','Member',$uid); - $this->success('用户添加成功!',U('index')); + \Think\Log::actionLog('User/add', 'Member', $uid); + $this->success('用户添加成功!', U('index')); } } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { - $list=D('AuthGroup')->where(array('status'=>1))->select(); - $this->assign('lists',$list); + $list = D('AuthGroup')->where(array('status' => 1))->select(); + $this->assign('lists', $list); $this->meta_title = '新增管理员'; - - - $this->m_title = '管理员列表'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'User/index','status'=>1])->find()); - - + + $this->m_title = '管理员列表'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find()); + + $this->display(); } } -/** - * 系统非常规MD5加密方法 - * @param string $str 要加密的字符串 - * @return string - */ -function think_ucenter_md5($str, $key = 'ThinkUCenter'){ - return '' === $str ? '' : md5(sha1($str) . $key); -} - public function edit($id){ + + /** + * 系统非常规MD5加密方法 + * @param string $str 要加密的字符串 + * @return string + */ + function think_ucenter_md5($str, $key = 'ThinkUCenter') + { + return '' === $str ? '' : md5(sha1($str) . $key); + } + + public function edit($id) + { // var_dump(session());exit; - if(IS_POST){ - if(isset($_POST['bind_wx'])){ - if($_POST['bind_wx']=='unbind_wx'){ - $info['admin_openid']=''; - }else{ - $info['admin_openid']=session('admin_openid'); - if($info['admin_openid']==''){ + if (IS_POST) { + if (isset($_POST['bind_wx'])) { + if ($_POST['bind_wx'] == 'unbind_wx') { + $info['admin_openid'] = ''; + } else { + $info['admin_openid'] = session('admin_openid'); + if ($info['admin_openid'] == '') { $this->error('请在30分钟内扫描并关注微信公众号!'); } } } - if($_POST['auth']==''&&$id!=1){ + if ($_POST['auth'] == '' && $id != 1) { $this->error('请选择用户权限!'); } - if($_POST['password']==''){ + if ($_POST['password'] == '') { //$this->error('请填写管理员密码!'); } - if(!empty($_POST['password']) && (strlen($_POST['password'])<6 || strlen($_POST['password']) > 30)){ + if (!empty($_POST['password']) && (strlen($_POST['password']) < 6 || strlen($_POST['password']) > 30)) { $this->error('管理员密码长度必须在6-30个字符之间!'); } - if($_POST['second_pwd']==''){ + if ($_POST['second_pwd'] == '') { //$this->error('请填写二级密码!'); } - if(!empty($_POST['second_pwd']) && (strlen($_POST['second_pwd'])<6 || strlen($_POST['second_pwd']) > 30)){ + if (!empty($_POST['second_pwd']) && (strlen($_POST['second_pwd']) < 6 || strlen($_POST['second_pwd']) > 30)) { $this->error('二级密码长度必须在6-30个字符之间!'); } - if($_POST['email']==''){ + if ($_POST['email'] == '') { $this->error('请填写邮箱!'); } - - $pattern = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i"; - - if(!preg_match( $pattern, $_POST['email'])) { - $this->error('邮箱格式不正确!'); - } - if(isset($_POST['mobile'])&&$_POST['mobile']!=''){ + + $pattern = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i"; + + if (!preg_match($pattern, $_POST['email'])) { + $this->error('邮箱格式不正确!'); + } + if (isset($_POST['mobile']) && $_POST['mobile'] != '') { $dx = A('Phone'); - $res = $dx->check_tel_code($_POST['mobile'],$_POST['code']); + $res = $dx->check_tel_code($_POST['mobile'], $_POST['code']); switch ($res) { case '-1': $this->error('短信验证码无效,请重新获取'); @@ -349,27 +366,27 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ break; } } - $Member=D('UcenterMember'); - $mem=D('Member'); - $au=D('AuthGroupAccess'); - $map['id']=$id; - $maps['uid']=$id; - $info['username']=$_POST['username']; - $in['nickname']=$_POST['username']; - $pwd=$this->think_ucenter_md5($_POST['password'],UC_AUTH_KEY); - $spwd=$this->think_ucenter_md5($_POST['second_pwd'],UC_AUTH_KEY); - $rpwd=$Member->where(array('id'=>$id))->find(); - $oldpwd=$rpwd['password']; - $oldspwd=$rpwd['second_pwd']; + $Member = D('UcenterMember'); + $mem = D('Member'); + $au = D('AuthGroupAccess'); + $map['id'] = $id; + $maps['uid'] = $id; + $info['username'] = $_POST['username']; + $in['nickname'] = $_POST['username']; + $pwd = $this->think_ucenter_md5($_POST['password'], UC_AUTH_KEY); + $spwd = $this->think_ucenter_md5($_POST['second_pwd'], UC_AUTH_KEY); + $rpwd = $Member->where(array('id' => $id))->find(); + $oldpwd = $rpwd['password']; + $oldspwd = $rpwd['second_pwd']; $User = new UserApi; - $info['password']= (empty($pwd) || $pwd==$oldpwd)?$oldpwd:$pwd; - $info['second_pwd']= (empty($spwd) || $spwd==$oldspwd)?$oldspwd:$spwd; - $info['email']=$_POST['email']; - $info['mobile']=isset($_POST['mobile'])?$_POST['mobile']:''; - $ss['group_id']=$_POST['auth']; - $ss['houtai']=$_POST['houtai']; - $smember=$Member->where($map)->save($info); - $meb=$mem->where($maps)->save($in); + $info['password'] = (empty($pwd) || $pwd == $oldpwd) ? $oldpwd : $pwd; + $info['second_pwd'] = (empty($spwd) || $spwd == $oldspwd) ? $oldspwd : $spwd; + $info['email'] = $_POST['email']; + $info['mobile'] = isset($_POST['mobile']) ? $_POST['mobile'] : ''; + $ss['group_id'] = $_POST['auth']; + $ss['houtai'] = $_POST['houtai']; + $smember = $Member->where($map)->save($info); + $meb = $mem->where($maps)->save($in); if ($au->where(array('uid' => $id))->find()) { if ($ss['group_id'] == '') { unset($ss['group_id']); @@ -379,178 +396,223 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ $ss['uid'] = $id; $ag = $au->add($ss); } - - if($smember !== false||$meb||$ag){ - M('user_pwd')->where($maps)->setField('password',think_encrypt($info['password'])); - $this->success('修改成功!',U('User/index')); - }else{ - $this->error('修改失败!',U('User/index')); + + if ($smember !== false || $meb || $ag) { + M('user_pwd')->where($maps)->setField('password', think_encrypt($info['password'])); + $this->success('修改成功!', U('User/index')); + } else { + $this->error('修改失败!', U('User/index')); } - }else{ - $map['id']=$_GET['id']; - $Member=D('UcenterMember')->where($map)->find(); - $au=D('AuthGroupAccess')->where(array('uid'=>$_GET['id']))->find(); - $this->assign("authid",$au["group_id"]); - $this->assign("houtai",$au["houtai"]); - $list=D('AuthGroup')->where(array('status'=>1))->select(); - $username=$_POST['username']; - $password=$_POST['password']; - $this->assign('lists',$list); - $this->assign('list',$Member); - $this->assign('sd',$group); - $this->meta_title = '编辑管理员'; - - $this->m_title = '管理员列表'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'User/index','status'=>1])->find()); - - + } else { + $map['id'] = $_GET['id']; + $Member = D('UcenterMember')->where($map)->find(); + $au = D('AuthGroupAccess')->where(array('uid' => $_GET['id']))->find(); + $this->assign("authid", $au["group_id"]); + $this->assign("houtai", $au["houtai"]); + $list = D('AuthGroup')->where(array('status' => 1))->select(); + $username = $_POST['username']; + $password = $_POST['password']; + $this->assign('lists', $list); + $this->assign('list', $Member); + $this->assign('sd', $group); + $this->meta_title = '编辑管理员'; + + $this->m_title = '管理员列表'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find()); + + $this->display(); } } - public function bdwx(){ - $map['id']=UID; - $Member=D('UcenterMember')->field('id,username,admin_openid,openid_sign')->where($map)->find(); - $this->assign('id',$map['id']); - $this->assign('list',$Member); + + public function bdwx() + { + $map['id'] = UID; + $Member = D('UcenterMember')->field('id,username,admin_openid,openid_sign')->where($map)->find(); + $this->assign('id', $map['id']); + $this->assign('list', $Member); $this->meta_title = '绑定微信'; $this->display(); } - public function updatelist($p=0){ + + public function updatelist($p = 0) + { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 - if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} - if(isset($_REQUEST['op_account'])){ - if ($_REQUEST['op_account']=='全部') { + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + if (isset($_REQUEST['op_account'])) { + if ($_REQUEST['op_account'] == '全部') { unset($_REQUEST['op_account']); - }else{ - $map['op_account'] = trim($_REQUEST['op_account']); + } else { + $map['op_account'] = trim($_REQUEST['op_account']); unset($_REQUEST['op_account']); } } - if(isset($_REQUEST['game_name'])){ - $map['game_name'] = trim($_REQUEST['game_name']); + if (isset($_REQUEST['game_name'])) { + $map['game_name'] = trim($_REQUEST['game_name']); unset($_REQUEST['game_name']); } - if(isset($_REQUEST['account'])){ - $map['user_account'] = array('like','%'.trim($_REQUEST['account']).'%'); + if (isset($_REQUEST['account'])) { + $map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%'); unset($_REQUEST['account']); } - if(isset($_REQUEST['huobi'])){ - $map['type'] = $_REQUEST['huobi']; + if (isset($_REQUEST['huobi'])) { + $map['type'] = $_REQUEST['huobi']; unset($_REQUEST['huobi']); } - if(isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])){ - $map['create_time'] = array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1)); - unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); - }elseif(isset($_REQUEST['timestart'])){ - $map['create_time'] = ['GT',strtotime(I('timestart'))]; + if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { + $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1)); unset($_REQUEST['timestart']); - }elseif(isset($_REQUEST['timeend'])){ - $map['create_time'] = ['LT',strtotime(I('timeend'))+86399]; + unset($_REQUEST['timeend']); + } elseif (isset($_REQUEST['timestart'])) { + $map['create_time'] = ['GT', strtotime(I('timestart'))]; + unset($_REQUEST['timestart']); + } elseif (isset($_REQUEST['timeend'])) { + $map['create_time'] = ['LT', strtotime(I('timeend')) + 86399]; unset($_REQUEST['timeend']); } - $list=M('balance_edit','tab_') + $list = M('balance_edit', 'tab_') ->where($map) ->order('create_time desc') ->page($page, $row) ->select(); - $count = M('balance_edit','tab_')->where($map)->count(); + $count = M('balance_edit', 'tab_')->where($map)->count(); //分页 - $page = set_pagination($count,$row); - if($page) {$this->assign('_page', $page);} - - $this->assign('list',$list); + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + + $this->assign('list', $list); $this->meta_title = '修改记录'; - - $this->m_title = '账户修改记录'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Member/login_record','status'=>1])->find()); - - + + $this->m_title = '账户修改记录'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Member/login_record', 'status' => 1])->find()); + + $this->display('updatelist'); } + /** * 获取用户注册错误信息 - * @param integer $code 错误编码 + * @param integer $code 错误编码 * @return string 错误信息 */ - private function showRegError($code = 0){ + private function showRegError($code = 0) + { switch ($code) { - case -1: $error = '管理员账号长度必须在16个字符以内!'; break; - case -2: $error = '管理员账号被禁止注册!'; break; - case -3: $error = '管理员账号被占用!'; break; - case -4: $error = '管理员密码长度必须在6-30个字符之间!'; break; - case -5: $error = '邮箱格式不正确!'; break; - case -6: $error = '邮箱长度必须在1-32个字符之间!'; break; - case -7: $error = '邮箱被禁止注册!'; break; - case -8: $error = '邮箱被占用!'; break; - case -9: $error = '手机格式不正确!'; break; - case -10: $error = '手机被禁止注册!'; break; - case -11: $error = '手机号被占用!'; break; - case -12: $error = '二级密码长度必须在6-30个字符之间!';break; - default: $error = '未知错误'; + case -1: + $error = '管理员账号长度必须在16个字符以内!'; + break; + case -2: + $error = '管理员账号被禁止注册!'; + break; + case -3: + $error = '管理员账号被占用!'; + break; + case -4: + $error = '管理员密码长度必须在6-30个字符之间!'; + break; + case -5: + $error = '邮箱格式不正确!'; + break; + case -6: + $error = '邮箱长度必须在1-32个字符之间!'; + break; + case -7: + $error = '邮箱被禁止注册!'; + break; + case -8: + $error = '邮箱被占用!'; + break; + case -9: + $error = '手机格式不正确!'; + break; + case -10: + $error = '手机被禁止注册!'; + break; + case -11: + $error = '手机号被占用!'; + break; + case -12: + $error = '二级密码长度必须在6-30个字符之间!'; + break; + default: + $error = '未知错误'; } return $error; } - public function get_openid(){ + + public function get_openid() + { $User = new UserApi; - if($_POST['id']>999){ - $this->ajaxReturn(array('status'=>0,'msg'=>'管理员id不能大于999')); + if ($_POST['id'] > 999) { + $this->ajaxReturn(array('status' => 0, 'msg' => '管理员id不能大于999')); } $data = $User->verifyPwd($_POST['id'], $_POST['pwd']); - if(!$data){ - $this->ajaxReturn(array('status'=>0,'msg'=>'密码错误,请重新选择')); + if (!$data) { + $this->ajaxReturn(array('status' => 0, 'msg' => '密码错误,请重新选择')); } - $appid = C('wechat.appid'); + $appid = C('wechat.appid'); $appsecret = C('wechat.appsecret'); - $result=auto_get_access_token(dirname(__FILE__).'/access_token_validity.txt'); - if($result['is_validity']){ - session('token',$result['access_token']); - $auth = new WechatAuth($appid, $appsecret,$result['access_token']); - }else{ - $auth = new WechatAuth($appid, $appsecret); + $result = auto_get_access_token(dirname(__FILE__) . '/access_token_validity.txt'); + if ($result['is_validity']) { + session('token', $result['access_token']); + $auth = new WechatAuth($appid, $appsecret, $result['access_token']); + } else { + $auth = new WechatAuth($appid, $appsecret); $token = $auth->getAccessToken(); - $token['expires_in_validity']=time()+$token['expires_in']; - wite_text(json_encode($token),dirname(__FILE__).'/access_token_validity.txt'); - session('token',$token['access_token']); + $token['expires_in_validity'] = time() + $token['expires_in']; + wite_text(json_encode($token), dirname(__FILE__) . '/access_token_validity.txt'); + session('token', $token['access_token']); } - $times=date('s',time()); + $times = date('s', time()); // $scene_id=strrev($_POST['id'].$times); - $scene_id=$_POST['id'].$times.$_POST['type']; - session('scene_id',$scene_id); - $ticket = $auth->qrcodeCreate($scene_id,600);//10分钟 - if($ticket==''){ - $return=array('status'=>0,'data'=>'获取ticket失败!'); + $scene_id = $_POST['id'] . $times . $_POST['type']; + session('scene_id', $scene_id); + $ticket = $auth->qrcodeCreate($scene_id, 600);//10分钟 + if ($ticket == '') { + $return = array('status' => 0, 'data' => '获取ticket失败!'); } $qrcode = $auth->showqrcode($ticket['ticket']); - $return=array('status'=>1,'data'=>$qrcode); + $return = array('status' => 1, 'data' => $qrcode); $this->ajaxReturn($return); } - function checkpwd(){ + + function checkpwd() + { $User = new UserApi; $data = $User->verifyPwd($_POST['id'], $_POST['pwd']); - $this->ajaxReturn(array('data'=>$data)); + $this->ajaxReturn(array('data' => $data)); } - function checkOpenidpic(){ + + function checkOpenidpic() + { sleep(2); - $data=M('ucenter_member')->where(array('id'=>$_REQUEST['id']))->find(); - if($data['openid_sign']==session('scene_id')){ - $this->ajaxReturn(array("status"=>1)); - }else{ - $this->ajaxReturn(array("status"=>0)); + $data = M('ucenter_member')->where(array('id' => $_REQUEST['id']))->find(); + if ($data['openid_sign'] == session('scene_id')) { + $this->ajaxReturn(array("status" => 1)); + } else { + $this->ajaxReturn(array("status" => 0)); } } - public function delete($id){ + public function delete($id) + { M()->startTrans(); $res1 = M('member')->delete($id); $res2 = M('ucenter_member')->delete($id); - $res3 = M('auth_group_access')->where(array('uid'=>$id))->delete(); - if($res1 && $res2 && $res3){ + $res3 = M('auth_group_access')->where(array('uid' => $id))->delete(); + if ($res1 && $res2 && $res3) { M()->commit(); $this->success('删除成功'); - }else{ + } else { M()->rollback(); - $this->error('删除失败'.M()->getError()); + $this->error('删除失败' . M()->getError()); } } @@ -558,7 +620,7 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ { $map = []; if (isset($_REQUEST['game_name'])) { - $map['game_name'] = ['like', trim($_REQUEST['game_name'])."%"]; + $map['game_name'] = ['like', trim($_REQUEST['game_name']) . "%"]; unset($_REQUEST['game_name']); } if (isset($_REQUEST['server_id'])) { @@ -578,19 +640,19 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ $promoter_ids = D("Promote")->where($queryStr)->field('id')->select(); $promoter_ids ? $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; } - + } if (isset($_REQUEST['game_type'])) { $map['sdk_version'] = trim($_REQUEST['game_type']); unset($_REQUEST['game_type']); } - empty(I('user_account')) || $map['user_account'] = ['like',"%".I('user_account')."%"]; + empty(I('user_account')) || $map['user_account'] = ['like', "%" . I('user_account') . "%"]; $list = $this->lists(M('user_play_info', 'tab_'), $map, 'play_time desc'); $this->assign('list', $list); $this->meta_title = '角色数据'; - - $this->m_title = '角色查询'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'User/rolelist','status'=>1])->find()); + + $this->m_title = '角色查询'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/rolelist', 'status' => 1])->find()); $this->display(); @@ -600,47 +662,51 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ * 更新游戏角色数据 * @param $id */ - public function user_update($ids){ + public function user_update($ids) + { $res = D('User')->update_user_player($ids); $this->success("更新成功:{$res['suc']}个,失败:{$res['ero']}"); } + /** * 更新游戏角色数据 * @param $id */ - public function age(){ - if (IS_POST){ + public function age() + { + if (IS_POST) { $data = $_POST; $a = new ToolController(); $re = $a->save($data); - \Think\Log::actionLog('User/age','User',1); + \Think\Log::actionLog('User/age', 'User', 1); $this->success('保存成功'); - }else{ - $data = I('type',1) == 1? C('age'):C('age_prevent'); - $this->assign('data',$data); - $this->meta_title = I('type',1) == 1?"实名认证设置":'防沉迷设置'; - - $this->m_title = I('type',1)==1?'实名认证设置':'防沉迷设置'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'User/age/type/'.I('type',1),'status'=>1])->find()); - + } else { + $data = I('type', 1) == 1 ? C('age') : C('age_prevent'); + $this->assign('data', $data); + $this->meta_title = I('type', 1) == 1 ? "实名认证设置" : '防沉迷设置'; + + $this->m_title = I('type', 1) == 1 ? '实名认证设置' : '防沉迷设置'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/age/type/' . I('type', 1), 'status' => 1])->find()); + $this->display(); } - + } - public function update_pwd(){ - if(IS_POST){ - if(strlen($_POST['new_pwd'])<6||strlen($_POST['new_pwd'])>30){ + public function update_pwd() + { + if (IS_POST) { + if (strlen($_POST['new_pwd']) < 6 || strlen($_POST['new_pwd']) > 30) { $this->error('密码格式不正确!'); } - $oldspwd=$this->think_ucenter_md5($_POST['password'],UC_AUTH_KEY); - $newpwd =$this->think_ucenter_md5($_POST['new_pwd'],UC_AUTH_KEY); - $Member=D('UcenterMember'); - $rpwd=$Member->where(array('id'=>session('user_auth.uid')))->find(); - if($oldspwd==$rpwd['password']){ - $Member->where(array('id'=>session('user_auth.uid')))->save(['password'=>$newpwd]); - $this->success('修改成功!',U('User/index')); - }else{ + $oldspwd = $this->think_ucenter_md5($_POST['password'], UC_AUTH_KEY); + $newpwd = $this->think_ucenter_md5($_POST['new_pwd'], UC_AUTH_KEY); + $Member = D('UcenterMember'); + $rpwd = $Member->where(array('id' => session('user_auth.uid')))->find(); + if ($oldspwd == $rpwd['password']) { + $Member->where(array('id' => session('user_auth.uid')))->save(['password' => $newpwd]); + $this->success('修改成功!', U('User/index')); + } else { $this->error('原密码错误!'); } @@ -648,14 +714,14 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ $this->display(); } - public function get_server_lists($game_id=0){ - $server = M("server","tab_"); + public function get_server_lists($game_id = 0) + { + $server = M("server", "tab_"); $map['game_id'] = $game_id; $lists = $server->field('id,server_name,game_name')->where($map)->select(); - if(empty($lists)){ - return $this->ajaxReturn(array('status'=>0,'data'=>'')); + if (empty($lists)) { + return $this->ajaxReturn(array('status' => 0, 'data' => '')); } - return $this->ajaxReturn(array('status'=>1,'data'=>$lists)); + return $this->ajaxReturn(array('status' => 1, 'data' => $lists)); } - } \ No newline at end of file diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt index 49c9cc67d..bc484849f 100644 --- a/Application/Admin/Controller/access_data_foldline.txt +++ b/Application/Admin/Controller/access_data_foldline.txt @@ -1 +1 @@ -{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":1},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":1},{"time":"10:00","count":0},{"time":"11:00","count":2},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":3},{"time":"15:00","count":1},{"time":"16:00","count":1},{"time":"17:00","count":1},{"time":"18:00","count":3},{"time":"19:00","count":0},{"time":"20:00","count":2},{"time":"21:00","count":0},{"time":"22:00","count":3},{"time":"23:00","count":2}],"sum":{"news":20,"active":43,"player":10,"money":50.059999999999995},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":2},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":2},{"time":"10:00","count":3},{"time":"11:00","count":7},{"time":"12:00","count":1},{"time":"13:00","count":1},{"time":"14:00","count":4},{"time":"15:00","count":1},{"time":"16:00","count":1},{"time":"17:00","count":3},{"time":"18:00","count":5},{"time":"19:00","count":0},{"time":"20:00","count":2},{"time":"21:00","count":1},{"time":"22:00","count":8},{"time":"23:00","count":2}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":1},{"time":"11:00","count":1},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":1},{"time":"15:00","count":3},{"time":"16:00","count":2},{"time":"17:00","count":1},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":1}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":"1.01"},{"time":"11:00","count":"9.00"},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":"0.01"},{"time":"15:00","count":"10.01"},{"time":"16:00","count":"11.02"},{"time":"17:00","count":"14.00"},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":"5.01"}]} \ No newline at end of file +{"news":[{"time":"0:00","count":1},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":1},{"time":"11:00","count":1},{"time":"12:00","count":1},{"time":"13:00","count":1},{"time":"14:00","count":12},{"time":"15:00","count":1},{"time":"16:00","count":3},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":2},{"time":"20:00","count":6},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":29,"active":49,"player":7,"money":13.17},"active":[{"time":"0:00","count":2},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":1},{"time":"9:00","count":4},{"time":"10:00","count":7},{"time":"11:00","count":1},{"time":"12:00","count":4},{"time":"13:00","count":2},{"time":"14:00","count":12},{"time":"15:00","count":3},{"time":"16:00","count":5},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":2},{"time":"20:00","count":6},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":1},{"time":"14:00","count":2},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":1},{"time":"20:00","count":2},{"time":"21:00","count":1},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":"6.01"},{"time":"14:00","count":"3.08"},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":"4.02"},{"time":"20:00","count":"0.05"},{"time":"21:00","count":"0.01"},{"time":"22:00","count":0},{"time":"23:00","count":0}]} \ No newline at end of file diff --git a/Application/Admin/View/Platform/promotepay_statistics.html b/Application/Admin/View/Platform/promotepay_statistics.html index 44b9b0151..a6dfd38e3 100644 --- a/Application/Admin/View/Platform/promotepay_statistics.html +++ b/Application/Admin/View/Platform/promotepay_statistics.html @@ -96,7 +96,7 @@ 累计充值 - 排行榜 + 今日充值 @@ -120,8 +120,8 @@ {$data['promote_account']} - {$data.count} - {$data.rand}{$data.rand}{$data.rand}{$data.rand} + {$data.count} + {$data.today} {$data.week} {$data.mounth} @@ -131,7 +131,7 @@ 汇总 {$total.sum_count} - --- + {$total.sum_today} {$total.sum_week} {$total.sum_mounth} diff --git a/Application/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html index d0adefd7d..bad81eab1 100644 --- a/Application/Admin/View/User/rolelist.html +++ b/Application/Admin/View/User/rolelist.html @@ -124,7 +124,7 @@ - {$data.play_time|date='Y-m-d H:i:s',###} + {$data.create_time|date='Y-m-d H:i:s',###} {$data.user_account} getPublicAchievementMap($ids, $params); $items = M('user_play_info', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select(); - $records = []; foreach ($items as $item) { $promoteId = $item['promote_id']; @@ -119,7 +118,6 @@ class PromoteRepository { $records[$promoteId] = $item['count']; } } - $records = $this->assembleZero($ids, $records, 0); return $records; @@ -162,7 +160,7 @@ class PromoteRepository { } } - $records = $this->assembleZero($ids, [], 0); + $records = $this->assembleZero($ids, $records, 0); return $records; } @@ -188,7 +186,7 @@ class PromoteRepository { $inQuery = M('user_play_info', 'tab_')->field('create_ip')->group('create_ip')->where($map)->buildSql(); $resultMap = ['create_ip' => ['exp', ' in (' . $inQuery . ')']]; - $items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select(); + $items = M('user_play_info', 'tab_')->field(['count(DISTINCT create_ip) count', 'promote_id'])->where($resultMap)->group('promote_id')->select(); $records = []; foreach ($items as $item) { @@ -203,7 +201,7 @@ class PromoteRepository { } } - $records = $this->assembleZero($ids, [], 0); + $records = $this->assembleZero($ids, $records, 0); return $records; } @@ -233,7 +231,8 @@ class PromoteRepository { $inQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($map)->buildSql(); $resultMap = ['_string' => 'user_id in (' . $inQuery . ')']; - $items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select(); + $items = M('user_play_info', 'tab_')->field(['count(DISTINCT user_id) count', 'promote_id'])->where($resultMap)->group('promote_id')->select(); + // var_dump(M()->getLastSql()); $records = []; foreach ($items as $item) { $promoteId = $item['promote_id']; @@ -247,7 +246,7 @@ class PromoteRepository { } } - $records = $this->assembleZero($ids, [], 0); + $records = $this->assembleZero($ids, $records, 0); return $records; } @@ -370,6 +369,7 @@ class PromoteRepository { $params['time_column'] = 'pay_time'; $map = $this->getPublicAchievementMap($ids, $params); + $map['pay_status'] = 1; $items = M('spend', 'tab_')->field(['sum(pay_amount) amount', 'promote_id', 'pay_way'])->where($map)->group('promote_id, pay_way')->select(); // echo M()->getLastSql();die(); $records = []; diff --git a/Application/Base/Repository/UserRepository.class.php b/Application/Base/Repository/UserRepository.class.php index 3e42e4052..e3ad78ade 100644 --- a/Application/Base/Repository/UserRepository.class.php +++ b/Application/Base/Repository/UserRepository.class.php @@ -133,8 +133,13 @@ class UserRepository $dayList = $params['dayList'] ?? []; $params['time_column'] = 'create_time'; $conditions = $this->getDayGroupConditions($params); - $items = M('login_daily_record', 'tab_')->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day, count(DISTINCT user_id, game_id) as count') + $subQuery = M('login_daily_record', 'tab_')->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day,count(DISTINCT user_id) as count') ->where($conditions) + ->group('game_id') + ->buildSql(); + $items = M()->field('*,sum(count) as count') + ->table($subQuery) + ->alias('a') ->group('day') ->select(); @@ -294,8 +299,13 @@ class UserRepository $params['time_column'] = 'create_time'; $conditions = $this->getCreateRoleConditions($params); - $items = M('user_play_info', 'tab_')->field('count(distinct game_id,user_id) count, FROM_UNIXTIME(create_time, "%Y-%m-%d") as day') + $subQuery = M('user_play_info', 'tab_')->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day,count(DISTINCT user_id) as count') ->where($conditions) + ->group('game_id') + ->buildSql(); + $items = M()->field('*,sum(count) as count') + ->table($subQuery) + ->alias('a') ->group('day') ->select(); return $this->assembleRecords($items, $dayList, 'count'); @@ -346,10 +356,14 @@ class UserRepository ->where("ti.user_id = user_id and ti.game_id = game_id and ti.create_time < " . $params['begin_time']) ->fetchSql(true) ->count(); - $items = $model->field("count(distinct game_id,user_id) count, FROM_UNIXTIME(create_time, '%Y-%m-%d') as day, - (" . $sql . ") as num") + $subQuery = $model->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day,count(DISTINCT user_id) as count') ->where($conditions) - ->group("day") + ->group('game_id') + ->buildSql(); + $items = M()->field("*,sum(count) as count,(" . $sql . ") as num") + ->table($subQuery) + ->alias('a') + ->group('day') ->having('num = 0') ->select(); return $this->assembleRecords($items, $dayList, 'count'); @@ -411,10 +425,14 @@ class UserRepository ->where("ti.create_device_number = create_device_number and ti.game_id = game_id and ti.create_time < " . $params['begin_time']) ->fetchSql(true) ->count(); - $items = $model->field("count(distinct game_id,create_device_number) count, FROM_UNIXTIME(create_time, '%Y-%m-%d') as day, - (" . $sql . ") as num") + $subQuery = $model->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day,count(DISTINCT create_device_number) as count') ->where($conditions) - ->group("day") + ->group('game_id') + ->buildSql(); + $items = M()->field("*,sum(count) as count,(" . $sql . ") as num") + ->table($subQuery) + ->alias('a') + ->group('day') ->having('num = 0') ->select(); return $this->assembleRecords($items, $dayList, 'count'); @@ -476,10 +494,14 @@ class UserRepository ->where("ti.create_ip = create_ip and ti.game_id = game_id and ti.create_time < " . $params['begin_time']) ->fetchSql(true) ->count(); - $items = $model->field("count(distinct game_id,create_ip) count, FROM_UNIXTIME(create_time, '%Y-%m-%d') as day, - (" . $sql . ") as num") + $subQuery = $model->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day,count(DISTINCT create_ip) as count') ->where($conditions) - ->group("day") + ->group('game_id') + ->buildSql(); + $items = M()->field("*,sum(count) as count,(" . $sql . ") as num") + ->table($subQuery) + ->alias('a') + ->group('day') ->having('num = 0') ->select(); return $this->assembleRecords($items, $dayList, 'count'); diff --git a/Application/Callback/Controller/Notify3Controller.class.php b/Application/Callback/Controller/Notify3Controller.class.php index 6c3c0e9e6..33d7e65eb 100644 --- a/Application/Callback/Controller/Notify3Controller.class.php +++ b/Application/Callback/Controller/Notify3Controller.class.php @@ -194,6 +194,7 @@ class Notify3Controller extends BaseController $data['type'] = 1; $data['sub_type'] = 1; $data['target_id'] = $promote['id']; + $data['promote_id'] = $promote['id']; $data['target_level'] = $promote['level']; $data['target_type'] = 1; $data['ref_id'] = $order['id']; diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 6f38130b5..8ed98c5b7 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -1053,7 +1053,7 @@ function is_check_account($account){ $map[$field]=$game_id; $data=M('game','tab_')->where($map)->find(); if(empty($data)){return '';} - return $data['dratio']; + return $data['ratio']; } /** diff --git a/Application/Home/Controller/ArticleController.class.php b/Application/Home/Controller/ArticleController.class.php index 7c0e2af26..0ccce084d 100644 --- a/Application/Home/Controller/ArticleController.class.php +++ b/Application/Home/Controller/ArticleController.class.php @@ -82,6 +82,9 @@ class ArticleController extends HomeController { $field = 'id as document_id,category_id'; $decumentData = M('document')->field($field)->where("id={$id}")->find(); $promote_id = get_pid(); + if(empty($promote_id)) { + $promote_id = 0; + } foreach ($decumentData as $key => $value) { $decumentData['promote_id'] = $promote_id; $decumentData['create_time'] = time(); diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 76c7d09c2..1a464a126 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1241,6 +1241,17 @@ class DownloadController extends BaseController { $promoteId = I('promote_id', 0); $sdkVersion = I('sdk_version', 0); $headmanPromoteId = I('headman_promote_id', 0); + $costBegin = I('cost_begin', ''); //充值总额范围 + $costEnd = I('cost_end', ''); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime += 3600 * 24; + $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; @@ -1270,7 +1281,7 @@ class DownloadController extends BaseController { if(empty($levelPromote)) { array_push($ids,PID); } - array_push($ids,$queryPromote['id']); + // array_push($ids,$queryPromote['id']); if (!empty($ids)) { $map['promote_id'] = ['in',$ids]; @@ -1304,6 +1315,18 @@ class DownloadController extends BaseController { } } + if($costBegin) { + $map['costbegin'] = $costBegin; + }else { + $map['costbegin'] = ""; + } + if($costEnd) { + $map['costend'] = $costEnd; + }else { + $map['costend'] = ""; + } + $map['begintime'] = $begTime; + $map['endtime'] = $endTime; $conditions = json_encode($map,TRUE); $addtime = time(); $data = [ @@ -1462,7 +1485,7 @@ class DownloadController extends BaseController { array_push($ids,PID); } - array_push($ids,$queryPromote['id']); + //array_push($ids,$queryPromote['id']); if (!empty($ids)) { $map['promote_id'] = ['in',$ids]; @@ -1507,7 +1530,7 @@ class DownloadController extends BaseController { if (($playTimeEnd - $playTimeBegin) > 31 * 24 * 3600) { $this->error('时间范围不能超过31天'); } - $map['play_time'] = ['between', [$playTimeBegin, $playTimeEnd]]; + $map['create_time'] = ['between', [$playTimeBegin, $playTimeEnd]]; } if ($isSelf) { $map['promote_id'] = $queryPromote['id']; @@ -1735,18 +1758,21 @@ class DownloadController extends BaseController { $xlsName = "注册明细"; $xlsCell = array( array('account','玩家账号'), - array('promote_account','推广账号'), + array('promote_account','推广账号'), + array('device_number','设备IMIE/IDFA'), array('register_time','注册时间'), array('register_ip','注册ip'), - array('login_time','登陆时间'), - array('login_ip','登陆ip') + array('login_time','登陆时间'), + array('login_ip','登陆ip') ); $model = M('user','tab_'); - $data = $model->field('account,promote_account,register_time,register_ip,login_time,login_ip')->where($map)->select(); + $data = $model->field('account,device_number,promote_account,register_time,register_ip,login_time,login_ip')->where($map)->order('tab_user.id desc')->select(); //var_dump($data); $xlsData = []; foreach ($data as $key1 => $value1) { + $value1['register_time'] = date("Y-m-d H:i:s",$value1['register_time']); + $value1['login_time'] = date("Y-m-d H:i:s",$value1['login_time']); $value1['account'] = $this->encryption($value1['account']); $xlsData[] = $value1; } @@ -1761,14 +1787,16 @@ class DownloadController extends BaseController { array('promote_account','推广账号'), array('game_name','游戏名称'), array('server_name','区服'), - array('user_nickname','游戏昵称'), + array('role_name','游戏昵称'), array('role_level','等级'), + array('create_time','创建时间'), ); $model = M('user_play_info','tab_'); - $data = $model->field('user_account,promote_account,game_name,server_name,user_nickname,role_level')->where($map)->select(); + $data = $model->field('user_account,promote_account,game_name,server_name,role_name,role_level')->where($map)->order('create_time desc')->select(); $xlsData = []; foreach ($data as $key1 => $value1) { $value1['user_account'] = $this->encryption($value1['user_account']); + $value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']); $xlsData[] = $value1; } $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); @@ -2701,55 +2729,92 @@ class DownloadController extends BaseController { array('play_time','最后登录时间'), array('promote_account','推广员账号'), - ); - if(!empty($map['promote_id'])) { - $spendMap['promote_id'] = $map['promote_id']; - } - $map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]]; - $roles = M('user_play_info','tab_')->where($map)->select(); - - $roleIds = array_column($roles, 'role_id'); - $spendMap['pay_status'] = 1; - $spendMap['pay_game_status'] = 1; - if (count($roleIds) > 0) { - $spendMap['game_player_id'] = ['in', $roleIds]; - } else { - $spendMap['_string'] = '1<>1'; - } - $allRecharges = M('spend', 'tab_')->field('count(*) count, sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select(); - $allRecords = []; - foreach ($allRecharges as $recharge) { - $allRecords[$recharge['game_player_id']] = $recharge; - } + ); + $subMap = []; + if(!empty($map['game_id'])) { + $subMap['game_id'] = $map['game_id']; + } + if(!empty($map['server_id'])) { + $subMap['server_id'] = $map['server_id']; + } + $costBegin = $map['costbegin']; + $costEnd = $map['costend']; + unset($map['costbegin']); + unset($map['costend']); + + $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; + $roleIdMap = $subMap; + $roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true); + $map['role_id'] = ['in', $roleIds]; + if ($costBegin != '' || $costEnd != '') { + $having = ''; + if ($costBegin != '' && $costEnd != '') { + $having = 'sum(recharge_cost) between ' . $costBegin . ' and ' . $costEnd; + } elseif ($costBegin != '' && $costEnd == '') { + $having = 'sum(recharge_cost) >= ' . $costBegin; + } elseif ($costBegin == '' && $costEnd != '') { + $having = 'sum(recharge_cost) <= ' . $costEnd; + } + $subQuery = M('user_play_data_count', 'tab_')->field('role_id') + ->where($subMap) + ->group('game_id,server_id,role_id') + ->having($having) + ->buildSql(); + $map['_string'] = 'role_id in (' . $subQuery . ')'; + } + $spendMap['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; + $spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; + // $map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]]; + $sqlCost = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_cost) cost') + ->where($spendMap) + ->buildSql(); - $map['pay_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - $todayRecharges = M('spend', 'tab_')->field('sum(cost) cost, game_player_id')->where($map)->group('game_player_id')->select(); - $todayRecords = []; - foreach ($todayRecharges as $recharge) { - $todayRecords[$recharge['game_player_id']] = $recharge; - } + $sqlCount = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_count) count') + ->where($spendMap) + ->buildSql(); + + $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; + + $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_count) count') + ->where($spendMap) + ->buildSql(); + unset($map['begintime']); + unset($map['endtime']); + $subQuery = M('user_play_info', 'tab_') + ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") + ->where($map) + ->having('recharge_cost > 0') + ->order('play_time desc') + ->buildSql(); + $roles = M()->field(' * ') + ->table($subQuery) + ->alias('a') + ->order('play_time desc') + ->select(); + foreach ($roles as $role) { + $records[] = [ + 'user_account' => encryption($role['user_account']), + 'game_name' => $role['game_name'], + 'role_name' => $role['role_name'], + 'role_id' => $role['role_id'], + 'role_level' => $role['role_level'], + 'server_id' => $role['server_id'], + 'server_name' => $role['server_name'], + 'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'], + 'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'], + 'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'], + 'play_time' => $role['play_time'], + 'play_ip' => $role['play_ip'], + 'promote_id' => $role['promote_id'], + 'promote_account' => $role['promote_account'], + 'sdk_version' => $role['sdk_version'], + 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) + ]; + } - $records = []; - foreach ($roles as $role) { - $records[] = [ - 'user_account' => $role['user_account'], - 'game_name' => $role['game_name'], - 'role_name' => $role['role_name'], - 'role_id' => $role['role_id'], - 'role_level' => $role['role_level'], - 'server_id' => $role['server_id'], - 'server_name' => $role['server_name'], - 'recharge_cost' => isset($allRecords[$role['role_id']]) ? round(floatval($allRecords[$role['role_id']]['cost']), 2) : 0, - 'recharge_count' => isset($allRecords[$role['role_id']]) ? $allRecords[$role['role_id']]['count'] : 0, - 'recharge_cost_today' => isset($todayRecords[$role['role_id']]) ? round(floatval($todayRecords[$role['role_id']]['cost']), 2) : 0, - 'play_time' => $role['play_time'], - 'play_ip' => $role['play_ip'], - 'promote_id' => $role['promote_id'], - 'promote_account' => $role['promote_account'], - 'sdk_version' => $role['sdk_version'], - 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) - ]; - } $xlsData = []; foreach ($records as $key1 => $value1) { $value1['user_account'] = $this->encryption($value1['user_account']); diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index 493ad6e6c..605c26ad4 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -565,4 +565,45 @@ class FinanceController extends BaseController $this->assign('modelList', $modelList); $this->display(); } + + //审核拒绝 重新审核 + public function renewReview() + { + //是否是会长 + $this->purview(); + //验证安全密码 + $metaTitle = '结算明细'; + $modelList = ['财务管理', $metaTitle]; + $res = $this->verifyPasswordView($modelList, false); + if ($res == false) { + $data['status'] = 0; + $data['msg'] = '权限异常'; + $this->ajaxReturn($data); + } + + $id = intval(I('id', 0)); + $data = M('withdraw', 'tab_')->find($id); + if (empty($data) || $data['status'] != -1) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } + if ($data['promote_id'] != $this->loginPromote['id']) { + $data['status'] = 0; + $data['msg'] = '权限异常'; + $this->ajaxReturn($data); + } + + $save['status'] = 0; + $save['id'] = $id; + $res = M('withdraw', 'tab_')->save($save); + if ($res === false) { + $data['status'] = 0; + $data['msg'] = '提交失败'; + } else { + $data['status'] = 1; + $data['msg'] = '提交成功'; + } + $this->ajaxReturn($data); + } } \ No newline at end of file diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 1d0307c2a..0335835b6 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -180,14 +180,14 @@ class PromoteController extends BaseController $month_add_user_money = $this->pay_total(3, 1, $promoteId); $yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); - $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y'))-1; //计算昨天用户的统计数据,当日用户充值数据 $pay_time = " between {$yesterday_start} and {$yesterday_end}"; $createTime = ['between', array($yesterday_start, $yesterday_end - 1)]; - $yesterdaySpendData = $this->caculateSpend($pay_time, [], $createTime); +// $yesterdaySpendData = $this->caculateSpend($pay_time, []); +// var_dump($yesterdaySpendData);die(); $todayAddSpendData = $this->caculateSpend($pay_time, [], [], 1); -// var_dump($todayAddSpendData);die(); $mounthAddSpendData = $this->caculateSpend($pay_time, [], [], 2); @@ -209,7 +209,7 @@ class PromoteController extends BaseController $this->assign('data', $data); // $this->assign('yesterdayData',$yesterdayData); $this->assign('spendData', $spendData); - $this->assign('yesterdaySpendData', $yesterdaySpendData); +// $this->assign('yesterdaySpendData', $yesterdaySpendData); $this->assign('todayAddSpendData', $todayAddSpendData); $this->assign('mounthAddSpendData', $mounthAddSpendData); @@ -240,99 +240,131 @@ class PromoteController extends BaseController private function caculateSpend($pay_time, $condition, $create = [], $type = 0) { + $map1['promote_id'] = $map['promote_id'] = array('egt', 0); $spend = M('Spend', 'tab_'); + $map1['pay_status'] = $map['pay_status'] = 1; $today = total(1); + $yesterday = total(5); $week = total(2); $mounth = total(3); - $yesterday = total(5); + unset( $map['create_time']); - $map1['promote_id'] = $map['promote_id'] = array('gt', 0); - $map1['pay_status'] = $map['pay_status'] = 1; - $map1['pay_way'] = $map['pay_way'] = array('gt', 0); - $userId = []; - $this->getLoginPromote(); + $promote_id = get_pid(); $promoteId = M("promote", "tab_") - ->where(array('chain' => ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%'])) - ->getField('id', true); - $promoteId[] = $this->loginPromote['id']; + ->field("id") + ->where(array('chain' => ['like', '/'.$promote_id . '/%'],'id'=>$promote_id,'_logic'=>'or')) + ->select(); + $promoteId = implode(',',array_column($promoteId,'id')); + $whereUser['promote_id'] = ['IN', $promoteId]; if ($type == 1) { + $pay_time = total(1); $start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; $whereUser['register_time'] = ['between', array($start, $end - 1)]; $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } else if ($type == 2) { + $pay_time = total(3); $start = mktime(0, 0, 0, date('m'), 1, date('Y')); $end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1; $whereUser['register_time'] = ['between', array($start, $end - 1)]; $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } +// if ($userId) { +// var_dump($userId); +// } - $userId = implode(',', array_column($userId, 'id')); if ($userId) { + + $userId = implode(',', array_column($userId, 'id')); +// var_dump($userId); $map1['user_id'] = $map['user_id'] = ['IN', $userId]; } else if (!$userId && $type != 0) { - return array('today' => 0, 'mounth' => 0); - } - - if ($create) { - $map['create_time'] = $create; - } - - - $bindrecharge_data = M('bind_recharge', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',real_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',real_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',real_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',real_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $deposit_data = M('deposit', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $spendData = $spend - ->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map) - ->union(' (' . $bindrecharge_data . ') ') - ->union(' (' . $deposit_data . ') ') - ->group('promote_id') - ->select(false); + return array('sum_mounth' => 0, 'sum_today' => 0); + } - $promote_id = get_pid(); - $promote_map = "tp1.`id` = {$promote_id}"; + //获取所有会长 + $promote_map = "`chain` = '%/{$promote_id}/%' OR id = {$promote_id}"; - $data = $spend->field('sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp1.id = tp2.id where $promote_map ) AS t ON promote_id = t.id") - ->where($condition)->table('(' . $spendData . ') as a')->group()->order('count desc,a.ordertime')->find(); + $promote = M("promote","tab_")->field("id,account")->where($promote_map)->select(); + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $yesterday . ',pay_amount,0))*100) as yesterday, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } else { + $dbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $yesterday . ',pay_amount,0))*100) as yesterday, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } + $data[] = $dbdata; + } +// if ($userId) { +// echo $spend->_sql();die(); +// } + foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; + static $i = 0; + $i++; + $data[$key]['rand'] = $i; + $data[$key]['count'] = $value['count'] / 100; + $data[$key]['today'] = $value['today'] / 100; + $data[$key]['yesterday'] = $value['yesterday'] / 100; + $data[$key]['week'] = $value['week'] / 100; + $data[$key]['mounth'] = $value['mounth'] / 100; + } + $total = $this->data_total($data); - $spendData1 = $spend->field('sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') -// ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') ) AS t ON promote_id = t.id") - ->where($condition)->table('(' . $spendData . ') as a')->group()->order('count desc,a.ordertime')->find(); + return $total; +// - $data['rand'] = 1; - $data['count'] = $data['count'] / 100; - $data['today'] = $spendData1['today'] / 100; - $data['week'] = $spendData1['week'] / 100; - $data['mounth'] = $spendData1['mounth'] / 100; + } - return $data; + public function data_total($data) + { + $total['sum_count'] = array_sum(array_column($data, 'count')); + $total['sum_today'] = array_sum(array_column($data, 'today')); + $total['yesterday'] = array_sum(array_column($data, 'yesterday')); + $total['sum_week'] = array_sum(array_column($data, 'week')); + $total['sum_mounth'] = array_sum(array_column($data, 'mounth')); + return $total; } private function pay_total($type = 0, $newadd = 1, $promoteId = "") @@ -867,6 +899,7 @@ class PromoteController extends BaseController $realName = I('real_name', ''); $status = I('status', 'all'); $promoteType = I('promote_type', 0); + $parentId = I('parent_id', 0); $loginer = $this->getLoginPromote(); $map = []; @@ -892,6 +925,9 @@ class PromoteController extends BaseController if ($realName) { $map['real_name'] = ['like', '%' . $realName . '%']; } + if ($parentId) { + $map['parent_id'] = $parentId; + } if ($status != 'all') { $map['status'] = ['eq', $status]; } @@ -899,10 +935,8 @@ class PromoteController extends BaseController list($records, $pagination, $count) = $this->paginate($query); foreach ($records as $key => $value) { - $records[$key]['idcard'] = encryption($value['idcard']); $records[$key]['mobile_phone'] = encryption($value['mobile_phone']); - } $ids = array_column($records, 'id'); @@ -941,6 +975,23 @@ class PromoteController extends BaseController $promoteTypeName = '推广员'; } + $parentMap = []; + $parentMap['chain'] = ['like', $loginer['chain'] . $loginer['id'] . '/%']; + $isGetParents = true; + if ($loginer['level'] == 1 && $promoteType == 1) { + $parentMap['level'] = 2; + } elseif ($loginer['level'] == 1 && $promoteType == 2) { + $parentMap['level'] = 3; + } elseif ($loginer['level'] == 2 && $promoteType == 2) { + $parentMap['level'] = 3; + } else { + $isGetParents = false; + } + $parents = null; + if ($isGetParents) { + $parents = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where($parentMap)->select(); + } + $this->assign('parents', $parents); $this->assign('promoteTypeName', $promoteTypeName); $this->assign('hasChildList', $hasChildList); $this->assign('hasPlayerList', $hasPlayerList); @@ -1132,15 +1183,15 @@ class PromoteController extends BaseController $this->error('您输入的手机号码格式不合法', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); } - if (empty($_REQUEST['email'])) { - $this->error('电子邮箱不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); - return false; - } + // if (empty($_REQUEST['email'])) { + // $this->error('电子邮箱不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); + // return false; + // } - $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"; - if (!preg_match($pattern, $_REQUEST['email'])) { - $this->error('您输入的电子邮箱地址不合法', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); - }; + // $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"; + // if (!preg_match($pattern, $_REQUEST['email'])) { + // $this->error('您输入的电子邮箱地址不合法', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0)))); + // }; $user = new PromoteApi(); $res = $user->edit($_POST); diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index b4ffc591f..be50a7529 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1709,118 +1709,169 @@ class QueryController extends BaseController $isSelf = I('is_self', 0); $roleName = I('role_name', ''); $userAccount = I('user_account', ''); - $promoteId = I('promote_id', 0); $sdkVersion = I('sdk_version', 0); $costBegin = I('cost_begin', ''); $costEnd = I('cost_end', ''); + $lastSortName = trim(I('last_sort_name', '')); + $sortName = trim(I('sort_name', '')); + $sort = intval(I('sort', 1)); + $sortNameData = ['recharge_cost', 'recharge_count', 'recharge_cost_today', 'unlogin_day']; + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime += 3600 * 24; $promote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - $map[] = [ - '_logic' => 'or', - 'id' => $queryPromote['id'], - 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] - ]; - $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $records = []; + $pagination = ''; + $count = 0; + if (intval($endTime - $begTime) / (24 * 3600) <= 31) { + $map = [ + '_logic' => 'or', + 'id' => $queryPromote['id'], + 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] + ]; + $ids = M('promote', 'tab_')->where($map)->getField('id', true); - $map = []; - if (count($ids) > 0) { - $map = ['promote_id' => ['in', $ids]]; - } else { - $map['_string'] = '1<>1'; - } + $map = []; + if (count($ids) > 0) { + $map = ['promote_id' => ['in', $ids]]; + } else { + $map['_string'] = '1<>1'; + } - $spendMap = $map; - if ($gameId != 0) { - $map['game_id'] = $gameId; - } - if ($serverId != 0) { - $map['server_id'] = $serverId; - } - if ($roleName != '') { - $map['role_name'] = ['like', '%' . $roleName . '%']; - } - if ($userAccount != '') { - $map['user_account'] = ['like', '%' . $userAccount . '%']; - } - if ($sdkVersion != 0) { - $map['sdk_version'] = $sdkVersion; - } - if ($isSelf) { - $map['promote_id'] = $queryPromote['id']; - $spendMap['promote_id'] = $queryPromote['id']; - } - if ($costBegin != '' || $costEnd != '') { - $having = ''; - if ($costBegin != '' && $costEnd != '') { - $having = 'sum(cost) between ' . $costBegin . ' and ' . $costEnd; - } elseif ($costBegin != '' && $costEnd == '') { - $having = 'sum(cost) >= ' . $costBegin; - } elseif ($costBegin == '' && $costEnd != '') { - $having = 'sum(cost) <= ' . $costEnd; + $subMap = []; + if ($gameId != 0) { + $map['game_id'] = $gameId; + $subMap['game_id'] = $gameId; + } + if ($serverId != 0) { + $map['server_id'] = $serverId; + $subMap['server_id'] = $serverId; + } + if ($roleName != '') { + $map['role_name'] = ['like', '%' . $roleName . '%']; + } + if ($userAccount != '') { + $map['user_account'] = ['like', '%' . $userAccount . '%']; + } + if ($sdkVersion != 0) { + $map['sdk_version'] = $sdkVersion; + } + if ($isSelf) { + $map['promote_id'] = $queryPromote['id']; } - $subMap = $map; - $subMap['pay_status'] = 1; - $subMap['pay_game_status'] = 1; - $subQuery = M('spend', 'tab_')->field('game_player_id')->where($subMap)->group('game_player_id')->having($having)->buildSql(); - $map['_string'] = 'role_id in (' . $subQuery . ')'; - } - $query = M('user_play_info', 'tab_')->where($map)->order('play_time desc'); - list($roles, $pagination, $count) = $this->paginate($query); - $roleIds = array_column($roles, 'role_id'); - - $spendMap['pay_status'] = 1; - $spendMap['pay_game_status'] = 1; - if (count($roleIds) > 0) { - $spendMap['game_player_id'] = ['in', $roleIds]; - } else { - $spendMap['_string'] = '1<>1'; - } - $allRecharges = M('spend', 'tab_')->field('count(*) count, sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select(); - $allRecords = []; - foreach ($allRecharges as $recharge) { - $allRecords[$recharge['game_player_id']] = $recharge; - } - $spendMap['pay_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - $todayRecharges = M('spend', 'tab_')->field('sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select(); - $todayRecords = []; - foreach ($todayRecharges as $recharge) { - $todayRecords[$recharge['game_player_id']] = $recharge; - } + $subMap['create_time'] = ['between', [$begTime, $endTime - 1]]; + $roleIdMap = $subMap; + $roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true); + $map['role_id'] = ['in', $roleIds]; + if ($costBegin != '' || $costEnd != '') { + $having = ''; + if ($costBegin != '' && $costEnd != '') { + $having = 'sum(recharge_cost) between ' . $costBegin . ' and ' . $costEnd; + } elseif ($costBegin != '' && $costEnd == '') { + $having = 'sum(recharge_cost) >= ' . $costBegin; + } elseif ($costBegin == '' && $costEnd != '') { + $having = 'sum(recharge_cost) <= ' . $costEnd; + } + $subQuery = M('user_play_data_count', 'tab_')->field('role_id') + ->where($subMap) + ->group('game_id,server_id,role_id') + ->having($having) + ->buildSql(); + $map['_string'] = 'role_id in(' . $subQuery . ')'; + } - $records = []; - foreach ($roles as $role) { - $records[] = [ - 'user_account' => encryption($role['user_account']), - 'game_name' => $role['game_name'], - 'role_name' => $role['role_name'], - 'role_id' => $role['role_id'], - 'role_level' => $role['role_level'], - 'server_id' => $role['server_id'], - 'server_name' => $role['server_name'], - 'recharge_cost' => isset($allRecords[$role['role_id']]) ? round(floatval($allRecords[$role['role_id']]['cost']), 2) : 0, - 'recharge_count' => isset($allRecords[$role['role_id']]) ? $allRecords[$role['role_id']]['count'] : 0, - 'recharge_cost_today' => isset($todayRecords[$role['role_id']]) ? round(floatval($todayRecords[$role['role_id']]['cost']), 2) : 0, - 'play_time' => $role['play_time'], - 'play_ip' => $role['play_ip'], - 'promote_id' => $role['promote_id'], - 'promote_account' => $role['promote_account'], - 'sdk_version' => $role['sdk_version'], - 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) - ]; + $orderBy = 'play_time desc'; + if (!empty($sortName)) { + if (in_array($sortName, $sortNameData)) { + $desc = ' desc'; + $asc = ' asc'; + if ($sortName == 'unlogin_day') { + $sortName = 'play_time'; + $desc = ' asc'; + $asc = ' desc'; + } + if ($lastSortName == 'unlogin_day') { + $lastSortName = 'play_time'; + } + if ($lastSortName != $sortName) { + $sortString = $desc; + $sort = 1; + } else { + $sortString = ($sort == 1) ? $desc : $asc; + } + $orderBy = $sortName . $sortString; + } + } + + $spendMap['uc.create_time'] = ['between', [$begTime, $endTime - 1]]; + $spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; + $sqlCost = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_cost) cost') + ->where($spendMap) + ->buildSql(); + $sqlCount = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_count) count') + ->where($spendMap) + ->buildSql(); + $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; + $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc') + ->field('sum(uc.recharge_count) count') + ->where($spendMap) + ->buildSql(); + $subQuery = M('user_play_info', 'tab_') + ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") + ->where($map) + ->having('recharge_cost > 0') + ->order('play_time desc') + ->buildSql(); + $query = M()->field('*') + ->table($subQuery) + ->alias('a') + ->order($orderBy); + + list($roles, $pagination, $count) = $this->paginate($query); + + foreach ($roles as $role) { + $records[] = [ + 'user_account' => encryption($role['user_account']), + 'game_name' => $role['game_name'], + 'role_name' => $role['role_name'], + 'role_id' => $role['role_id'], + 'role_level' => $role['role_level'], + 'server_id' => $role['server_id'], + 'server_name' => $role['server_name'], + 'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'], + 'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'], + 'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'], + 'play_time' => $role['play_time'], + 'play_ip' => $role['play_ip'], + 'promote_id' => $role['promote_id'], + 'promote_account' => $role['promote_account'], + 'sdk_version' => $role['sdk_version'], + 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) + ]; + } } $games = $this->getGamesByPromote($promote); $this->assign('games', $games); - $this->assign('promotes', $promotes); - $this->assign('groupPromotes', $groupPromotes); $this->assign('records', $records); $this->assign('pagination', $pagination); $this->assign('count', $count); + $this->assign('initBegTime', $initBegTime); + $this->assign('initEndTime', $initEndTime); + $this->assign('sort', $sort); $this->display('userRecharges'); } @@ -1906,10 +1957,10 @@ class QueryController extends BaseController public function achievement() { $time = I('time', date('Y-m-d')); - if(!empty($time)) { - $defaultTime = $time ; - }else { - $defaultTime = date('Y-m-d',time()); + if (!empty($time)) { + $defaultTime = $time; + } else { + $defaultTime = date('Y-m-d', time()); } $sdkVersion = I('sdk_version', 0); $gameId = I('game_id', 0); @@ -2000,7 +2051,7 @@ class QueryController extends BaseController $rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params); $rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params); $rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params); - + if (I('p', 1) == 1) { $selfParams = $params; $selfParams['isContainSubs'] = false; @@ -2013,7 +2064,6 @@ class QueryController extends BaseController $selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams); $selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams); $selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams); - $records[] = [ 'id' => $parent['id'], 'account' => $parent['account'], @@ -2027,7 +2077,7 @@ class QueryController extends BaseController 'login_user_count' => $selfLoginUserCountList[$parent['id']], 'recharge_count' => $selfRechargeCountList[$parent['id']], 'recharge_user_count' => $selfRechargeUserCountList[$parent['id']], - 'recharge_amount' => $selfRechargeAmountList[$parent['id']]['ban_coin'] + $rechargeAmountList[$parent['id']]['coin'] + $rechargeAmountList[$parent['id']]['cash'], + 'recharge_amount' => $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash'], 'recharge_by_ban_coin' => $selfRechargeAmountList[$parent['id']]['ban_coin'], 'recharge_by_coin' => $selfRechargeAmountList[$parent['id']]['coin'], 'recharge_by_cash' => $selfRechargeAmountList[$parent['id']]['cash'], @@ -2070,13 +2120,13 @@ class QueryController extends BaseController $this->assign('parentid', $parentId); $this->assign('count', $count); $this->assign('timeout', $timeout); - $this->assign('time',$defaultTime); + $this->assign('time', $defaultTime); $this->display(); } public function getChildPromoteList() { - $promoteId = intval(I('post.promote_id', 0)); + $promoteId = intval(I('post . promote_id', 0)); $promoteId = empty($promoteId) ? PID : $promoteId; $promoteList = getAllPromoteListByType(3, false, $promoteId); $data['status'] = 1; diff --git a/Application/Home/Controller/SafeController.class.php b/Application/Home/Controller/SafeController.class.php index f411f529a..260dc2c8c 100644 --- a/Application/Home/Controller/SafeController.class.php +++ b/Application/Home/Controller/SafeController.class.php @@ -443,38 +443,13 @@ class SafeController extends BaseController{ public function safeDocument() { $time = time(); - $today = date('Y-m-d'); - $username = $_REQUEST['username']; - $tsession =S($today); - if(S($username)) { - $code = S($username); - }else { - if(!empty($tsession)) { - $num = $tsession + 1; - }else { - $num = 1; - } - $promoteRs = M('promote','tab_')->where(['account'=>$username])->getField('create_time',true); - $code = date('Ymd',$promoteRs[0])."_".$num; - } + $loginPromote = $this->getLoginPromote(); + $sn = date('Ymd') . '-' . strtoupper(substr(md5($loginPromote['id']), 8, 16)); $endTime = date('Y-m-d',strtotime('+1 year')); $this->assign('time',date('Y-m-d',$time)); $this->assign('endTime',$endTime); - $this->assign('code',$code); - $this->assign('username',$username); + $this->assign('sn',$sn); $this->display(); } - - public function ajaxAgree() { - $username = $_REQUEST['username']; - $code = $_REQUEST['code']; - $today = date('Y-m-d'); - if(empty(S($username))) { - S($username, $code); - $t = S($today); - S($today,$t+1); - } - $this->ajaxReturn(['code'=>10000]); - } } \ No newline at end of file diff --git a/Application/Home/View/default/Finance/withdrawRecord.html b/Application/Home/View/default/Finance/withdrawRecord.html index cd9515a2f..03c52bf83 100644 --- a/Application/Home/View/default/Finance/withdrawRecord.html +++ b/Application/Home/View/default/Finance/withdrawRecord.html @@ -173,6 +173,8 @@ 提现明细 汇款证明 + + 重新审核 结算单 @@ -267,6 +269,30 @@ }); $(".select_gallery").select2(); + + $('.renew-review').click(function () { + var id = parseInt($(this).attr('data-id')); + + $.ajax({ + type: 'post', + url: '{:U("renewReview")}', + dataType: 'json', + data: {id:id}, + success: function (data) { + if (data.status == 1) { + layer.msg(data.msg, {icon: 1}); + setTimeout(function(){ + window.location.reload(); + },2000); + } else { + layer.msg(data.msg, {icon: 5}); + } + }, + error: function (result) { + layer.msg('网络异常', {icon: 5}); + } + }); + }); }); diff --git a/Application/Home/View/default/Promote/children.html b/Application/Home/View/default/Promote/children.html index 52e049283..d0a0eaef7 100644 --- a/Application/Home/View/default/Promote/children.html +++ b/Application/Home/View/default/Promote/children.html @@ -31,6 +31,16 @@ + +
+ +
+
diff --git a/Application/Home/View/default/Promote/edit_chlid.html b/Application/Home/View/default/Promote/edit_chlid.html index 2b078fa94..46df37f5f 100644 --- a/Application/Home/View/default/Promote/edit_chlid.html +++ b/Application/Home/View/default/Promote/edit_chlid.html @@ -97,7 +97,7 @@ - *电子邮箱 + 电子邮箱 diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index eeeb5b479..0c550f33c 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -6,15 +6,15 @@
  • 推广总用户

    {$data.count}
  • -
  • 推广总充值

    ¥{$spendData.count}
  • -
  • 当日新增用户充值

    ¥{$todayAddSpendData.today}
  • -
  • 当月新增用户充值

    ¥{$mounthAddSpendData.mounth}
  • +
  • 推广总充值

    ¥{$spendData.sum_count}
  • +
  • 当日新增用户充值

    ¥{$todayAddSpendData.sum_today}
  • +
  • 当月新增用户充值

    ¥{$mounthAddSpendData.sum_mounth}
  • 昨日注册用户

    {$data.yesterday}
  • -
  • 昨日充值金额

    ¥{$yesterdaySpendData.count}
  • +
  • 昨日充值金额

    ¥{$spendData.yesterday}
  • 今日注册用户

    {$data.today}
  • -
  • 今日充值金额

    ¥{$spendData.today}
  • +
  • 今日充值金额

    ¥{$spendData.sum_today}
diff --git a/Application/Home/View/default/Query/achievement.html b/Application/Home/View/default/Query/achievement.html index 1a9214d30..68699376b 100644 --- a/Application/Home/View/default/Query/achievement.html +++ b/Application/Home/View/default/Query/achievement.html @@ -109,8 +109,8 @@ {$record.new_create_role_ip_count} {$record.login_user_count} - {$record.recharge_count} {$record.recharge_user_count} + {$record.recharge_count} {$record.recharge_amount} {$record.recharge_by_cash} {$record.recharge_by_coin} diff --git a/Application/Home/View/default/Query/register.html b/Application/Home/View/default/Query/register.html index 8943277f3..673eb850c 100644 --- a/Application/Home/View/default/Query/register.html +++ b/Application/Home/View/default/Query/register.html @@ -72,8 +72,7 @@
- +
diff --git a/Application/Home/View/default/Query/userRecharges.html b/Application/Home/View/default/Query/userRecharges.html index b4d440dc0..b760808bc 100644 --- a/Application/Home/View/default/Query/userRecharges.html +++ b/Application/Home/View/default/Query/userRecharges.html @@ -1,6 +1,7 @@ + @@ -22,51 +33,63 @@ 玩家充值
-