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.
762 lines
32 KiB
PHP
762 lines
32 KiB
PHP
<?php
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
use Base\Model\PromoteModel;
|
|
use Base\Service\PromoteService;
|
|
use Base\Service\TestingResourceService;
|
|
use Base\Service\PartnerService;
|
|
use Base\Repository\TestingResourceRepository;
|
|
use Base\Repository\GameRepository;
|
|
|
|
class TestingResourceController extends ThinkController
|
|
{
|
|
public function index()
|
|
{
|
|
$params = I('get.');
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
$repository = new TestingResourceRepository();
|
|
$query = $repository->getTestingRolesQuery($params);
|
|
|
|
[$roles, $page, $count] = $this->paginate($query);
|
|
|
|
$records = $repository->makeTestingRoleRecords($roles);
|
|
|
|
$gameRepository = new GameRepository();
|
|
|
|
$this->assign('statusList', TestingResourceRepository::$userStatusList);
|
|
$this->assign('games', $gameRepository->getChoiceGames());
|
|
$this->assign('servers', $gameRepository->getServersByGameId($gameId));
|
|
$this->assign('count', $count);
|
|
$this->assign('records', $records);
|
|
$this->assign('_page', $page);
|
|
$this->display();
|
|
}
|
|
|
|
public function users()
|
|
{
|
|
$params = I('get.');
|
|
|
|
$repository = new TestingResourceRepository();
|
|
$query = $repository->getTestingUsersQuery($params);
|
|
|
|
[$testingUsers, $page, $count] = $this->paginate($query);
|
|
|
|
$records = $repository->makeTestingUserRecords($testingUsers);
|
|
|
|
$this->assign('statusList', TestingResourceRepository::$userStatusList);
|
|
$this->assign('count', $count);
|
|
$this->assign('records', $records);
|
|
$this->assign('_page', $page);
|
|
$this->display();
|
|
}
|
|
|
|
public function getServers()
|
|
{
|
|
$gameId = I('game_id', 0);
|
|
$gameRepository = new GameRepository();
|
|
$servers = $gameRepository->getServersByGameId($gameId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
|
|
}
|
|
|
|
public function gameSettings()
|
|
{
|
|
$page = I('p', 1);
|
|
$row = I('row', 10);
|
|
|
|
$gameId = I('base_game_id', 0);
|
|
$partnerId = I('partner_id', 0);
|
|
|
|
$conditions = [];
|
|
$conditions['_string'] = '1=1';
|
|
if ($partnerId > 0) {
|
|
$partnerService = new PartnerService();
|
|
$baseGames = $partnerService->findBaseGamesByPartnerId($partnerId);
|
|
if (empty($baseGames)) {
|
|
$conditions['_string'] = '1=0';
|
|
} else {
|
|
$conditions['base_game_id'] = ['in', array_column($baseGames, 'id')];
|
|
}
|
|
}
|
|
if ($gameId > 0) {
|
|
$conditions['base_game_id'] = $gameId;
|
|
}
|
|
$query = M('testing_game_setting', 'tab_')->where($conditions)->order('create_time desc');
|
|
[$items, $page, $count] = $this->paginate($query);
|
|
|
|
$baseGames = M('base_game', 'tab_')->select();
|
|
$baseGames = index_by_column('id', $baseGames);
|
|
$partners = M('partner', 'tab_')->field(['id', 'partner'])->select();
|
|
$partners = index_by_column('id', $partners);
|
|
|
|
$games = M('game', 'tab_')->where(['id', 'partner_id'])->select();
|
|
$games = index_by_column('id', $games);
|
|
foreach ($baseGames as $key => $baseGame) {
|
|
if ($baseGame['android_game_id'] > 0) {
|
|
$baseGame['partner_id'] = $games[$baseGame['android_game_id']]['partner_id'];
|
|
} else {
|
|
$baseGame['partner_id'] = $games[$baseGame['ios_game_id']]['partner_id'];
|
|
}
|
|
$baseGames[$key] = $baseGame;
|
|
}
|
|
|
|
$spendList = [];
|
|
$provideItems = [];
|
|
if (count($items) > 0) {
|
|
$pageGameIds = array_merge(array_column($baseGames, 'android_game_id'), array_column($baseGames, 'ios_game_id'));
|
|
/* $spendCondition = [
|
|
'pay_status' => 1,
|
|
'game_id' => ['in', $pageGameIds]
|
|
];
|
|
$spendList = M('spend', 'tab_')->field('sum(pay_amount) amount, game_id')->where($spendCondition)->group('game_id')->select();
|
|
$spendList = index_by_column('game_id', $spendList); */
|
|
|
|
$provideItems = M('testing_resource_batch', 'tab_')
|
|
->field('sum(provide_amount) amount, game_id')
|
|
->where([
|
|
'verify_status' => 1,
|
|
'game_id' => ['in', $pageGameIds]
|
|
])
|
|
->group('game_id')
|
|
->select();
|
|
$provideItems = index_by_column('game_id', $provideItems);
|
|
}
|
|
|
|
$records = [];
|
|
foreach ($items as $item) {
|
|
$baseGame = $baseGames[$item['base_game_id']] ?? null;
|
|
$partnerId = $baseGame ? $baseGame['partner_id'] : 0;
|
|
$partner = $partners[$partnerId] ?? null;
|
|
|
|
/* $aSpendItem = $spendList[$baseGame['android_game_id']] ?? null;
|
|
$bSpendItem = $spendList[$baseGame['ios_game_id']] ?? null;
|
|
$aSpendQuota = $aSpendItem ? $aSpendItem['amount'] : 0;
|
|
$bSpendQuota = $bSpendItem ? $bSpendItem['amount'] : 0; */
|
|
|
|
$aProvideItem = $provideItems[$baseGame['ios_game_id']] ?? null;
|
|
$bProvideItem = $provideItems[$baseGame['android_game_id']] ?? null;
|
|
$aProvideQuota = $aProvideItem ? $aProvideItem['amount'] : 0;
|
|
$bProvideQuota = $bProvideItem ? $bProvideItem['amount'] : 0;
|
|
|
|
$records[] = [
|
|
'id' => $item['id'],
|
|
'base_game_id' => $item['base_game_id'],
|
|
'game_name' => $baseGame ? $baseGame['name'] : '无此游戏',
|
|
'partner_name' => $partner ? $partner['partner'] : '--',
|
|
'rate' => $item['rate'],
|
|
'base_quota' => $item['base_quota'],
|
|
// 'quota' => round(($aSpendQuota + $bSpendQuota) * $item['rate'] / 100, 2),
|
|
'provide_quota' => $aProvideQuota + $bProvideQuota
|
|
];
|
|
}
|
|
|
|
$this->assign('_page', $page);
|
|
$this->assign('records', $records);
|
|
$this->assign('partners', $partners);
|
|
$this->assign('baseGames', $baseGames);
|
|
$this->display();
|
|
}
|
|
|
|
public function saveGameSetting()
|
|
{
|
|
$params = I('post.');
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->saveGameSetting($params);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '保存成功']);
|
|
} catch (\Exception $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '保存失败!' . $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function deleteGameSetting()
|
|
{
|
|
$id = I('id', 0);
|
|
M('testing_game_setting', 'tab_')->where(['id' => $id])->delete();
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '删除成功']);
|
|
}
|
|
|
|
public function addTestingUsers()
|
|
{
|
|
$accountsStr = trim(I('accounts', ''), ',');
|
|
if ($accountsStr == '') {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '请输入测试资源账号']);
|
|
}
|
|
$accounts = explode(',', $accountsStr);
|
|
|
|
$testingResourceService = new TestingResourceService();
|
|
$result = $testingResourceService->addTestingUsers($accounts);
|
|
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '请求成功', 'data' => $result]);
|
|
}
|
|
|
|
public function batches()
|
|
{
|
|
$params = I('get.');
|
|
$isExport = $params['export'] ?? 0;
|
|
|
|
$repository = new TestingResourceRepository();
|
|
$query = $repository->getBatchesQuery($params);
|
|
|
|
if ($isExport == 1) {
|
|
$batches = $query->select();
|
|
$records = $repository->makeBatchesRecords($batches);
|
|
data2csv($records, '申请批次列表', [
|
|
'batch_no' => '批次号',
|
|
'create_time' => '申请时间',
|
|
'game_name' => '游戏名称',
|
|
'server_name' => '区服名称',
|
|
'role_name' => '角色名称',
|
|
'user_account' => '测试账号',
|
|
'user_phone' => '手机号',
|
|
'promote_account' => '所属推广员',
|
|
'apply_username' => '申请人',
|
|
'verify_admin_username' => '审核人',
|
|
'apply_amount' => '申请金额',
|
|
'provide_amount' => '发放金额',
|
|
'verify_status_text' => '审核状态',
|
|
'verify_time' => '审核时间',
|
|
'provide_status_text' => '发放状态',
|
|
'provide_time' => '发放时间'
|
|
]);
|
|
}
|
|
|
|
list($batches, $pagination, $count) = $this->paginate($query);
|
|
|
|
$records = $repository->makeBatchesRecords($batches);
|
|
|
|
$gameRepository = new GameRepository();
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select();
|
|
|
|
$this->assign('verifyStatusList', TestingResourceRepository::$verifyStatusList);
|
|
$this->assign('provideStatusList', TestingResourceRepository::$provideStatusList);
|
|
$this->assign('servers', $gameRepository->getServersByGameId($gameId));
|
|
$this->assign('games', $gameRepository->getChoiceGames());
|
|
$this->assign('admins', $admins);
|
|
$this->assign('count', $count);
|
|
$this->assign('_page', $pagination);
|
|
$this->assign('records', $records);
|
|
$this->display();
|
|
}
|
|
public function indexDailyCountTip()
|
|
{
|
|
$tipApply = 10000;
|
|
$params = [
|
|
'create_time_start'=>date("Y-m-d",strtotime("-1 day")),
|
|
'create_time_end'=>date("Y-m-d",time()),
|
|
];
|
|
$where = $this->setDailyCountWhere($params);
|
|
$having = 'apply_amount >= '.$tipApply;
|
|
$dbdata = M('testing_resource_batch','tab_')
|
|
->where($where)->field("FROM_UNIXTIME(create_time,'%Y-%m-%d') as create_day_time,user_id,role_id,game_id,apply_promote_id,apply_admin_id,verify_admin_id,sum(apply_amount) apply_amount,sum(provide_amount) provide_amount")
|
|
->group("role_id,game_id,create_day_time")
|
|
->order("create_day_time desc")
|
|
->having($having)
|
|
->select();
|
|
$repository = new TestingResourceRepository();
|
|
$records = $repository->makeDailyCountTipData($dbdata);
|
|
//获取跳转连接
|
|
$jumpParm = [
|
|
'apply_amount_start'=>$tipApply,
|
|
'create_time_start'=>$params['create_time_start'],
|
|
'create_time_end'=>$params['create_time_end']
|
|
];
|
|
$jumpUrl = U("TestingResource/dailyCount",$jumpParm);
|
|
$this->ajaxReturn(['status'=>1,'count'=>count($records),'list'=>$records,'jump'=>$jumpUrl]);
|
|
}
|
|
//每日统计
|
|
public function dailyCount()
|
|
{
|
|
$page = I('p', 1);
|
|
$row = I('row', 10);
|
|
$params = I('get.');
|
|
|
|
if(!array_key_exists("create_time_start",$params) && !array_key_exists("create_time_end",$params) && !array_key_exists("isselect",$params)){
|
|
$this->redirect(ACTION_NAME, array('create_time_start' => date('Y-m-d'),"create_time_end"=>date('Y-m-d')));
|
|
}
|
|
|
|
$where = $this->setDailyCountWhere($params);
|
|
$having = '1=1';
|
|
isset($params['apply_amount_start']) && !empty($params['apply_amount_start']) && ( $having .= ' and apply_amount >=' . $params['apply_amount_start']);
|
|
isset($params['apply_amount_end']) && !empty($params['apply_amount_end']) && ( $having .= ' and apply_amount <=' . $params['apply_amount_end']);
|
|
|
|
$isExport = $params['export'] ?? 0;
|
|
$query = M('testing_resource_batch','tab_')
|
|
->where($where)->field("FROM_UNIXTIME(create_time,'%Y-%m-%d') as create_day_time,user_id,role_id,game_id,apply_promote_id,apply_admin_id,verify_admin_id,sum(apply_amount) apply_amount,sum(provide_amount) provide_amount")
|
|
->group("role_id,game_id,create_day_time")
|
|
->order("apply_amount desc,create_day_time desc")
|
|
->having($having);
|
|
$countsql = clone $query;
|
|
if(empty($isExport)){
|
|
$dbdata= $query->page($page,$row)->select();
|
|
$count = M()->table('('.$countsql->select(false).') a')->count();
|
|
}else{
|
|
$dbdata= $query->select();
|
|
}
|
|
$repository = new TestingResourceRepository();
|
|
$records = $repository->makeDailyCountData($dbdata);
|
|
|
|
if (!empty($isExport)) {
|
|
data2csv($records, '测试资源申请统计', [
|
|
'create_day_time' => '申请日期',
|
|
'role_name' => '角色名称',
|
|
'game_name' => '游戏名称',
|
|
'server_name' => '区服名称',
|
|
'user_account' => '测试账号',
|
|
'apply_username' => '申请人',
|
|
'promote_account' => '所属推广员',
|
|
'level_top_promote' => '所属会长',
|
|
'apply_amount' => '总申请金额',
|
|
'provide_amount' => '实发金额'
|
|
]);
|
|
}
|
|
$pagination = set_pagination($count, $row);
|
|
$gameRepository = new GameRepository();
|
|
$gameId = $params['game_id'] ?? 0;
|
|
$this->assign('games', $gameRepository->getChoiceGames());
|
|
$this->assign('count', $count);
|
|
$this->assign('_page', $pagination);
|
|
$this->assign('records', $records);
|
|
$this->display();
|
|
}
|
|
protected function setDailyCountWhere($params)
|
|
{
|
|
$where['_string'] = '1 = 1';
|
|
isset($params['game_id']) && !empty($params['game_id']) && ($where['game_id'] = $params['game_id']);
|
|
isset($params['server_id']) && !empty($params['server_id']) && ($where['server_id'] = $params['server_id']);
|
|
if (isset($params['account']) && !empty($params['account'])) {
|
|
$user = M('user', 'tab_')->field(['id'])->where('account like "' . $params['account'] . '%"')->getField('id',true);
|
|
if (!empty($user)) {
|
|
$where['user_id'] = ['in',$user];
|
|
} else {
|
|
$where['_string'] .= ' and 1<>1';
|
|
return $where;
|
|
}
|
|
}
|
|
isset($params['create_time_start']) && !empty($params['create_time_start']) && ( $where['_string'] .= ' and create_time >=' . strtotime($params['create_time_start'] . ' 00:00:00'));
|
|
isset($params['create_time_end']) && !empty($params['create_time_end']) && ( $where['_string'] .= ' and create_time <=' . strtotime($params['create_time_end'] . ' 23:59:59'));
|
|
if (isset($params['role_name']) && !empty($params['role_name']) ) {
|
|
$roles = M('user_play_info', 'tab_')->where(['role_name' => ['like', "%{$params['role_name']}%"]])->getField('role_id',true);
|
|
if(!empty($roles)){
|
|
$where['role_id'] = ["in",$roles];
|
|
}else{
|
|
$where['_string'] .= ' and 1<>1';
|
|
return $where;
|
|
}
|
|
}
|
|
if (isset($params['apply_name']) && !empty($params['apply_name'])) {
|
|
$promote = M('promote', 'tab_')->where(['account' => ['like', "%{$params['apply_name']}%"]])->getField('id',true);
|
|
$applyAdmins = M('ucenter_member', 'sys_')->where(['username' => ['like', "%{$params['apply_name']}%"]])->getField('id',true);
|
|
if(empty($promote) && empty($applyAdmins)){
|
|
$where['_string'] .= ' and 1<>1';
|
|
return $where;
|
|
}
|
|
if(!empty($promote)){
|
|
$promote = implode(",",$promote);
|
|
if(empty($applyAdmins)){
|
|
$where['_string'] .= " and apply_promote_id in ({$promote })";
|
|
}else{
|
|
$where['_string'] .= " and ( apply_promote_id in ({$promote })";
|
|
}
|
|
}
|
|
if(!empty($applyAdmins)){
|
|
$applyAdmins = implode(",",$applyAdmins);
|
|
if(empty($promote)){
|
|
$where['_string'] .= " and apply_admin_id in ({$applyAdmins}) ";
|
|
}else{
|
|
$where['_string'] .= " or apply_admin_id in ({$applyAdmins}) )";
|
|
}
|
|
}
|
|
}
|
|
return $where;
|
|
}
|
|
|
|
|
|
|
|
public function orders()
|
|
{
|
|
$id = I('id', 0);
|
|
|
|
$batch = M('testing_resource_batch', 'tab_')->where(['id' => $id])->find();
|
|
|
|
$role = M('user_play_info', 'tab_')
|
|
->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account'])
|
|
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
|
|
->find();
|
|
|
|
$applyPromote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $batch['apply_promote_id']])->find();
|
|
$promote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $role['apply_promote_id']])->find();
|
|
|
|
$query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc');
|
|
list($orders, $pagination, $count) = $this->paginate($query);
|
|
|
|
$repository = new TestingResourceRepository();
|
|
foreach ($orders as $order) {
|
|
$records[] = [
|
|
'id' => $order['id'],
|
|
'create_time' => $batch['create_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['create_time']),
|
|
'game_name' => $role['game_name'],
|
|
'user_account' => $role['user_account'],
|
|
'server_name' => $role['server_name'],
|
|
'role_name' => $role['role_name'],
|
|
'promote_account' => $promote['account'],
|
|
'ref_name' => $order['ref_name'],
|
|
'ref_amount' => $order['ref_amount'],
|
|
'num' => $order['num'],
|
|
'amount' => $order['num'] * $order['ref_amount'],
|
|
'remark' => $order['remark'],
|
|
'provide_status' => $order['provide_status'],
|
|
'provide_status_text' => $repository->getProvideStatusText($order['provide_status']),
|
|
];
|
|
}
|
|
|
|
$this->assign('count', $count);
|
|
$this->assign('_page', $pagination);
|
|
$this->assign('records', $records);
|
|
$this->display();
|
|
}
|
|
|
|
public function apply()
|
|
{
|
|
$id = I('id', 0);
|
|
|
|
$role = null;
|
|
if ($id != 0) {
|
|
$role = M('user_play_info', 'tab_')
|
|
->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name', 'testing_other_quota'])
|
|
->where(['id' => $id])
|
|
->find();
|
|
}
|
|
|
|
$hasItf = 0;
|
|
|
|
$servers = [];
|
|
$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();
|
|
$binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find();
|
|
if ($binding) {
|
|
$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']])
|
|
->find();
|
|
if ($bindingRole) {
|
|
$bindingRole['binding_time'] = $binding['create_time'];
|
|
}
|
|
}
|
|
|
|
$repository = new TestingResourceRepository();
|
|
$gameSetting = $repository->getGameSettingByGameId($role['game_id']);
|
|
|
|
$hasItf = $gameSetting ? $gameSetting['has_itf'] : 0;
|
|
}
|
|
|
|
|
|
$testingResourceService = new TestingResourceService();
|
|
$quota = $testingResourceService->getRemainQuota($role, $bindingRole);
|
|
|
|
$games = M('game', 'tab_')->field(['id' , 'game_name'])->select();
|
|
|
|
$this->assign('hasItf', $hasItf);
|
|
$this->assign('games', $games);
|
|
$this->assign('servers', $servers);
|
|
$this->assign('bindingRole', $bindingRole);
|
|
$this->assign('role', $role);
|
|
$this->assign('quota', $quota);
|
|
$this->display();
|
|
}
|
|
|
|
public function doApply()
|
|
{
|
|
$params = I('post.');
|
|
$userAuth = session('user_auth');
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->apply($params, null, $userAuth['uid']);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '申请成功,等待审核。']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function verify()
|
|
{
|
|
$ids = I('ids', []);
|
|
$status = I('status', 0);
|
|
if (count($ids) == 0) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '请选择要审核的批次']);
|
|
}
|
|
if (!in_array($status, [1, 2])) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '请求状态异常']);
|
|
}
|
|
try {
|
|
$service = new TestingResourceService();
|
|
$batches = M('testing_resource_batch', 'tab_')->where(['verify_status' => 0, 'id' => ['in', $ids]])->select();
|
|
if (count($batches) == 0) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '无未审核批次']);
|
|
}
|
|
$userAuth = session('user_auth');
|
|
foreach ($batches as $batch) {
|
|
if ($status == 1) {
|
|
$service->verify($batch, $userAuth['uid']);
|
|
} elseif ($status == 2) {
|
|
$remark = '审核拒绝';
|
|
$service->verifyRefuse($batch, $remark, $userAuth['uid']);
|
|
}
|
|
}
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '操作成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function provide()
|
|
{
|
|
$ids = I('ids', []);
|
|
$status = I('status', 0);
|
|
if (count($ids) == 0) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '请选择要审核的批次']);
|
|
}
|
|
if (!in_array($status, [1, 2])) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '请求状态异常']);
|
|
}
|
|
try {
|
|
$service = new TestingResourceService();
|
|
$batches = M('testing_resource_batch', 'tab_')->where(['verify_status' => 1, 'provide_status' => 0, 'id' => ['in', $ids]])->select();
|
|
if (count($batches) == 0) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '无符合条件的批次']);
|
|
}
|
|
foreach ($batches as $batch) {
|
|
if ($status == 1) {
|
|
$service->provide($batch);
|
|
} elseif ($status == 2) {
|
|
$service->provideRefuse($batch);
|
|
}
|
|
}
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '操作成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function bindRole()
|
|
{
|
|
$params = I('post.');
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->bindRole($params);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function unbindRole()
|
|
{
|
|
$bindingId = I('binding_id', 0);
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->unbindRole($bindingId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '解绑成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function setOtherQuota()
|
|
{
|
|
$id = I('id', 0);
|
|
$otherQuota = I('other_quota', 0);
|
|
$otherQuotaRemark = I('otherQuotaRemark', '');
|
|
M('user_play_info', 'tab_')->where(['id' => $id])->save(['testing_other_quota' => $otherQuota,'testing_other_quota_remark' => $otherQuotaRemark]);
|
|
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);
|
|
$game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$resourceTypes = $testingResourceService->getResourceTypes($game);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resourceTypes' => []]]);
|
|
}
|
|
}
|
|
|
|
public function getResources()
|
|
{
|
|
$typeId = I('type_id', 0);
|
|
$gameId = I('game_id', 0);
|
|
$game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$resources = $testingResourceService->getResources($game, $typeId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resources' => []]]);
|
|
}
|
|
}
|
|
|
|
public function exportOrders()
|
|
{
|
|
$params = I('get.');
|
|
$repository = new TestingResourceRepository();
|
|
$batches = $repository->getBatchesQuery($params)->select();
|
|
$batches = index_by_column('id', $batches);
|
|
|
|
$records = [];
|
|
if (count($batches)) {
|
|
$gameRoleIds = [];
|
|
foreach ($batches as $batch) {
|
|
$gameRoleIds[] = $repository->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
}
|
|
$roles = M('user_play_info', 'tab_')
|
|
->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account', 'promote_id'])
|
|
->where(['game_role_id' => ['in', $gameRoleIds]])
|
|
->select();
|
|
$roles = index_by_column('game_role_id', $roles);
|
|
|
|
$applyPromotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($batches, 'apply_promote_id')]])->select();
|
|
$applyPromotes = index_by_column('id', $applyPromotes);
|
|
|
|
$verifyAdminIds = array_column($batches, 'verify_admin_id');
|
|
$verifyAdmins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $verifyAdminIds]])->select();
|
|
$verifyAdmins = index_by_column('id', $verifyAdmins);
|
|
|
|
$promotes = [];
|
|
if (count($roles) > 0) {
|
|
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($roles, 'promote_id')]])->select();
|
|
$promotes = index_by_column('id', $promotes);
|
|
}
|
|
|
|
$orders = M('testing_resource_order', 'tab_')->where(['batch_id' => ['in', array_column($batches, 'id')]])->order('batch_id desc')->select();
|
|
|
|
foreach ($orders as $order) {
|
|
|
|
$batch = $batches[$order['batch_id']];
|
|
$roleKey = $repository->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
$role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
|
|
$applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
|
|
$promote = $role ? ($promotes[$role['promote_id']] ?? null) : null;
|
|
$verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
|
|
|
|
$records[] = [
|
|
'id' => $order['id'],
|
|
'batch_no' => substr($batch['batch_no'], 14),
|
|
'create_time' => $batch['create_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['create_time']),
|
|
'game_name' => $role ? $role['game_name'] : '',
|
|
'user_account' => $role ? $role['user_account'] : '',
|
|
'server_name' => $role ? $role['server_name'] : '',
|
|
'role_name' => $role ? $role['role_name'] : '',
|
|
'promote_account' => $promote ? $promote['account'] : '',
|
|
'verify_admin_username' => $verifyAdmin ? $verifyAdmin['username'] : '系統',
|
|
'ref_name' => $order['ref_name'],
|
|
'ref_amount' => $order['ref_amount'],
|
|
'num' => $order['num'],
|
|
'amount' => $order['num'] * $order['ref_amount'],
|
|
'remark' => $order['remark'],
|
|
'verify_status_text' => $repository->getVerifyStatusText($batch['verify_status']),
|
|
'provide_status_text' => $repository->getProvideStatusText($order['provide_status']),
|
|
];
|
|
}
|
|
}
|
|
data2csv($records, '批次订单列表', [
|
|
'batch_no' => '批次号',
|
|
'create_time' => '申请时间',
|
|
'game_name' => '游戏名称',
|
|
'server_name' => '区服名称',
|
|
'user_account' => '测试账号',
|
|
'role_name' => '角色名称',
|
|
'promote_account' => '所属推广员',
|
|
'verify_admin_username' => '审核人',
|
|
'ref_name' => '资源名称',
|
|
'ref_amount' => '资源价值',
|
|
'num' => '申请数量',
|
|
'amount' => '申请金额',
|
|
'remark' => '申请备注',
|
|
'verify_status_text' => '审核状态',
|
|
'provide_status_text' => '发放状态'
|
|
]);
|
|
}
|
|
|
|
public function deleteTestingUser()
|
|
{
|
|
$userId = I('user_id', 0);
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->deleteTestingUser($userId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '删除成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function verifyTestingUsers()
|
|
{
|
|
$userIds = I('user_ids', 0);
|
|
$verifyStatus = I('verify_status', 1);
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->verifyTestingUser($userIds, $verifyStatus);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '审核成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function unfreezeTestingUser()
|
|
{
|
|
$userId = I('user_id', 0);
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->unfreezeTestingUser($userId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '解禁成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
public function freezeTestingUser()
|
|
{
|
|
$userId = I('user_id', 0);
|
|
try {
|
|
$testingResourceService = new TestingResourceService();
|
|
$testingResourceService->freezeTestingUser($userId);
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '禁用成功']);
|
|
} catch (\Throwable $e) {
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
} |