You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
6.1 KiB
PHP

<?php
namespace Home\Controller;
use Base\Service\PromoteService;
use Base\Repository\GameRepository;
use Base\Service\GameRebateService;
class GameRebateController extends BaseController
{
protected function _initialize()
{
parent::_initialize();
$loginPromote = $this->getLoginPromote();
if ($loginPromote['rebate_over_perm'] == 0) {
return $this->error('无权限操作');
}
}
public function single()
{
$this->records('A');
}
public function accumulative()
{
$this->records('C');
}
public function daily()
{
$this->records('B');
}
public function firstPay()
{
$this->records('D');
}
public function dayAccumulative()
{
$this->records('E');
}
public function weekly()
{
$this->records('F');
}
public function newRole()
{
$this->records('G');
}
public function dailySign()
{
$this->records('H');
}
public function singleTimes()
{
$this->records('I');
}
public function propsApplication()
{
$this->records('J');
}
public function openSevenDay()
{
$this->records('K');
}
public function records($awardType)
{
$promoteService = new PromoteService();
$loginPromote = $this->getLoginPromote();
$permPromote = $promoteService->getTopPromote($loginPromote);
$params = I('get.');
$params['is_export'] = ($params['export'] ?? 0);
$params['page'] = ($params['p'] ?? 1);
$params['limit'] = ($params['row'] ?? 10);
$baseGameId = $params['base_game_id'] ?? 0;
$isExport = $params['is_export'] == 1;
$service = new GameRebateService();
[$records, $count] = $service->listQuery($params, $awardType, $permPromote);
$pageTitle = $service->typeDisplayNames[$awardType];
$pageName = $service->typeNames[$awardType];
if (count($records) > 0) {
$records = $service->listRange($records);
if ($isExport) {
$field = $service->getExportHeadings($awardType);
data2csv($records, $pageTitle, $field);
exit;
}
}
$pagination = $this->getPagination($count, $params['page'], $params['limit']);
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select();
$baseGames = $service->getRebateBaseGames();
$gameRepository = new GameRepository();
$this->assign('pageTitle', $pageTitle);
$this->assign('pageName', $pageName);
$this->assign('awardType', $awardType);
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
$this->assign('admins', $admins);
$this->assign('baseGames', $baseGames);
$this->assign('sendStatusList', $service->sendStatusList);
$this->assign('reviewStatusList', $service->reviewStatusList);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
$this->display('records');
}
public function review()
{
$ids = I('ids', []);
$status = I('status', 0);
$loginPromote = $this->getLoginPromote();
try {
$handler = [];
$handler['type'] = 1;
$handler['id'] = $loginPromote['id'];
$handler['username'] = $loginPromote['account'];
$service = new GameRebateService();
$service->review($ids, $status, $handler);
$this->ajaxReturn([
'status' => 1,
'message' => '操作成功'
]);
} catch (\Exception $e) {
$this->ajaxReturn([
'status' => 0,
'message' => $e->getMessage()
]);
}
}
public function getServers()
{
$gameId = I('game_id', 0);
$gameRepository = new GameRepository();
$servers = $gameRepository->getServersByBaseGameId($gameId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
}
public function doPropsApply()
{
$params = I('post.');
$loginPromote = $this->getLoginPromote();
try {
$handler = [];
$handler['type'] = 1;
$handler['id'] = $loginPromote['id'];
$handler['username'] = $loginPromote['account'];
$service = new GameRebateService();
$service->propsApply($params, $handler);
$this->ajaxReturn([
'status' => 1,
'message' => '操作成功'
]);
} catch (\Exception $e) {
$this->ajaxReturn([
'status' => 0,
'message' => $e->getMessage()
]);
}
}
public function searchRoleInfo()
{
$params = I('post.');
$promoteService = new PromoteService();
$loginPromote = $this->getLoginPromote();
$permPromote = $promoteService->getTopPromote($loginPromote);
try {
$service = new GameRebateService();
$roleInfo = $service->getRoleInfo($params, $permPromote);
return $this->ajaxReturn([
'status' => 1,
'message' => '获取成功',
'data' => $roleInfo
]);
} catch (\Exception $e) {
return $this->ajaxReturn([
'status' => 0,
'message' => $e->getMessage(),
'data' => []
]);
}
}
public function propsApply()
{
$service = new GameRebateService();
$baseGames = $service->getRebateBaseGames();
$this->assign('baseGames', $baseGames);
$this->display();
}
public function getRebateProps()
{
$baseGameId = I('base_game_id', 0);
$props = M('rebate_props', 'tab_')->where(['base_game_id' => $baseGameId])->select();
$this->ajaxReturn([
'status' => 1,
'message' => '获取成功',
'data' => [
'props' => $props,
]
]);
}
}