diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index f141a57dd..46a590600 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -674,4 +674,28 @@ class AjaxController extends ThinkController{ $admins = getMarketAdmin($departmentId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['admins' => $admins]]); } + + public function searchRoleInfo() + { + $baseGameId = I('base_game_id', 0); + $roleId = I('role_id', ''); + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + if (!$baseGame) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在', 'data' => []]); + } + $gameIds = [$baseGame['android_game_id'] , $baseGame['ios_game_id']]; + + $role = M('user_play_info', 'tab_')->where(['game_id' => ['in', $gameIds], 'role_id' => $roleId])->order('play_time', 'desc')->limit(1)->find(); + if (!$role) { + return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在', 'data' => []]); + } + $payAmount = M('spend', 'tab_')->where(['game_id' => ['in', $gameIds], 'game_player_id' => $roleId, 'pay_status' => 1, 'user_id' => $role['user_id']])->sum('pay_amount'); + $payAmount = floatval($payAmount); + + return $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => ['server_name' => $role['server_name'], 'role_name' => $role['role_name'], 'pay_amount' => $payAmount] + ]); + } } \ No newline at end of file diff --git a/Application/Admin/Controller/GameRebateController.class.php b/Application/Admin/Controller/GameRebateController.class.php index 5452f0036..99b40e294 100644 --- a/Application/Admin/Controller/GameRebateController.class.php +++ b/Application/Admin/Controller/GameRebateController.class.php @@ -124,18 +124,16 @@ class GameRebateController extends ThinkController return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]); } - public function simulateSpendList() + private function simulateSpendQuery($params) { - $params = I('get.'); - $isExport = $params['is_export'] ?? 0; + $isExport = $params['export'] ?? 0; $page = $params['page'] ?? 0; $limit = $params['limit'] ?? 0; $baseGameId = $params['base_game_id'] ?? 0; $serverId = $params['server_id'] ?? ''; $roleName = $params['role_name'] ?? ''; $userAccount = $params['user_account'] ?? ''; - $reviewStatus = $params['review_status'] ?? -1; - $sendStatus = $params['send_status'] ?? -1; + $status = $params['status'] ?? -1; $reviewerId = $params['reviewer_id'] ?? 0; $reviewType = $params['review_type'] ?? -1; @@ -154,11 +152,8 @@ class GameRebateController extends ThinkController if ($serverId != '') { $where['server_id'] = $serverId; } - if ($reviewStatus != -1) { - $where['review_status'] = $reviewStatus; - } - if ($sendStatus != -1) { - $where['send_status'] = $sendStatus; + if ($status != -1) { + $where['status'] = $status; } if ($reviewerId != 0) { $where['reviewer_id'] = $reviewerId; @@ -199,21 +194,57 @@ class GameRebateController extends ThinkController $records = $query->order('create_time desc')->page($page, $limit)->select(); $count = $countQuery->count(); } + return [$records, $count]; + } - if (count($records) > 0) { + public function simulateSpendList() + { + $params = I('get.'); + $baseGameId = $params['base_game_id'] ?? 0; + $isExport = $params['export'] ?? 0; + $error = ''; + $records = []; + $count = 0; + if ($baseGameId > 0) { + [$records, $count] = $this->simulateSpendQuery($params); + } else { + $error = '请选择游戏搜索'; + } + $statusList = [ + 0 => '未审核', + 1 => '审核通过', + 2 => '审核拒绝', + ]; + + if (count($records) > 0) { $users = []; $userIds = array_column($records, 'user_id'); $users = M('user', 'tab_')->field(['id', 'promote_account'])->where(['id' => ['in', $userIds]])->select(); $users = index_by_column('id', $users); + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + $gameIds = [$baseGame['android_game_id'] , $baseGame['ios_game_id']]; + + $roleIds = array_column($records, 'role_id'); + $items = M('spend', 'tab_') + ->field(['game_player_id', 'sum(pay_amount) amount']) + ->where(['game_player_id' => ['in', $roleIds], 'game_id' => ['in', $gameIds], 'pay_status' => 1, 'user_id' => ['in', $userIds]]) + ->group('game_player_id') + ->select(false); + + $payAmountItems = []; + foreach ($items as $item) { + $payAmountItems[$item['game_player_id']] = $item['amount']; + } + foreach ($records as $key => $record) { $user = $users[$record['user_id']]; - $payAmount = 0; /** @todo */ + $payAmount = $payAmountItems[$record['role_id']] ?? 0; $records[$key]['pay_amount'] = $payAmount; $records[$key]['total_amount'] = $payAmount + $record['amount']; $records[$key]['promote_account'] = $user['promote_account']; - $records[$key]['status_text'] = $this->reviewStatusList[$record['status']]; + $records[$key]['status_text'] = $statusList[$record['status']]; $records[$key]['review_time'] = $record['review_time'] > 0 ? date('Y-m-d H:i:s', $record['review_time']) : '--'; $records[$key]['create_time'] = $record['create_time'] > 0 ? date('Y-m-d H:i:s', $record['create_time']) : '--'; } @@ -255,8 +286,9 @@ class GameRebateController extends ThinkController $this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId)); $this->assign('admins', $admins); $this->assign('baseGames', $baseGames); - $this->assign('reviewStatusList', []); + $this->assign('statusList', $statusList); $this->assign('records', $records); + $this->assign('error', $error); $this->display('simulateSpendList'); } diff --git a/Application/Admin/View/GameRebate/simulateSpendForm.html b/Application/Admin/View/GameRebate/simulateSpendForm.html index 31817929f..6480951ee 100644 --- a/Application/Admin/View/GameRebate/simulateSpendForm.html +++ b/Application/Admin/View/GameRebate/simulateSpendForm.html @@ -131,7 +131,7 @@ body { width: 280px; } .form-group select { - width: 280px; + width: 290px; } .form-group textarea { padding: 5px; @@ -163,54 +163,41 @@ body {
--
角色名称: --
+--
当前累充: --
+--