master
ELF 4 years ago
parent 06bd640c79
commit c5fe80639f

@ -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' => '发放状态'
]);
}
}

@ -94,7 +94,7 @@ body {
margin-top: 10px;
}
.info-row button {
width: 120px;
width: auto;
height: 25px;
display: block;
background: #E5E5E5;
@ -284,6 +284,7 @@ body {
<script type="text/javascript">
$(".select_gallery").select2()
var globalGameId = $('#game-select').val()
var hasItf = $('#hasItf').val()
if (globalGameId > 0) {
initTable(globalGameId)
}
@ -318,6 +319,9 @@ body {
function initTable(gameId) {
var table = $('#resource-table');
table.find('.normal-row').remove()
if (hasItf != 1) {
return;
}
$.ajax({
url: "{:U('getResourceTypes')}",
type: "post",
@ -466,6 +470,13 @@ body {
statQuota()
}
})
$('#resource-table').on('blur', 'input[name=amount]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
statQuota()
}
})
function statQuota() {
var quota = $('#quota').attr('data-quota')
var hasItf = $('#hasItf').val()

@ -48,6 +48,29 @@
.clearfix {
*zoom: 1;
}
.butnbox {
padding: 10px 0 10px;
}
.butnbox .butnlist .butn {
display: inline-block;
width: 120px;
height: 28px;
line-height: 28px;
text-align: center;
color: #FFF;
background: #3C95C8;
border-radius: 3px;
cursor: pointer;
}
.data_list table td .status-0 {
color: #e6a23c;
}
.data_list table td .status-1 {
color: #67c23a;
}
.data_list table td .status-2 {
color: #f56c6c;
}
</style>
</block>
<block name="body">
@ -61,40 +84,82 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">游戏测试资源设置</h3>
<h3 class="page_title">测试资源申请批次</h3>
</div>
<div class="cf top_nav_list">
<div class="cf top_nav_list" style="height: 38px;">
<!-- 高级搜索 -->
<div class="jssearch cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="base_game_id" name="base_game_id" class="select_gallery" style="width:120px;">
<option value="0">游戏名称</option>
<?php foreach($baseGames as $baseGame):?>
<option value="<?=$baseGame['id']?>"><?=$baseGame['name']?></option>
<select id="game_id" name="game_id" class="select_gallery" style="width:120px;">
<option value="0">请选游戏</option>
<?php foreach($games as $game):?>
<option game-id="<?=$game['id']?>" value="<?=$game['id']?>"><?=$game['game_name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="server_id" name="server_id" class="select_gallery" style="width:120px;">
<option value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['server_id']?>">
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<input type="text" name="account" placeholder="测试账号" class="" value="" style="width: 150px">
</div>
<div class="input-list input-list-promote search_label_rehab">
<input type="text" readonly name="create_time_start" class="time-select" value="{:I('create_time_start')}"
placeholder="申请开始时间"/>
-
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" readonly name="create_time_end" class="time-select" value="{:I('create_time_end')}"
placeholder="申请结束时间"/>
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="verify_status" class="select_gallery" style="width:120px;">
<option value="-1">请选择审核状态</option>
<?php foreach($verifyStatusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="partner_id" name="partner_id" class="select_gallery" style="width:120px;">
<option value="">游戏合作方</option>
<?php foreach($partners as $partner):?>
<option value="<?=$partner['id']?>"><?=$partner['partner']?></option>
<select name="provide_status" class="select_gallery" style="width:120px;">
<option value="-1">请选择发放状态</option>
<?php foreach($provideStatusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('PresidentDeposit/records')}">搜索</a>
<a class="sch-btn" href="javascript:;" id="add-btn">新增</a>
<a class="sch-btn" href="javascript:;" id="search" url="{:U('TestingResource/batches')}">搜索</a>
<a class="sch-btn" href="{:U('exportOrders', I('get.'))}" target="_blank">导出</a>
</div>
<!-- <div class="input-list">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,),I('get.')))}">导出</a>
</div> -->
</div>
</div>
<div class="butnbox">
<div class="butnlist jscheckbutn" style="margin-left: 2px">
<a class="butn" id="verify-agree-btn">审批通过</a>
<a class="butn" id="verify-refuse-btn" style="background-color: red;">审核拒绝</a>
<a class="butn" id="provide-agree-btn">设为已发放</a>
<a class="butn" id="provide-refuse-btn" style="background-color: red;">设为发放失败</a>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
@ -133,7 +198,7 @@
<else />
<volist name="records" id="record" mod="2">
<tr data-id="{$record.id}" class="<eq name='mod' value='1'>odd</eq>">
<td><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
<td><input class="ids" type="checkbox" value="{$record['id']}" name="ids[]"></td>
<td style="word-wrap:break-word;">{$record.batch_no}</td>
<td>
<?=substr($record['create_time'], 0, 10)?>
@ -178,10 +243,10 @@
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>
@ -297,6 +362,116 @@
})
return ids;
}
$("#game_id").change(function () {
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: $("#game_id option:selected").attr('game-id') },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
var servers = result.data.servers
var str = "<option value=''>请选择区服</option>"
for (var i in servers){
str += "<option value='"+servers[i].server_id+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
$('#verify-agree-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的批次')
}
layer.confirm('确定要审核通过这些批次吗?', {
title: '审核通过',
btn: ['确定']
}, function(){
verify(ids, 1)
})
}
})
$('#verify-refuse-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的批次')
}
layer.confirm('确定要审核拒绝这些批次吗?', {
title: '审核拒绝',
btn: ['确定']
}, function(){
verify(ids, 2)
})
}
})
$('#provide-agree-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的批次')
}
layer.confirm('确定将这些批次设为已发放吗?', {
title: '设为已发放',
btn: ['确定']
}, function(){
provide(ids, 1)
})
}
})
$('#provide-refuse-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的批次')
}
layer.confirm('确定将这些批次设为发放失败吗?', {
title: '设为发放失败',
btn: ['确定']
}, function(){
provide(ids, 2)
})
}
})
function verify(ids, status) {
$.ajax({
url: "{:U('verify')}",
type: "post",
data: { ids: ids, status: status },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
} else {
layer.msg(result.message)
}
}
})
}
function provide(ids, status) {
$.ajax({
url: "{:U('provide')}",
type: "post",
data: { ids: ids, status: status },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
} else {
layer.msg(result.message)
}
}
})
}
});
</script>
</block>

