|
|
|
@ -15,6 +15,8 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$params = I('get.');
|
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
|
|
|
|
|
|
$repository = new TestingResourceRepository();
|
|
|
|
|
$query = $repository->getTestingUsersQuery($params);
|
|
|
|
|
|
|
|
|
@ -81,11 +83,44 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
$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'],
|
|
|
|
@ -93,6 +128,8 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
'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
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -139,15 +176,41 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
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_promote_account' => '申请人',
|
|
|
|
|
'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;
|
|
|
|
|
|
|
|
|
|
$this->assign('verifyStatusList', TestingResourceRepository::$verifyStatusList);
|
|
|
|
|
$this->assign('provideStatusList', TestingResourceRepository::$provideStatusList);
|
|
|
|
|
$this->assign('servers', $gameRepository->getServersByGameId($gameId));
|
|
|
|
@ -235,13 +298,12 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
$hasItf = $gameSetting ? $gameSetting['has_itf'] : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$testingResourceService = new TestingResourceService();
|
|
|
|
|
$quota = $testingResourceService->getRemainQuota($role, $bindingRole);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo 目前固定游戏猫
|
|
|
|
|
*/
|
|
|
|
|
$games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select();
|
|
|
|
|
$games = M('game', 'tab_')->field(['id' , 'game_name'])->select();
|
|
|
|
|
|
|
|
|
|
$this->assign('hasItf', $hasItf);
|
|
|
|
|
$this->assign('games', $games);
|
|
|
|
|
$this->assign('servers', $servers);
|
|
|
|
@ -266,10 +328,207 @@ class TestingResourceController extends ThinkController
|
|
|
|
|
public function verify()
|
|
|
|
|
{
|
|
|
|
|
$ids = I('ids', []);
|
|
|
|
|
$service = new TestingResourceService();
|
|
|
|
|
$batches = M('testing_resource_batch', 'tab_')->where(['verify_status' => 0, 'id' => ['in', $ids]])->select();
|
|
|
|
|
foreach ($batches as $batch) {
|
|
|
|
|
$service->verify($batch);
|
|
|
|
|
$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' => '无未审核批次']);
|
|
|
|
|
}
|
|
|
|
|
foreach ($batches as $batch) {
|
|
|
|
|
if ($status == 1) {
|
|
|
|
|
$service->verify($batch);
|
|
|
|
|
} elseif ($status == 2) {
|
|
|
|
|
$service->verifyRefuse($batch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 $th) {
|
|
|
|
|
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 $th) {
|
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setOtherQuota()
|
|
|
|
|
{
|
|
|
|
|
$id = I('id', 0);
|
|
|
|
|
$otherQuota = I('other_quota', 0);
|
|
|
|
|
M('user_play_info', 'tab_')->where(['id' => $id])->save(['testing_other_quota' => $otherQuota]);
|
|
|
|
|
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);
|
|
|
|
|
$testingResourceService = new TestingResourceService();
|
|
|
|
|
$resourceTypes = $testingResourceService->getResourceTypes($gameId);
|
|
|
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResources()
|
|
|
|
|
{
|
|
|
|
|
$typeId = I('type_id', 0);
|
|
|
|
|
$testingResourceService = new TestingResourceService();
|
|
|
|
|
$resources = $testingResourceService->getResources($typeId);
|
|
|
|
|
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $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);
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
$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'] : '',
|
|
|
|
|
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
|
|
|
|
|
'promote_account' => $promote ? $promote['account'] : '',
|
|
|
|
|
'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' => '角色名称',
|
|
|
|
|
'apply_promote_account' => '申请人',
|
|
|
|
|
'promote_account' => '所属推广员',
|
|
|
|
|
'ref_name' => '资源名称',
|
|
|
|
|
'ref_amount' => '资源价值',
|
|
|
|
|
'num' => '申请数量',
|
|
|
|
|
'amount' => '申请金额',
|
|
|
|
|
'remark' => '申请备注',
|
|
|
|
|
'verify_status_text' => '审核状态',
|
|
|
|
|
'provide_status_text' => '发放状态'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|