diff --git a/Application/Admin/Controller/GameRebateController.class.php b/Application/Admin/Controller/GameRebateController.class.php index 39c621933..6347f4c68 100644 --- a/Application/Admin/Controller/GameRebateController.class.php +++ b/Application/Admin/Controller/GameRebateController.class.php @@ -123,4 +123,185 @@ class GameRebateController extends ThinkController $servers = $gameRepository->getServersByBaseGameId($gameId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]); } + + public function simulateSpendList() + { + $params = I('get.'); + $isExport = $params['is_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; + $reviewerId = $params['reviewer_id'] ?? 0; + $reviewType = $params['review_type'] ?? -1; + + $where = [ + '_string' => '1=1', + ]; + if ($baseGameId != 0) { + $where['base_game_id'] = $baseGameId; + } + if ($userAccount != '') { + $where['user_account'] = ['like', $userAccount . '%']; + } + if ($roleName != '') { + $where['role_name'] = ['like', $roleName . '%']; + } + if ($serverId != '') { + $where['server_id'] = $serverId; + } + if ($reviewStatus != -1) { + $where['review_status'] = $reviewStatus; + } + if ($sendStatus != -1) { + $where['send_status'] = $sendStatus; + } + if ($reviewerId != 0) { + $where['reviewer_id'] = $reviewerId; + } + if ($reviewType != -1) { + $where['review_type'] = $reviewType; + } + + if (I('review_time_start', '') != '') { + $where['_string'] .= ' and review_time>=' . strtotime(I('review_time_start') . ' 00:00:00'); + } + if (I('review_time_end', '') != '') { + $where['_string'] .= ' and review_time<=' . strtotime(I('review_time_end') . ' 23:59:59'); + } + + if (I('create_time_start', '') != '') { + $where['_string'] .= ' and create_time>=' . strtotime(I('create_time_start') . ' 00:00:00'); + } + if (I('create_time_end', '') != '') { + $where['_string'] .= ' and create_time<=' . strtotime(I('create_time_end') . ' 23:59:59'); + } + + /* if ($promote) { + $promoteService = new PromoteService(); + $subSql = M('user', 'tab_')->field(['id'])->where(['_string' => 'promote_id in(' . $promoteService->subInSql($promote) . ')'])->select(false); + $where['_string'] .= ' and user_id in(' . $subSql . ')'; + } */ + + $query = M('simulate_spend', 'tab_')->where($where); + + $count = 0; + $records = []; + if ($isExport == 1 || $limit == 'all') { + $records = $query->order('create_time desc')->select(); + $count = count($records); + } else { + $countQuery = clone $query; + $records = $query->order('create_time desc')->page($page, $limit)->select(); + $count = $countQuery->count(); + } + + 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); + + foreach ($records as $key => $record) { + $user = $users[$record['user_id']]; + $payAmount = 0; /** @todo */ + $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]['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']) : '--'; + } + + if ($isExport) { + $field = [ + 'order_no' => '订单号', + 'base_game_name' => '游戏名称', + 'server_name' => '区服', + 'user_account' => '玩家账号', + 'role_id' => '角色ID', + 'role_name' => '角色名称', + 'promote_account' => '所属推广员', + 'pay_amount' => '当前累充金额', + 'amount' => '模拟发放金额', + 'total_amount' => '可触发返利功能金额', + 'create_time' => '添加时间', + 'status_text' => '审核状态', + 'review_time' => '审核时间', + 'reviewer_username' => '审核人', + 'remark' => '备注', + ]; + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出转区转游模拟发放记录','url'=>U('GameRebate/simulateSpendList'),'menu'=>'推广员-发放福利管理-' . '导出转区转游模拟发放记录']); + data2csv($records, '转区转游模拟发放', $field); + exit; + } + } + + $page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']); + + if($page) { + $this->assign('_page', $page); + } + + $admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select(); + $baseGames = M('base_game', 'tab_')->select(); + + $gameRepository = new GameRepository(); + $this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId)); + $this->assign('admins', $admins); + $this->assign('baseGames', $baseGames); + $this->assign('reviewStatusList', []); + $this->assign('records', $records); + $this->display('records'); + } + + public function addSimulateSpend() + { + $params = I('post.'); + try { + $adminInfo = $_SESSION['onethink_admin']['user_auth']; + $handler = []; + $handler['id'] = $adminInfo['uid']; + $handler['username'] = $adminInfo['username']; + $service = new GameRebateService(); + $service->addSimulateSpend($params, $handler); + $this->ajaxReturn([ + 'status' => 1, + 'message' => '保存成功' + ]); + } catch (\Exception $e) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $e->getMessage() + ]); + } + } + + public function reviewSimulateSpend() + { + $ids = I('ids', []); + $status = I('status', 0); + try { + $adminInfo = $_SESSION['onethink_admin']['user_auth']; + $handler = []; + $handler['id'] = $adminInfo['uid']; + $handler['username'] = $adminInfo['username']; + $service = new GameRebateService(); + $service->reviewSimulateSpend($ids, $status, $handler); + $this->ajaxReturn([ + 'status' => 1, + 'message' => '操作成功' + ]); + } catch (\Exception $e) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $e->getMessage() + ]); + } + } } diff --git a/Application/Admin/View/GameRebate/simulateSpendForm.html b/Application/Admin/View/GameRebate/simulateSpendForm.html new file mode 100644 index 000000000..45870074a --- /dev/null +++ b/Application/Admin/View/GameRebate/simulateSpendForm.html @@ -0,0 +1,622 @@ + + + + + + 游戏登陆列表|----软件管理平台 + + + + + + + + + + + + + + +
+ > +
+ + + + + diff --git a/Application/Admin/View/GameRebate/simulateSpendList.html b/Application/Admin/View/GameRebate/simulateSpendList.html new file mode 100644 index 000000000..06d8099b9 --- /dev/null +++ b/Application/Admin/View/GameRebate/simulateSpendList.html @@ -0,0 +1,394 @@ + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+   +
+
+   +
+
+ + - +
+ + +
+
+
+ + - +
+ + +
+
+
+ +
+
+ +
+
+ +
+
+ 搜索 +
+ +
+
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 订单号游戏名称区服账号角色ID角色名所属推广员当前累充金额模拟发放金额可触发返利功能金额添加时间审核状态审核时间审核人备注
aOh! 暂时还没有内容!
+ + + + + + {$data.order_no}{$data.base_game_name}{$data.server_name}{$data.user_account}{$data.role_id}{$data.role_name}{$data.promote_account}{$data.pay_amount}{$data.amount}{$data.total_amount}{$data.create_time} + {$data.status_text} + {$data.review_time}{$data.reviewer_username}
+
+
+
+ 导出 + {$_page|default=''} +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/Application/Base/Service/GameRebateService.class.php b/Application/Base/Service/GameRebateService.class.php index 6dc49bfea..3f760c661 100644 --- a/Application/Base/Service/GameRebateService.class.php +++ b/Application/Base/Service/GameRebateService.class.php @@ -309,4 +309,68 @@ class GameRebateService ]); return $fields; } + + public function addSimulateSpend($params, $handler = null) + { + $baseGameId = $params['base_game_id'] ?? 0; + $roleId = $params['role_id'] ?? ''; + $amount = $params['amount'] ?? 0; + $remark = $params['remark'] ?? ''; + if ($baseGameId == 0) { + throw new \Exception('请选择游戏'); + } + if ($roleId == 0) { + throw new \Exception('请输入角色ID'); + } + if ($amount <= 0) { + throw new \Exception('金额必须大于0'); + } + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + if ($baseGame == null) { + throw new \Exception('游戏不存在'); + } + $gameIds = [$baseGame['android_game_id'], $baseGame['ios_game_id']]; + + $role = M('user_play_info', 'tab_')->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]])->find(); + if ($role == null) { + throw new \Exception('角色不存在'); + } + $data = [ + 'user_id' => $role['user_id'], + 'user_account' => $role['user_account'], + 'base_game_id' => $baseGame['id'], + 'base_game_name' => $baseGame['name'], + 'role_id' => $role['role_id'], + 'role_name' => $role['role_name'], + 'server_id' => $role['server_id'], + 'server_name' => $role['server_name'], + 'order_no' => '', + 'create_time' => time(), + 'amount' => $amount, + 'remark' => $remark + ]; + + M('simulate_spend', 'tab_')->add($data); + } + + public function reviewSimulateSpend(array $ids, $status, $handler) + { + if (!in_array($status, [1, 2])) { + throw new \Exception('状态异常'); + } + if (count($ids) == 0) { + throw new \Exception('请选择要操作的记录'); + } + $orders = M('simulate_spend', 'tab_')->field(['id'])->where(['review_status' => 0, 'id' => ['in', $ids]])->select(); + if (count($orders) != count($ids)) { + throw new \Exception('含有不存在的记录或者已审核的记录'); + } + + M('simulate_spend', 'tab_')->where(['status' => 0, 'id' => ['in', $ids]])->save([ + 'status' => $status, + 'review_time' => time(), + 'reviewer_id' => $handler['id'], + 'reviewer_username' => $handler['username'], + ]); + } } \ No newline at end of file