@ -122,7 +122,7 @@
<td>{$data.partner_name}</td>
<td class="base_quota" data-value="{$data.base_quota}">{$data.base_quota}</td>
<td class="rate" data-value="{$data.rate}">{$data.rate}%</td>
<td></td>
<td>{$data.provide_quota}</td>
<td>
<div class="partakebtn">
<a class="edit-setting">编辑</a>

@ -61,7 +61,7 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">游戏测试资源设置</h3>
<h3 class="page_title">测试账号</h3>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
@ -104,11 +104,11 @@
<input type="text" name="role_name" placeholder="角色名称" class="" value="" style="width: 150px">
</div>
<div class="input-list input-list-promote search_label_rehab">
<input type="text" readonly name="pay_confirm_time_start" class="time-select" value="{:I('pay_confirm_time_start')}"
<input type="text" readonly name="create_time_start" class="time-select" value="{:I('create_time_start')}"
placeholder="创建开始时间"/>
-
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" readonly name="pay_confirm_time_end" class="time-select" value="{:I('pay_confirm_time_end')}"
<input type="text" readonly name="create_time_end" class="time-select" value="{:I('create_time_end')}"
placeholder="创建结束时间"/>
<span class="add-on"><i class="icon-th"></i></span>
</div>
@ -145,6 +145,7 @@
<th>申请总金额</th>
<th>状态</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
@ -154,7 +155,7 @@
<td colspan="99" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="records" id="record">
<tr data-id="<?=$record['id']?>">
<tr data-id="<?=$record['id']?>" data-binding-id="{$record.binding_id}" data-other-quota="{$record.other_quota}">
<td>
<input class="ids" type="radio" value="{$record['id']}" name="role_id">
</td>
@ -164,7 +165,9 @@
<td>{$record.user_phone}</td>
<td>{$record.role_name}</td>
<td>{$record.bind_user_account}</td>
<td>{$record.bind_role_name}</td>
<td>
{$record.bind_role_name}
</td>
<td>{$record.base_quota}</td>
<td>{$record.other_quota}</td>
<td>{$record.quota}</td>
@ -178,6 +181,12 @@
<br>
<?=substr($record['create_time'], 10)?>
</td>
<td>
<a href="javascript:;" class="set-quota-btn">设置额外额度</a>
<?php if($record['binding_id'] > 0):?>
<a href="javascript:;" style="color: #f56c6c" class="unbind-btn">解绑角色</a>
<?php endif;?>
</td>
</tr>
</volist>
</empty>
@ -216,6 +225,21 @@
</div>
</form>
</div>
<div id="other-quota-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="">
<div class="form-group">
<label>额外额度</label>
<div class="form-item" style="width: 280px;">
<input type="text" class="form-input" name="other_quota" value="" style="width:250px">
</div>
</div>
<div class="form-group">
<label></label>
<a id="quota-submit" href="javascript:;" class="add-submit btn">确定</a>
</div>
</form>
</div>
</block>
<block name="script">
@ -282,7 +306,73 @@
area: ['700px', '380px'],
zIndex: 250,
})
});
})
$('.set-quota-btn').click(function () {
var box = $('#other-quota-box')
var tr = $(this).parents('tr').eq(0)
var id = tr.attr('data-id')
var otherQuota = tr.attr('data-other-quota')
box.find('[name=id]').val(id)
box.find('[name=other_quota]').val(otherQuota)
layer.open({
title: '设置额外额度',
type: 1,
content: box,
area: ['500px', '200px'],
zIndex: 250,
})
})
$('#quota-submit').on({
click: function() {
var box = $('#other-quota-box')
var id = box.find('[name=id]').val()
var otherQuota = box.find('[name=other_quota]').val()
$.ajax({
url: "{:U('setOtherQuota')}",
type: "POST",
dataType: "json",
data: { id: id, other_quota: otherQuota },
success: function (result) {
if (result.status == 0) {
layer.msg(result.message);
} else {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
}
},
error: function () {
}
})
}
})
$('.unbind-btn').click(function () {
var tr = $(this).parents('tr').eq(0)
var bindingId = tr.attr('data-binding-id')
layer.confirm('确定要解绑吗?', {
// closeBtn:0,
title: '解绑',
btn: ['确定'] //按钮
}, function(){
$.ajax({
async: false,
url: "{:U('unbindRole')}",
type: "POST",
dataType: "json",
data: { binding_id: bindingId },
success: function (result) {
if (result.status == 0) {
layer.msg(result.message);
} else {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
}
}
})
})
})
$('#add-submit').on({
click: function () {
var box = $('#add-box')
@ -309,7 +399,7 @@
error: function () {
}
});
})
}
})

