diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 4531cf3dd..63e746e58 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -256,7 +256,7 @@ class PlatformController extends ThinkController "pay_status"=>1 ]; D("Spend")->addSubsiteWhere($map); - $Payamount = M("Spend","tab_")->field("sum(IF(is_check=1,pay_amount,0)) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); + $Payamount = SM("Spend","tab_")->field("sum(IF(is_check=1,pay_amount,0)) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); if(empty($Payamount)) return ; foreach ($Payamount as $v) { $list[$v['paytime']]['payamount'] = $v['pay_amount']; @@ -271,7 +271,7 @@ class PlatformController extends ThinkController "pay_time"=>["between",$yearMap], "pay_status"=>1 ]; - $Payamount = M("Spend","tab_")->field("sum(IF(is_check=2,pay_amount,0)) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); + $Payamount = SM("Spend","tab_")->field("sum(IF(is_check=2,pay_amount,0)) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); if(empty($Payamount)) return ; foreach ($Payamount as $v) { $list[$v['paytime']]['unpayamount'] = $v['pay_amount']; diff --git a/Application/Admin/Controller/SubSpendController.class.php b/Application/Admin/Controller/SubSpendController.class.php index ba561f0d7..0d0d1f8dd 100644 --- a/Application/Admin/Controller/SubSpendController.class.php +++ b/Application/Admin/Controller/SubSpendController.class.php @@ -75,26 +75,18 @@ class SubSpendController extends ThinkController unset($_REQUEST['merchant_id']); } - $marketAdminId = 0; - $isMarketAdmin = isMarketAdmin(); - if ($isMarketAdmin) { - $userAuth = session('user_auth'); - $marketAdminId = $userAuth['uid']; - } else { - $marketAdminId = I('market_admin_id', 0); - } - if ($marketAdminId > 0) { - $map['market_admin_id'] = $marketAdminId; - } else { - setPowerPromoteIds($map,'promote_id'); - } - - if (isset($_REQUEST['promote_id'])) { - $promoteId = intval($_REQUEST['promote_id']); - if ($promoteId == 0) { + if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) { + $promoteId = I('promote_id',-1); + $companyId = I('company_id',-1); + if ($promoteId == 0 || $companyId == 0) { $map['promote_id'] = 0; } else { - $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + if($companyId != -1){ + $promoteMap['company_id'] = $companyId; + } + if($promoteId != -1){ + $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + } $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); $promoteIds[] = $promoteId; $map['promote_id'] = ['in', $promoteIds]; @@ -116,20 +108,7 @@ class SubSpendController extends ThinkController $map['game_id'] = ['in',$game_id]; } - // if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { - // $map1 = $map; - // $map1['pay_status'] = 1; - // } else { - // $map = '1 = 2'; - // $map1 = $map; - // } - // $this->checkListOrCountAuthRestMap($map,["extend", "pay_order_number", "user_account"]); D("Spend")->addSubsiteWhere($map); - - $map1 = $map; - $map1['pay_status'] = 1; - $total = null_to_0(M(self::model_name,"tab_")->where($map1)->sum('pay_amount')); - $this->assign('total', $total); $this->meta_title = $this->m_title = '游戏充值'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Spend/lists', 'status' => 1])->find()); @@ -146,6 +125,10 @@ class SubSpendController extends ThinkController $value['sdk_version_name'] = $game_arr[1]; } } + + $promoteCompany = M('promote_company','tab_')->field('id, company_name as name')->where(['status' => 1])->select(); + array_unshift($promoteCompany,['id'=>0,'name'=>C('OFFICIEL_CHANNEL')]); + $this->assign('promoteCompany', $promoteCompany); $this->assign('showMarketAdmin', session('user_auth')['show_market_admin']); $this->assign('showPromote', session('user_auth')['show_promote']); @@ -163,6 +146,257 @@ class SubSpendController extends ThinkController $this->assign('menubtn',$this->menuAuth($is_sub_data)); $this->display(); } + public function exportList() + { + $xlsName = $_REQUEST['xlsname']; + $startDate = empty($_REQUEST['timestart']) ? date('Y-m-d', strtotime('-6 day', time())) : $_REQUEST['timestart']; + $endDate = empty($_REQUEST['timeend']) ? date('Y-m-d') : $_REQUEST['timeend']; + + $startTime = strtotime($startDate); + $endTime = strtotime($endDate) + 86399; + $map['pay_time'] = array('BETWEEN', array($startTime, $endTime)); + $is_sub_data = I("issubdata",0); + if($is_sub_data == 1){ + $SpendModel = M("spend","tab_",SUBSITE_DB); + }else{ + $SpendModel = M("spend","tab_"); + } + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + + if (isset($_REQUEST['user_account'])) { + $map['user_account'] = array('like', trim($_REQUEST['user_account'])); + unset($_REQUEST['user_account']); + } + if (isset($_REQUEST['spend_ip'])) { + $map['spend_ip'] = array('like', trim($_REQUEST['spend_ip']) . '%'); + unset($_REQUEST['spend_ip']); + } + if (isset($_REQUEST['game_name'])) { + if ($_REQUEST['game_name'] == '全部') { + unset($_REQUEST['game_name']); + } else { + $map['game_id'] = ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')]; + unset($_REQUEST['game_name']); + } + } + if (isset($_REQUEST['game_type']) && $_REQUEST['game_type']) { + $map['sdk_version'] = $_REQUEST['game_type']; + } + if (isset($_REQUEST['server_id'])) { + $map['server_id'] = $_REQUEST['server_id']; + unset($_REQUEST['server_id']); + } + if (isset($_REQUEST['pay_order_number'])) { + $map['pay_order_number'] = array('like', trim($_REQUEST['pay_order_number'])); + unset($_REQUEST['pay_order_number']); + } + if (isset($_REQUEST['extend'])) { + $map['extend'] = array('like', trim($_REQUEST['extend'])); + unset($_REQUEST['extend']); + } + if (isset($_REQUEST['pay_status'])) { + $map['pay_status'] = $_REQUEST['pay_status']; + unset($_REQUEST['pay_status']); + } + if (isset($_REQUEST['pay_way'])) { + if ($_REQUEST['pay_way'] == 2) { + $map['pay_way'] = ['in', '2,3,4']; + } else { + $map['pay_way'] = $_REQUEST['pay_way']; + } + unset($_REQUEST['pay_way']); + } + + if (isset($_REQUEST['is_check'])) { + $map['is_check'] = (int)($_REQUEST['is_check']); + unset($_REQUEST['is_check']); + } + + if ($_REQUEST['merchant_id']) { + $map['merchant_id'] = $_REQUEST['merchant_id']; + unset($_REQUEST['merchant_id']); + } + + if (isset($_REQUEST['pay_game_status'])) { + $map['pay_game_status'] = $_REQUEST['pay_game_status']; + unset($_REQUEST['pay_game_status']); + } + + if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) { + $promoteId = I('promote_id',-1); + $companyId = I('company_id',-1); + if ($promoteId == 0 || $companyId == 0) { + $map['promote_id'] = 0; + } else { + if($companyId != -1){ + $promoteMap['company_id'] = $companyId; + } + if($promoteId != -1){ + $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + } + $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; + } + } + 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); + $sort = $data_order == 3 ? 'desc' : 'asc'; + $order = $data_order_type . ' ' . $sort; + } else { + $order = ' pay_time desc '; + } + + if (I('platform_type', 0) != 0) { + $sy = I('platform_type', 0) == 1 ? '=' : '<>'; + $game_id = M("Game","tab_")->where('unique_code ' . $sy . ' ""')->getField("id",true); + $map['game_id'] = ['in',$game_id]; + } + + // if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { + // $map1 = $map; + // $map1['pay_status'] = 1; + // } else { + // $map = '1 = 2'; + // $map1 = $map; + // } + D("Spend")->addSubsiteWhere($map); + $map1 = $map; + $map1['pay_status'] = 1; + $total = $SpendModel->where($map1)->sum('pay_amount'); +// var_dump($total);die(); + $total=$total?$total:0; + + + $headers = [ + 'pay_order_number' => '支付订单号', + 'extend' => 'CP订单号', + 'pay_time' => '充值时间', + 'payed_time' => '支付时间', + 'user_account' => '玩家账号', + 'game_name' => '游戏名称', + 'sdk_version' => '设备类型', + 'game_id' => '所属CP', + 'promote_account' => L('Subordinate_channel'), + '0 as company_name' => '所属推广公司', + 'market_admin_id' => '所属市场专员', + 'merchant_id' => '所属商户', + 'spend_ip' => '充值ip', + 'server_id' => '区服ID', + 'server_name' => '游戏区服', + 'game_player_id' => '角色ID', + 'game_player_name' => '角色名称', + 'cost' => '订单金额', + 'pay_amount' => '实付金额', + 'pay_way' => '充值方式', + 'pay_status' => L('Order_status'), + 'pay_game_status' => '游戏通知状态', + 'is_check' => '是否参与结算', + 'promote_id' => "消费"."{$total}", + ]; + + + $xlsCell = array_values($headers); + $fields = array_keys($headers); + // ----获取游戏的基本信息begin + //获取游戏公司 + $cpCompanyDb = M("partner","tab_")->field("id,partner")->order("id asc")->select(); + $cpCompany = []; + foreach ($cpCompanyDb as $index => $cp) { + $cpCompany[$cp['id']]=$cp['partner']; + } + unset($cpCompanyDb); + //获取所有游戏 + $gameDb = M("Game","tab_")->field("id,relation_game_name,partner_id")->order("id asc")->select(); + $gameInfo = []; + foreach ($gameDb as $index => $g) { + $partner_name = $cpCompany[$g['partner_id']]; + $g['partner_name'] = $partner_name; + $gameInfo[$g['id']]=$g; + } + unset($cpCompany); + unset($gameDb); + // ----获取游戏的基本信息end + + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('GBK', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + + $accessNum = $SpendModel + ->where($map) + ->count(); + + + $perSize = 10000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + +// var_dump($count);die(); + for($i = 1; $i <= $pages; $i++) { + $xlsData = $SpendModel + ->field($fields) + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order($order ? $order : 'pay_time desc') + ->select(); + if ($showMarketAdmin == 1) { + $adminUsernameList = getAdminUsernameList(array_column($xlsData, 'market_admin_id')); + } + $promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select(); + $promoters = $promoters ? array_column($promoters, 'company_id', 'id') : []; + $companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : []; + $companys = $companys ? array_column($companys, 'company_name', 'id') : []; + + foreach($xlsData as $value) { + //游戏信息匹配 + $thisGameInfo = $gameInfo[$value["game_id"]]; + $value['game_name'] =$thisGameInfo['relation_game_name']; + $value['sdk_version'] = $value['sdk_version'] == 1 ? "安卓" : "苹果"; + $value['game_id'] = $thisGameInfo['partner_name']; + + $value['is_check'] = D("Spend")::IsCheckStr[$value['is_check']]; + + $value['company_name'] = $promoters[$value['promote_id']] == 0 ? C('OFFICIEL_CHANNEL') : ($companys[$promoters[$value['promote_id']]] ?? ''); + unset($value['promote_id']); + $value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']); + if($value['pay_status'] == 1) { + $value['payed_time'] = date('Y-m-d H:i:s',$value['payed_time']); + }else { + $value['payed_time'] = "------"; + } + $value['merchant_id'] = getMerchantName($value['merchant_id']); + checkEncryptionAuth($value['user_account'],'spend_lists'); + ($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; + $value['extend'] = $value['extend'].'`'; + $value['pay_way'] = get_pay_way($value['pay_way']); + $value['pay_status'] = get_info_status($value['pay_status'],9); + $value['pay_game_status'] = get_info_status($value['pay_game_status'],14); + $value['market_admin_id'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + } + unset($xlsData);//释放变量的内存 + //刷新输出缓冲到浏览器 + ob_flush(); + flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 + } + fclose($fp); + //操作日志 + $GetData = $_GET; + unset($GetData['xlsname']); + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U('Spend/lists',$GetData),'menu'=>'充值-游戏订单-游戏充值-导出']); + } protected function menuAuth($is_sub_data = false) { @@ -403,6 +637,10 @@ class SubSpendController extends ThinkController if ($page) { $data['page'] = $page; } + + $total = null_to_0($SpendModel->where($map)->where("pay_status = 1")->sum('pay_amount')); + $this->assign('total', $total); + return $data; } diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index 2f73776f3..1668dc596 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -9,6 +9,7 @@ use Base\Service\TestingResourceService; use Base\Service\PartnerService; use Base\Repository\TestingResourceRepository; use Base\Repository\GameRepository; +use Base\Service\GameService; class TestingResourceController extends ThinkController { @@ -439,11 +440,21 @@ class TestingResourceController extends ThinkController $bindingRole = null; if ($role) { $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select(); + $game = M('game', 'tab_')->where(['id' => $role['game_id']])->find(['id', 'data_share']); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); if ($binding) { + + $gameIds = [$role['game_id']]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $bindingRole = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name']) - ->where(['game_id' => $binding['game_id'], 'role_id' => $binding['bind_role_id']]) + ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']]) ->find(); if ($bindingRole) { $bindingRole['binding_time'] = $binding['create_time']; @@ -585,31 +596,6 @@ class TestingResourceController extends ThinkController return $this->ajaxReturn(['status' => 1, 'message' => '设置成功']); } - public function getUserRoles() - { - $gameId = I('game_id', 0); - $serverId = I('server_id', 0); - $userAccount = I('user_account', ''); - $server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find(); - if (is_null($server)) { - return $this->ajaxReturn(['status' => 0, 'message' => '区服不存在']); - } - - $user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find(); - if (is_null($user)) { - return $this->ajaxReturn(['status' => 0, 'message' => '账号不存在']); - } - - $testingUser = M('testing_user', 'tab_')->where(['user_account' => $userAccount])->find(); - $isTestingAccount = is_null($testingUser) ? false : true; - - $roles = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'role_name']) - ->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']]) - ->select(); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]); - } - public function getResourceTypes() { $gameId = I('game_id', 0); @@ -767,4 +753,33 @@ class TestingResourceController extends ThinkController return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); } } + + public function getUserRoles() + { + $gameId = I('game_id', 0); + $roleId = I('role_id', 0); + + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); + if (is_null($game)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); + } + + $gameIds = [$gameId]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames); + if (is_null($baseGame)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); + } + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + + $roles = M('user_play_info', 'tab_') + ->field(['id', 'role_id', 'role_name']) + ->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]]) + ->select(); + + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]); + } } \ No newline at end of file diff --git a/Application/Admin/View/Platform/promote_pool.html b/Application/Admin/View/Platform/promote_pool.html index dbca80e3b..237e588bb 100644 --- a/Application/Admin/View/Platform/promote_pool.html +++ b/Application/Admin/View/Platform/promote_pool.html @@ -40,7 +40,7 @@ 推广员充值统计

推广员汇总

-

说明:统计各工会每月注册及充值总额(注册数:以玩家最后归属的公会为准,非去重)

+

说明:统计各工会每月注册及充值总额(注册数:以玩家最后归属的公会为准,非去重)/ 支付信息仅统计已固定的订单数据

diff --git a/Application/Admin/View/SubSpend/lists.html b/Application/Admin/View/SubSpend/lists.html index f82eb1b85..f1ab220f9 100644 --- a/Application/Admin/View/SubSpend/lists.html +++ b/Application/Admin/View/SubSpend/lists.html @@ -142,6 +142,16 @@

+ +
+ +
+
-
- -
-
+
@@ -535,48 +535,17 @@ body { $('#verify-quota').html(verifyQuota) $('#quota').html(quota-verifyQuota) } - $('#test_account').on({ - blur: function() { - var gameId = $('#game-select').val() - if (gameId == 0) { - return layer.msg('请选择游戏') - } - var serverId = $('#server-select').val() - if (serverId == 0) { - return layer.msg('请选择区服') - } - var userAccount = $('#test_account').val() - if (userAccount == '') { - return layer.msg('请输入测试资源账号') - } - getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) { - if (roles.length == 0) { - return layer.msg('当前账号在该区服未创建角色') - } - if (!isTestingAccount) { - return layer.msg('此账号非测试账号') - } - var html = ""; - for (var i in roles){ - html += "" - } - $("#role-select").html(html); - $("#role-select").select2(); - }) - } - }) - function getUserRoles(userAccount, gameId, serverId, callback) { + function getUserRoles(bindRoleId, gameId, callback) { $.ajax({ url: "{:U('getUserRoles')}", type: "post", - data: { user_account: userAccount, game_id: gameId, server_id: serverId }, + data: { role_id: bindRoleId, game_id: gameId }, dataType: 'json', success: function(result){ if (result.status == 1) { var roles = result.data.roles - var isTestingAccount = result.data.is_testing_account - callback(roles, isTestingAccount) + callback(roles) } else { layer.msg(result.message) } @@ -584,7 +553,7 @@ body { }) } - $('#bind_account').on({ + $('#bind_role_id').on({ blur: function () { var gameId = $('#game-select').val() if (gameId == 0) { @@ -594,16 +563,13 @@ body { if (serverId == 0) { return layer.msg('请选择区服') } - var userAccount = $('#bind_account').val() - if (userAccount == '') { - return layer.msg('请输入玩家账号') + var bindRoleId = $('#bind_role_id').val() + if (bindRoleId == '') { + return layer.msg('请输入角色ID') } - getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) { + getUserRoles(bindRoleId, gameId, function(roles) { if (roles.length == 0) { - return layer.msg('玩家账号在该区服未创建角色') - } - if (isTestingAccount) { - return layer.msg('此账号为测试账号,无法绑定') + return layer.msg('未查询到角色') } var html = ""; for (var i in roles){ diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index c4821b93e..a10ab1221 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -2,6 +2,7 @@ namespace Base\Repository; +use Base\Service\GameService; use Base\Tool\Registry; use Base\Service\PromoteService; @@ -222,7 +223,7 @@ class TestingResourceRepository 'provide_status' => $batch['provide_status'], 'provide_status_text' => $this->getProvideStatusText($batch['provide_status']), 'provide_time' => $batch['provide_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['provide_time']), - 'content' => $content, + 'content' => '', ]; } return $records; @@ -317,6 +318,7 @@ class TestingResourceRepository foreach ($roles as $role) { $bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')'; } + $bindingOrWhereStr = '(' . implode(' or ', $bindingOrWhere) . ')'; $userIds = array_unique(array_column($roles, 'user_id')); $users = []; @@ -325,15 +327,30 @@ class TestingResourceRepository $applyRecords = []; $testingUsers = []; if (count($roles) > 0) { + $games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($roles, 'game_id')]])->select(); + $games = index_by_column('id', $games); + + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select(); $testingUsers = index_by_column('user_id', $testingUsers); $users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select(); $users = index_by_column('id', $users); - $bindingRows = M('testing_binding', 'tab_')->where(['_string' => implode(' or ', $bindingOrWhere)])->select(); + $bindingRows = M('testing_binding', 'tab_')->where(['_string' => $bindingOrWhereStr])->select(); $bindingRoleIds = []; foreach ($bindingRows as $bindingRow) { $bindings[$this->getGameRoleId($bindingRow['game_id'], $bindingRow['role_id'])] = $bindingRow; $bindingRoleIds[] = $this->getGameRoleId($bindingRow['game_id'], $bindingRow['bind_role_id']); + $game = $games[$bindingRow['game_id']]; + $gameIds = [$bindingRow['game_id']]; + if ($game['data_share'] == 1) { + $baseGame = $gameRepository->getBaseGameByGameId($bindingRow['game_id'], $baseGames); + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + foreach ($gameIds as $gameId) { + $bindingRoleIds[] = $this->getGameRoleId($gameId, $bindingRow['bind_role_id']); + } } if (count($bindings) > 0) { $bindingRoles = M('user_play_info', 'tab_') @@ -347,7 +364,7 @@ class TestingResourceRepository ->field('sum(apply_amount) amount, game_id, role_id') ->where([ 'verify_status' => 0, - '_string' => implode(' or ', $bindingOrWhere) + '_string' => $bindingOrWhereStr, ]) ->group('game_id,role_id')->select(); $verifyRecords = []; @@ -359,7 +376,7 @@ class TestingResourceRepository ->field('sum(provide_amount) amount, game_id, role_id') ->where([ 'verify_status' => 1, - '_string' => implode(' or ', $bindingOrWhere) + '_string' => $bindingOrWhereStr, ]) ->group('game_id,role_id')->select(); $provideRecords = []; @@ -371,9 +388,8 @@ class TestingResourceRepository ->field('sum(provide_amount) amount, game_id, role_id') ->where([ 'verify_status' => 1, - '_string' => implode(' or ', $bindingOrWhere), - 'provide_time' => ['egt', strtotime(date('Y-m-d 00:00:00'))], - 'provide_time' => ['elt', strtotime(date('Y-m-d 23:59:59'))], + '_string' => $bindingOrWhereStr, + 'provide_time' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]], ]) ->group('game_id,role_id')->select(); $todayProvideRecords = []; @@ -384,7 +400,7 @@ class TestingResourceRepository $applyItems = M('testing_resource_batch', 'tab_') ->field('sum(apply_amount) amount, game_id, role_id') ->where([ - '_string' => implode(' or ', $bindingOrWhere), + '_string' => $bindingOrWhereStr, ]) ->group('game_id,role_id')->select(); $applyRecords = []; @@ -466,11 +482,19 @@ class TestingResourceRepository $testingUser = $testingUsers[$role['user_id']] ?? null; $binding = $bindings[$role['game_role_id']] ?? null; $bindingRole = null; + + $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); + if ($binding) { - $bindGameRoleId = $this->getGameRoleId($binding['game_id'], $binding['bind_role_id']); - $bindingRole = $bindingRoles[$bindGameRoleId] ? $bindingRoles[$bindGameRoleId] : null; + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + foreach ($gameIds as $gameId) { + $bindGameRoleId = $this->getGameRoleId($gameId, $binding['bind_role_id']); + if (isset($bindingRoles[$bindGameRoleId])) { + $bindingRole = $bindingRoles[$bindGameRoleId]; + break; + } + } } - $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); $gameSetting = null; if ($baseGame && isset($gameSettings[$baseGame['id']])) { $gameSetting = $gameSettings[$baseGame['id']]; diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index bd482148e..c5fb49c11 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -2,6 +2,7 @@ namespace Base\Service; use Base\Facade\Request; +use Base\Repository\GameRepository; use Base\Tool\GameResource; use Base\Repository\TestingResourceRepository; use Base\Repository\SpendRepository; @@ -167,17 +168,16 @@ class TestingResourceService $spendRepository = new SpendRepository(); $spendMap = $spendRepository->withIsCheck($spendMap); - $spendQuota += M('spend', 'tab_') + $spendQuota = M('spend', 'tab_') ->where($spendMap) - ->group('game_id,game_player_id') ->sum('pay_amount'); $totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2); } $providedQuota = M('testing_resource_batch', 'tab_') - ->where(['provide_status' => [in, [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) + ->where(['provide_status' => ['in', [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->sum('provide_amount'); $providingQuota = M('testing_resource_batch', 'tab_') - ->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) + ->where(['verify_status' => ['in', [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->sum('apply_amount'); return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2); } @@ -300,9 +300,24 @@ class TestingResourceService throw new \Exception('测试角色所属推广员异常'); } + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); + if (is_null($game)) { + throw new \Exception('游戏不存在'); + } + $gameIds = [$gameId]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames); + if (is_null($baseGame)) { + throw new \Exception('游戏不存在'); + } + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $bindRole = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'promote_id']) - ->where(['game_role_id' => $bindGameRoleId]) + ->where(['role_id' => $bindRoleId, 'game_id' => ['in', $gameIds]]) ->find(); if (is_null($bindRole)) { throw new \Exception('玩家角色不存在'); @@ -426,9 +441,18 @@ class TestingResourceService $bindingRole = null; if ($binding) { + + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $gameIds = [$gameId]; + if ($game['data_share'] == 1) { + $baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames); + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $bindingRole = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id']) - ->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']]) + ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']]) ->find(); if (is_null($bindingRole)) { throw new \Exception('绑定玩家角色不存在'); diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index 1d8f5bea8..c9a014e3d 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -10,6 +10,7 @@ use Think\Model; use Base\Service\TestingResourceService; use Base\Repository\TestingResourceRepository; use Base\Repository\GameRepository; +use Base\Service\GameService; class TestingResourceController extends BaseController { @@ -135,11 +136,21 @@ class TestingResourceController extends BaseController $bindingRole = null; if ($role) { $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select(); + $game = M('game', 'tab_')->where(['id' => $role['game_id']])->find(['id', 'data_share']); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); if ($binding) { + + $gameIds = [$role['game_id']]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $bindingRole = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name']) - ->where(['game_id' => $binding['game_id'], 'role_id' => $binding['bind_role_id']]) + ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']]) ->find(); if ($bindingRole) { $bindingRole['binding_time'] = $binding['create_time']; @@ -230,25 +241,29 @@ class TestingResourceController extends BaseController public function getUserRoles() { $gameId = I('game_id', 0); - $serverId = I('server_id', 0); - $userAccount = I('user_account', ''); - $server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find(); - if (is_null($server)) { - return $this->ajaxReturn(['status' => 0, 'message' => '区服不存在']); - } + $roleId = I('role_id', 0); - $user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find(); - if (is_null($user)) { - return $this->ajaxReturn(['status' => 0, 'message' => '账号不存在']); + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); + if (is_null($game)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); } - $testingUser = M('testing_user', 'tab_')->where(['user_account' => $userAccount])->find(); - $isTestingAccount = is_null($testingUser) ? false : true; - + $gameIds = [$gameId]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames); + if (is_null($baseGame)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); + } + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $roles = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'role_name']) - ->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']]) + ->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]]) ->select(); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]); + + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]); } } \ No newline at end of file diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html index b43622e30..0c52547e7 100644 --- a/Application/Home/View/default/TestingResource/apply.html +++ b/Application/Home/View/default/TestingResource/apply.html @@ -216,9 +216,9 @@