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.
687 lines
22 KiB
PHP
687 lines
22 KiB
PHP
<?php
|
|
|
|
namespace Admin\Controller;
|
|
|
|
use Base\Repository\GameRepository;
|
|
use Base\Service\GameRebateService;
|
|
|
|
/**
|
|
* 游戏返利
|
|
*/
|
|
class GameRebateController extends ThinkController
|
|
{
|
|
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)
|
|
{
|
|
$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;
|
|
|
|
if ($params['reviewer_id'] > 0) {
|
|
$params['review_type'] = 0;
|
|
}
|
|
$service = new GameRebateService();
|
|
[$records, $count] = $service->listQuery($params, $awardType);
|
|
|
|
$pageTitle = $service->typeDisplayNames[$awardType];
|
|
$pageName = $service->typeNames[$awardType];
|
|
if (count($records) > 0) {
|
|
$records = $service->listRange($records);
|
|
if ($isExport) {
|
|
$field = $service->getExportHeadings($awardType);
|
|
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $pageTitle . '记录','url'=>U('GameRebate/' . $pageName),'menu'=>'推广员-发放福利管理-' . '导出' . $pageTitle . '记录']);
|
|
data2csv($records, $pageTitle, $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 = $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('records', $records);
|
|
$this->display('records');
|
|
}
|
|
|
|
public function review()
|
|
{
|
|
$ids = I('ids', []);
|
|
$status = I('status', 0);
|
|
try {
|
|
$adminInfo = $_SESSION['onethink_admin']['user_auth'];
|
|
$handler = [];
|
|
$handler['id'] = $adminInfo['uid'];
|
|
$handler['username'] = $adminInfo['username'];
|
|
$handler['type'] = 2;
|
|
$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]]);
|
|
}
|
|
|
|
private function simulateSpendQuery($params)
|
|
{
|
|
$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'] ?? '';
|
|
$status = $params['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 ($status != -1) {
|
|
$where['status'] = $status;
|
|
}
|
|
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();
|
|
}
|
|
return [$records, $count];
|
|
}
|
|
|
|
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();
|
|
|
|
$payAmountItems = [];
|
|
foreach ($items as $item) {
|
|
$payAmountItems[$item['game_player_id']] = $item['amount'];
|
|
}
|
|
|
|
foreach ($records as $key => $record) {
|
|
$user = $users[$record['user_id']];
|
|
$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'] = $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']) : '--';
|
|
}
|
|
|
|
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();
|
|
|
|
$service = new GameRebateService();
|
|
$baseGames = $service->getRebateBaseGames();
|
|
|
|
$gameRepository = new GameRepository();
|
|
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
|
|
$this->assign('admins', $admins);
|
|
$this->assign('baseGames', $baseGames);
|
|
$this->assign('statusList', $statusList);
|
|
$this->assign('records', $records);
|
|
$this->assign('error', $error);
|
|
$this->display('simulateSpendList');
|
|
}
|
|
|
|
public function addSimulateSpend()
|
|
{
|
|
$service = new GameRebateService();
|
|
$baseGames = $service->getRebateBaseGames();
|
|
$this->assign('baseGames', $baseGames);
|
|
$this->display('simulateSpendForm');
|
|
}
|
|
|
|
public function saveSimulateSpend()
|
|
{
|
|
$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()
|
|
]);
|
|
}
|
|
}
|
|
|
|
private function propsQuery($params)
|
|
{
|
|
$isExport = $params['export'] ?? 0;
|
|
$page = $params['page'] ?? 0;
|
|
$limit = $params['limit'] ?? 0;
|
|
$baseGameId = $params['base_game_id'] ?? 0;
|
|
$refId = $params['ref_id'] ?? '';
|
|
$name = $params['name'] ?? '';
|
|
|
|
$where = [
|
|
'_string' => '1=1',
|
|
];
|
|
if ($baseGameId != 0) {
|
|
$where['base_game_id'] = $baseGameId;
|
|
}
|
|
if ($refId) {
|
|
$where['ref_id'] = $refId;
|
|
}
|
|
if ($name != '') {
|
|
$where['name'] = ['like', '%' . $name . '%'];
|
|
}
|
|
$query = M('rebate_props', '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();
|
|
}
|
|
return [$records, $count];
|
|
}
|
|
|
|
public function props()
|
|
{
|
|
$params = I('get.');
|
|
$baseGameId = $params['base_game_id'] ?? 0;
|
|
$isExport = $params['export'] ?? 0;
|
|
$records = [];
|
|
$count = 0;
|
|
$baseGame = null;
|
|
$setting = null;
|
|
if ($baseGameId > 0) {
|
|
$baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
|
|
$setting = M('rebate_times_setting', 'tab_')->where(['base_game_id' => $baseGameId, 'type' => 'J'])->find();
|
|
[$records, $count] = $this->propsQuery($params);
|
|
} else {
|
|
return $this->error('请选择游戏搜索');
|
|
}
|
|
|
|
if (count($records) > 0) {
|
|
if ($isExport) {
|
|
$field = [
|
|
'ref_id' => '道具ID',
|
|
'name' => '道具名称',
|
|
'value' => '道具价值',
|
|
];
|
|
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出定制道具记录','url'=>U('GameRebate/props'),'menu'=>'推广员-发放福利管理-' . '定制道具记录']);
|
|
data2csv($records, $baseGame['name'] . '-定制道具记录', $field);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']);
|
|
|
|
if($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
|
|
$this->assign('records', $records);
|
|
$this->assign('setting', $setting);
|
|
$this->display('props');
|
|
}
|
|
|
|
public function deleteProp()
|
|
{
|
|
$id = I('id', 0);
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->deleteProp($id);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '操作成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function batchDeleteProp()
|
|
{
|
|
$ids = I('ids', []);
|
|
$baseGameId = I('base_game_id', 0);
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->batchDeleteProp($ids, $baseGameId);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '操作成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function saveProp()
|
|
{
|
|
$params = I('post.');
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->saveProp($params);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '保存成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
private function parsePorps($props)
|
|
{
|
|
$keyMap = [
|
|
'道具ID' => 'ref_id',
|
|
'道具名称' => 'name',
|
|
'道具价值' => 'value'
|
|
];
|
|
$newProps = [];
|
|
foreach ($props as $prop) {
|
|
$newProp = [];
|
|
foreach ($prop as $key => $value) {
|
|
$key = trim($key);
|
|
if (isset($keyMap[$key])) {
|
|
$newProp[$keyMap[$key]] = $value;
|
|
}
|
|
}
|
|
$newProps[] = $newProp;
|
|
}
|
|
return $newProps;
|
|
}
|
|
|
|
public function saveProps()
|
|
{
|
|
$props = I('props', []);
|
|
$baseGameId = I('base_game_id', 0);
|
|
$props = $this->parsePorps($props);
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->saveProps($baseGameId, $props);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '保存成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function settings()
|
|
{
|
|
$params = I('get.');
|
|
$isExport = $params['export'] ?? 0;
|
|
$baseGameId = $params['base_game_id'] ?? 0;
|
|
$page = $params['page'] ?? 0;
|
|
$limit = $params['limit'] ?? 0;
|
|
$type = $params['type'] ?? 'J';
|
|
|
|
$where = [
|
|
'_string' => '1=1',
|
|
];
|
|
if ($baseGameId != 0) {
|
|
$where['base_game_id'] = $baseGameId;
|
|
}
|
|
if ($type) {
|
|
$where['type'] = $type;
|
|
}
|
|
|
|
$query = M('rebate_times_setting', '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();
|
|
}
|
|
|
|
$service = new GameRebateService();
|
|
$baseGames = $service->getRebateBaseGames();
|
|
$baseGames = index_by_column('id', $baseGames);
|
|
|
|
if (count($records) > 0) {
|
|
|
|
foreach ($records as $key => $record) {
|
|
$baseGame = $baseGames[$record['base_game_id']];
|
|
$records[$key]['base_game_name'] = $baseGame['name'];
|
|
}
|
|
|
|
if ($isExport) {
|
|
$field = [
|
|
'base_game_name' => '游戏名称',
|
|
'max_times' => '倍数上限',
|
|
];
|
|
$menuName = '';
|
|
if ($type == 'J') {
|
|
$menuName = '定制道具功';
|
|
} else {
|
|
$menuName = '游戏倍数设置';
|
|
$field['default_times'] = '默认倍数';
|
|
}
|
|
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $menuName,'url'=>U('GameRebate/props'),'menu'=>'推广员-发放福利管理-' . $$menuName]);
|
|
data2csv($records, $menuName, $field);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']);
|
|
|
|
if($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
|
|
$this->assign('baseGames', $baseGames);
|
|
$this->assign('records', $records);
|
|
$this->display('settings');
|
|
}
|
|
|
|
public function deleteSetting()
|
|
{
|
|
$id = I('id', 0);
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->deleteSetting($id);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '操作成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function saveSetting()
|
|
{
|
|
$params = I('post.');
|
|
try {
|
|
$service = new GameRebateService();
|
|
$service->saveSetting($params);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '操作成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function propsApply()
|
|
{
|
|
$service = new GameRebateService();
|
|
$baseGames = $service->getRebateBaseGames();
|
|
$this->assign('baseGames', $baseGames);
|
|
$this->display();
|
|
}
|
|
|
|
public function doPropsApply()
|
|
{
|
|
$params = I('post.');
|
|
try {
|
|
$adminInfo = $_SESSION['onethink_admin']['user_auth'];
|
|
$handler = [];
|
|
$handler['type'] = 2;
|
|
$handler['id'] = $adminInfo['uid'];
|
|
$handler['username'] = $adminInfo['username'];
|
|
|
|
$service = new GameRebateService();
|
|
$service->propsApply($params, $handler);
|
|
$this->ajaxReturn([
|
|
'status' => 1,
|
|
'message' => '操作成功'
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->ajaxReturn([
|
|
'status' => 0,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
}
|
|
}
|