@ -20,6 +20,15 @@ html {
body {
padding: 0px;
}
.data_list table td .status-0 {
color: #e6a23c;
}
.data_list table td .status-1 {
color: #67c23a;
}
.data_list table td .status-2 {
color: #f56c6c;
}
</style>
<body>
<div id="main" class="main" style="min-height: 342px;">

@ -16,9 +16,17 @@ class GameRepository
return $baseGames;
}
public function getBaseGameByGameId($gameId)
public function getBaseGameByGameId($gameId, array $baseGames = null)
{
return M('base_game', 'tab_')->where('android_game_id=' . $gameId . ' or ios_game_id=' . $gameId)->find();
if (is_null($baseGames)) {
return M('base_game', 'tab_')->where('android_game_id=' . $gameId . ' or ios_game_id=' . $gameId)->find();
}
foreach ($baseGames as $baseGame) {
if ($baseGame['android_game_id'] == $gameId || $baseGame['ios_game_id'] == $gameId) {
return $baseGame;
}
}
return null;
}
public function getChoiceGames(array $visibleGameIds = null, $fields = ['id', 'game_name'])
@ -40,6 +48,7 @@ class GameRepository
$map = [];
$map['game_id'] = $gameId;
return M('server', 'tab_')
->field($fields)
->where($map)
->order('server_id asc')
->select();

@ -290,6 +290,7 @@ class TestingResourceRepository
$spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $item['amount'];
}
}
$gameSettings = $this->getGameSettings();
return [
'users' => $users,
'spendItems' => $spendItems,
@ -299,6 +300,7 @@ class TestingResourceRepository
'provideRecords' => $provideRecords,
'verifyRecords' => $verifyRecords,
'todayProvideRecords' => $todayProvideRecords,
'gameSettings' => $gameSettings,
];
}
@ -307,6 +309,7 @@ class TestingResourceRepository
$result = $this->statByRoles($roles);
$users = $result['users'];
$spendItems = $result['spendItems'];
$gameSettings = $result['gameSettings'];
$bindings = $result['bindings'];
$bindingRoles = $result['bindingRoles'];
$applyRecords = $result['applyRecords'];
@ -314,6 +317,10 @@ class TestingResourceRepository
$verifyRecords = $result['verifyRecords'];
$todayProvideRecords = $result['todayProvideRecords'];
$gameSettings = index_by_column('base_game_id', $gameSettings);
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$records = [];
foreach ($roles as $role) {
$user = $users[$role['user_id']] ?? null;
@ -323,7 +330,15 @@ class TestingResourceRepository
$bindGameRoleId = $this->getGameRoleId($binding['game_id'], $binding['bind_role_id']);
$bindingRole = $bindingRoles[$bindGameRoleId] ? $bindingRoles[$bindGameRoleId] : null;
}
$gameSetting = $this->getGameSettingByGameId($role['game_id']);
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
$gameSetting = null;
if ($baseGame && isset($gameSettings[$baseGame['id']])) {
$gameSetting = $gameSettings[$baseGame['id']];
}
$spendQuota = $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0;
$quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0;
$records[] = [
'id' => $role['id'],
'game_name' => $role['game_name'],
@ -333,11 +348,12 @@ class TestingResourceRepository
'user_account' => $role['user_account'],
'user_phone' => $user ? $user['phone'] : '',
'role_name' => $role['role_name'],
'binding_id' => $binding ? $binding['id'] : 0,
'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '',
'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '',
'base_quota' => $gameSetting ? $gameSetting['base_quota'] : 0,
'other_quota' => $role['testing_other_quota'],
'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0,
'quota' => $quota,
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
'today_amount' => $todayProvideRecords[$role['game_role_id']] ?? 0,
@ -411,7 +427,6 @@ class TestingResourceRepository
$conditions['role_name'] = ['like', $roleName . '%'];
}
$conditions['_string'] = $strCondition;
return M('user_play_info', 'tab_')->where($conditions)->order('create_time desc');
}
}

@ -25,12 +25,11 @@ class TestingResourceService
$batchData['verify_time'] = time();
$batchData['update_time'] = time();
if (!in_array($batch['game_id'], [229, 230])) {
$gameIds = $this->repository->getHadSettingGameIds();
if (!in_array($batch['game_id'], $gameIds)) {
$batchData['verify_status'] = 2;
$batchData['verify_remark'] = '该游戏发放功能暂未实现';
$batchData['verify_remark'] = '该游戏暂不支持资源申请!';
M('testing_resource_batch', 'tab_')->where(['id' => $batch['id']])->save($batchData);
throw new \Exception('该游戏发放功能暂未实现');
}
@ -39,6 +38,45 @@ class TestingResourceService
M('testing_resource_batch', 'tab_')->where(['id' => $batch['id']])->save($batchData);
}
public function verifyRefuse($batch, $remark = '审核拒绝')
{
if ($batch['verify_status'] != 0) {
throw new \Exception('审核状态异常');
}
$batchData = [];
$batchData['verify_time'] = time();
$batchData['update_time'] = time();
$batchData['verify_status'] = 2;
$batchData['verify_remark'] = $remark;
M('testing_resource_batch', 'tab_')->where(['id' => $batch['id']])->save($batchData);
}
public function provideRefuse($batch, $remark = '发放失败')
{
if ($batch['verify_status'] != 1) {
throw new \Exception('该申请未审核通过');
}
if ($batch['provide_status'] != 0) {
throw new \Exception('发放状态异常');
}
M('testing_resource_order', 'tab_')
->where(['batch_id' => $batch['id']])
->save([
'provide_status' => 2,
'provide_time' => time(),
]);
M('testing_resource_batch', 'tab_')
->where(['id' => $batch['id']])
->save([
'provide_status' => 2,
'provide_time' => time(),
'update_time' => time()
]);
}
public function provide($batch)
{
if ($batch['verify_status'] != 1) {
@ -49,6 +87,10 @@ class TestingResourceService
throw new \Exception('发放状态异常');
}
$gameSetting = $this->repository->getGameSettingByGameId($batch['game_id']);
if (is_null($gameSetting)) {
throw new \Exception('该游戏不支持发放测试资源');
}
$role = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version'])
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
@ -60,17 +102,22 @@ class TestingResourceService
$hasError = false;
$provideAmount = 0;
foreach ($orders as $order) {
$result = $this->provideFromGameCat($order, $role);
$orderData = [
'result' => json_encode(['code' => $result['code'], 'message' => $result['message']]),
];
if (!$result['status']) {
$hasError = true;
$orderData['provide_status'] = 2;
$orderData = [];
if ($gameSetting['has_itf'] == 1) {
$result = $this->provideFromGameCat($order, $role);
$orderData = [
'result' => json_encode(['code' => $result['code'], 'message' => $result['message']]),
];
if (!$result['status']) {
$hasError = true;
$orderData['provide_status'] = 2;
} else {
$orderData['provide_status'] = 1;
}
} else {
$orderData['provide_status'] = 1;
}
$provideAmount += round($order['ref_amount'] * $order['num'], 2);
$provideAmount += $order['amount'];
$orderData['provide_time'] = time();
M('testing_resource_order', 'tab_')
->where(['id' => $order['id']])
@ -131,10 +178,11 @@ class TestingResourceService
$totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0);
if (!is_null($bindRole)) {
$totalQuota += M('spend', 'tab_')
$spendQuota += M('spend', 'tab_')
->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id'], 'pay_status' => 1])
->group('game_id,game_player_id')
->sum('pay_amount');
$totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2);
}
$providedQuota = M('testing_resource_batch', 'tab_')
->where(['provide_status' => [in, [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']])
@ -159,7 +207,7 @@ class TestingResourceService
$strCondition = '1=1';
if ($promote) {
$promoteService = new PromoteService();
$strCondition = ' and promote_id in (' . $promoteService->subInSql($promote) . ')';
$strCondition .= ' and promote_id in (' . $promoteService->subInSql($promote) . ')';
}
$users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts], '_string' => $strCondition])->select();
@ -214,7 +262,7 @@ class TestingResourceService
}
}
public function bindRole($params, $promote)
public function bindRole($params, $promote = null)
{
$gameId = $params['game_id'] ?? 0;
$testingRoleId = $params['testing_role_id'] ?? '';
@ -238,7 +286,7 @@ class TestingResourceService
$promoteService = new PromoteService();
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $testingRole['promote_id']])->find();
if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $promote)) {
if (is_null($testPromote) || ($promote && !$promoteService->isSubOrSelf($testPromote, $promote))) {
throw new \Exception('测试角色所属推广员异常');
}
@ -251,7 +299,7 @@ class TestingResourceService
}
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindRole['promote_id']])->find();
if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $promote)) {
if (is_null($bindPromote) || ($promote && !$promoteService->isSubOrSelf($bindPromote, $promote))) {
throw new \Exception('玩家账号所属推广员异常');
}
@ -288,6 +336,11 @@ class TestingResourceService
}
}
public function unbindRole($bindingId)
{
return M('testing_binding', 'tab_')->where(['id' => $bindingId])->delete();
}
public function apply($params, $promote = null)
{
$gameId = $params['game_id'] ?? 0;
@ -305,8 +358,11 @@ class TestingResourceService
$resources = $this->getGameCatResources('android');
} elseif ($gameId == 230) {
$resources = $this->getGameCatResources('ios');
} else {
throw new \Exception('该游戏不可申请资源');
}
$gameSetting = $this->repository->getGameSettingByGameId($gameId);
if (is_null($gameSetting)) {
throw new \Exception('该游戏不支持发放测试资源');
}
$binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find();
@ -374,7 +430,7 @@ class TestingResourceService
} */
}
$hasItf = false;
$hasItf = ($gameSetting['has_itf'] == 1);
$amount = 0;
if ($hasItf) {
foreach ($records as $key => $record) {
@ -404,9 +460,8 @@ class TestingResourceService
$amount += $record['amount'];
}
}
$testingResourceService = new TestingResourceService();
$remainQuota = $testingResourceService->getRemainQuota($role, $bindingRole);
$remainQuota = $this->getRemainQuota($role, $bindingRole);
if ($amount > $remainQuota) {
throw new \Exception('额度不足');
}
@ -453,6 +508,36 @@ class TestingResourceService
}
}
public function getResourceTypes($gameId)
{
$resourceTypes = [];
/**
* @todo 目前固定游戏猫
*/
if ($gameId == 229) {
$resourceTypes[] = ['id' => 1, 'name' => '通用'];
} elseif ($gameId == 230) {
$resourceTypes[] = ['id' => 2, 'name' => '通用'];
}
return $resourceTypes;
}
public function getResources($typeId)
{
$resources = [];
/**
* @todo 目前固定游戏猫资源类型ID
*/
if ($typeId == 2) {
$resources = $this->getGameCatResources('ios');
} elseif ($typeId == 1) {
$resources = $this->getGameCatResources('andriod');
}
return $resources;
}
private function getGameCatResources($deviceType)
{
$resources = [];

@ -14,14 +14,10 @@ use Base\Repository\GameRepository;
class TestingResourceController extends BaseController
{
private $gameBaseQuota = [
229 => 300,
230 => 300,
];
public function index()
{
$params = I('get.');
$gameId = $params['game_id'] ?? 0;
$loginPromote = $this->getLoginPromote();
$repository = new TestingResourceRepository();
@ -40,11 +36,6 @@ class TestingResourceController extends BaseController
$this->display();
}
private function getGameRoleId($gameId, $roleId)
{
return $gameId . '#' . $roleId;
}
public function addTestingUsers()
{
$loginPromote = $this->getLoginPromote();
@ -63,6 +54,8 @@ class TestingResourceController extends BaseController
public function batches()
{
$params = I('get.');
$gameId = $params['game_id'] ?? 0;
$loginPromote = $this->getLoginPromote();
$repository = new TestingResourceRepository();
$query = $repository->getBatchesQuery($params, $loginPromote);
@ -99,7 +92,7 @@ class TestingResourceController extends BaseController
$query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc');
list($orders, $pagination, $count) = $this->paginate($query);
$testingResourceService = new TestingResourceService();
$repository = new TestingResourceRepository();
foreach ($orders as $order) {
$records[] = [
'id' => $order['id'],
@ -116,7 +109,7 @@ class TestingResourceController extends BaseController
'amount' => $order['num'] * $order['ref_amount'],
'remark' => $order['remark'],
'provide_status' => $order['provide_status'],
'provide_status_text' => $testingResourceService->getProvideStatusText($order['provide_status']),
'provide_status_text' => $repository->getProvideStatusText($order['provide_status']),
];
}
@ -138,6 +131,8 @@ class TestingResourceController extends BaseController
->find();
}
$hasItf = 0;
$servers = [];
$bindingRole = null;
if ($role) {
@ -149,15 +144,18 @@ class TestingResourceController extends BaseController
->where(['game_id' => $binding['game_id'], 'role_id' => $binding['bind_role_id']])
->find();
}
$repository = new TestingResourceRepository();
$gameSetting = $repository->getGameSettingByGameId($role['game_id']);
$hasItf = $gameSetting ? $gameSetting['has_itf'] : 0;
}
$testingResourceService = new TestingResourceService();
$quota = $testingResourceService->getRemainQuota($role, $bindingRole);
$this->assign('hasItf', $hasItf);
$games = M('game', 'tab_')->field(['id' , 'game_name'])->select();
/**
* @todo 目前固定游戏猫
*/
$games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select();
$this->assign('games', $games);
$this->assign('servers', $servers);
$this->assign('bindingRole', $bindingRole);
@ -204,34 +202,16 @@ class TestingResourceController extends BaseController
public function getResourceTypes()
{
$gameId = I('game_id', 0);
$resourceTypes = [];
/**
* @todo 目前固定游戏猫
*/
if ($gameId == 229) {
$resourceTypes[] = ['id' => 1, 'name' => '通用'];
} elseif ($gameId == 230) {
$resourceTypes[] = ['id' => 2, 'name' => '通用'];
}
$testingResourceService = new TestingResourceService();
$resourceTypes = $testingResourceService->getResourceTypes($gameId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
}
public function getResources()
{
$typeId = I('type_id', 0);
$resources = [];
/**
* @todo 目前固定游戏猫资源类型ID
*/
if ($typeId == 2) {
$resources = $this->getGameCatResources('ios');
} elseif ($typeId == 1) {
$resources = $this->getGameCatResources('andriod');
}
$testingResourceService = new TestingResourceService();
$resources = $testingResourceService->getResources($typeId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
}
@ -259,22 +239,4 @@ class TestingResourceController extends BaseController
->select();
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]);
}
private function getGameCatResources($deviceType)
{
$resources = [];
$gameCatClient = new GameCatClient();
$result = $gameCatClient->api('get-pay-type', ['device_type' => $deviceType]);
if ($result['state'] == 1) {
$items = $result['data'];
foreach ($items as $item) {
$resources[$item['supportItem']] = [
'ref_id' => $item['supportItem'],
'name' => $item['content'],
'amount' => $item['amount'],
];
}
}
return $resources;
}
}

@ -70,7 +70,7 @@
margin-top: 10px;
}
.info-row button {
width: 120px;
width: auto;
height: 25px;
display: block;
background: #E5E5E5;
@ -240,6 +240,7 @@
<script type="text/javascript">
$(".select_gallery").select2()
var globalGameId = $('#game-select').val()
var hasItf = $('#hasItf').val()
if (globalGameId > 0) {
initTable(globalGameId)
}
@ -274,6 +275,9 @@
function initTable(gameId) {
var table = $('#resource-table');
table.find('.normal-row').remove()
if (hasItf != 1) {
return;
}
$.ajax({
url: "{:U('getResourceTypes')}",
type: "post",
@ -422,6 +426,13 @@
statQuota()
}
})
$('#resource-table').on('blur', 'input[name=amount]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
statQuota()
}
})
function statQuota() {
var quota = $('#quota').attr('data-quota')
var hasItf = $('#hasItf').val()

Loading…
Cancel
Save