master
elf 3 years ago
parent 6b7276c344
commit 7906e1b5c6

@ -674,4 +674,28 @@ class AjaxController extends ThinkController{
$admins = getMarketAdmin($departmentId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['admins' => $admins]]);
}
public function searchRoleInfo()
{
$baseGameId = I('base_game_id', 0);
$roleId = I('role_id', '');
$baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
if (!$baseGame) {
return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在', 'data' => []]);
}
$gameIds = [$baseGame['android_game_id'] , $baseGame['ios_game_id']];
$role = M('user_play_info', 'tab_')->where(['game_id' => ['in', $gameIds], 'role_id' => $roleId])->order('play_time', 'desc')->limit(1)->find();
if (!$role) {
return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在', 'data' => []]);
}
$payAmount = M('spend', 'tab_')->where(['game_id' => ['in', $gameIds], 'game_player_id' => $roleId, 'pay_status' => 1, 'user_id' => $role['user_id']])->sum('pay_amount');
$payAmount = floatval($payAmount);
return $this->ajaxReturn([
'status' => 1,
'message' => '获取成功',
'data' => ['server_name' => $role['server_name'], 'role_name' => $role['role_name'], 'pay_amount' => $payAmount]
]);
}
}

@ -124,18 +124,16 @@ class GameRebateController extends ThinkController
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
}
public function simulateSpendList()
private function simulateSpendQuery($params)
{
$params = I('get.');
$isExport = $params['is_export'] ?? 0;
$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'] ?? '';
$reviewStatus = $params['review_status'] ?? -1;
$sendStatus = $params['send_status'] ?? -1;
$status = $params['status'] ?? -1;
$reviewerId = $params['reviewer_id'] ?? 0;
$reviewType = $params['review_type'] ?? -1;
@ -154,11 +152,8 @@ class GameRebateController extends ThinkController
if ($serverId != '') {
$where['server_id'] = $serverId;
}
if ($reviewStatus != -1) {
$where['review_status'] = $reviewStatus;
}
if ($sendStatus != -1) {
$where['send_status'] = $sendStatus;
if ($status != -1) {
$where['status'] = $status;
}
if ($reviewerId != 0) {
$where['reviewer_id'] = $reviewerId;
@ -199,21 +194,57 @@ class GameRebateController extends ThinkController
$records = $query->order('create_time desc')->page($page, $limit)->select();
$count = $countQuery->count();
}
return [$records, $count];
}
if (count($records) > 0) {
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(false);
$payAmountItems = [];
foreach ($items as $item) {
$payAmountItems[$item['game_player_id']] = $item['amount'];
}
foreach ($records as $key => $record) {
$user = $users[$record['user_id']];
$payAmount = 0; /** @todo */
$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'] = $this->reviewStatusList[$record['status']];
$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']) : '--';
}
@ -255,8 +286,9 @@ class GameRebateController extends ThinkController
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
$this->assign('admins', $admins);
$this->assign('baseGames', $baseGames);
$this->assign('reviewStatusList', []);
$this->assign('statusList', $statusList);
$this->assign('records', $records);
$this->assign('error', $error);
$this->display('simulateSpendList');
}

@ -131,7 +131,7 @@ body {
width: 280px;
}
.form-group select {
width: 280px;
width: 290px;
}
.form-group textarea {
padding: 5px;
@ -163,54 +163,41 @@ body {
<select id="game-select" name="" class="select_gallery" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择游戏</option>
<?php foreach($baseGames as $game):?>
<option value="<?=$game['id']?>" <?php if($role && $role['game_id'] == $game['id']):?>selected<?php endif;?>>
<option value="<?=$game['id']?>">
<?=$game['name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group">
<label>区服</label>
<select id="server-select" class="select_gallery" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择区服</option>
<?php foreach($servers as $server):?>
<option value="<?=$server['id']?>" <?php if($role && $server['server_id'] == $role['server_id']):?>selected<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
<label>角色ID</label>
<input type="text" id="role-id" name="role_id" class="txt normal_txt" placeholder="请输入角色ID" value="" style="width: 205px;">
<button id="search-role-btn" class="add-row" type="button">查询</button>
</div>
<div class="form-group">
<label>角色</label>
<select id="role-select" name="role_id" class="select_gallery" <?php if($role):?>disabled<?php endif;?>>
<option value="">请选择角色</option>
<?php if($role):?>
<option value="<?=$role['role_id']?>" selected><?=$role['role_name']?></option>
<?php endif;?>
</select>
<label>角色区服</label>
<p id="server-name" class="static-input">--</p>
</div>
</div>
<div class="clearfix" style="margin-top: 10px;">
<div class="form-group">
<label>角色名称</label>
<p class="static-input">角色名称: --</p>
<p id="role-name" class="static-input">--</p>
</div>
<div class="form-group">
<label>当前累充</label>
<p class="static-input">当前累充: --</p>
<p id="pay-amount" class="static-input">--</p>
</div>
<div class="form-group">
<label>模拟发放金额</label>
<input type="text" name="amount" class="txt normal_txt" placeholder="请输入模拟发放金额" value="">
<input type="text" id="amount" name="amount" class="txt normal_txt" placeholder="请输入模拟发放金额" value="">
</div>
<div class="form-group">
<label>备注</label>
<textarea name="remark" class="txt normal_txt" style="width: 280px;" rows="10" placeholder="请输入备注"></textarea>
<textarea id="remark" name="remark" class="txt normal_txt" style="width: 280px;" rows="10" placeholder="请输入备注"></textarea>
<!-- <input type="text" name="remark" class="txt normal_txt" placeholder="请输入备注" value=""> -->
</div>
<div class="form-group">
<label></label>
<button id="add-row" class="add-row" type="button">增加</button>
<button id="submit-btn" class="add-row" type="button">增加</button>
</div>
</div>
</form>
@ -221,123 +208,6 @@ body {
<script type="text/javascript">
$(".select_gallery").select2()
var globalGameId = $('#game-select').val()
var hasItf = $('#hasItf').val()
if (globalGameId > 0) {
initTable(globalGameId)
}
$('#game-select').on({
change: function () {
var gameId = $(this).val()
globalGameId = gameId
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var servers = result.data.servers
var html = "<option value='0'>请选择区服</option>";
for (var i in servers){
html += "<option value='"+servers[i].id+"'>"+servers[i].server_name+"</option>"
}
$("#server-select").html(html);
$("#server-select").select2();
} else {
}
}
})
initTable(gameId)
}
})
var resourceTypes = new Array()
var rowCount = 0
function initTable(gameId) {
var table = $('#resource-table');
table.find('.normal-row').remove()
if (hasItf != 1) {
return;
}
$.ajax({
url: "{:U('getResourceTypes')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
rowCount = 0
resourceTypes = result.data.resourceTypes
var selector = $('#resource-type-select')
var html = getResourceTypesHtml()
selector.html(html)
selector.select2();
var resourceSelector = $('#resource-select')
resourceSelector.html(getResourcesHtml([]))
resourceSelector.select2();
$('#resource-amount').html('资源价值:--')
$('#resource-table tbody').html('')
} else {
}
}
})
}
function getResourceTypesHtml() {
var html = "<option value=''>请选择资源类型</option>";
for (var i in resourceTypes) {
html += "<option value='"+resourceTypes[i].id+"'>"+resourceTypes[i].name+"</option>"
}
return html
}
$('#resource-type-select').change(function () {
var that = this
var typeId = $(this).val()
$.ajax({
url: "{:U('getResources')}",
type: "post",
data: { game_id: globalGameId, type_id: typeId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var resources = result.data.resources
var html = getResourcesHtml(resources)
var rowSelect = $('#resource-select')
rowSelect.html(html);
rowSelect.select2();
} else {
}
}
})
})
function getResourcesHtml(resources) {
var html = "<option value=''>请选择资源内容</option>";
for (var i in resources){
html += "<option value='"+resources[i].ref_id+"' data-amount="+resources[i].amount+">"+resources[i].name+"</option>"
}
return html
}
$('#resource-select').change(function () {
var amount = $(this).find('option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
$('#resource-amount').html('资源价值:' + amount)
})
$('#add-row').click(function () {
if (rowCount >= 5) {
return layer.msg('最多同时只能添加5条')
}
var hasItf = $('#hasItf').val()
if (hasItf == 1) {
addRowItf()
} else {
addRow()
}
})
function isFloat(num){
if(!num) {
@ -369,181 +239,6 @@ body {
return true
}
function addRow() {
var remark = $('#remark-input').val()
var amount = $('#remark-amount').val()
if (remark == '') {
return layer.msg('请输入资源备注')
}
if (amount == '') {
return layer.msg('请输入资源价值')
}
if (!isNumber(amount)) {
return layer.msg('资源价值只能为正整数')
}
var html = '<tr class="normal-row" >' +
'<td style="width:420px" class="remark"><input name="remark" type="text" style="width:400px" value="' + remark + '"></td>' +
'<td class="amount"><input name="amount" type="text" value="' + amount + '"></td>' +
'<td><button class="delete-row" type="button" class="danger-btn">删除</button></td>' +
'</tr>';
$('#resource-table tbody').append(html)
rowCount ++
$(".select_gallery").select2()
statQuota()
}
function addRowItf() {
var resourceTypeId = $('#resource-type-select').val()
var resourceId = $('#resource-select').val()
var resourceTypeName = $('#resource-type-select option:selected').html()
var resourceName = $('#resource-select option:selected').html()
var amount = $('#resource-select option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
// var num = $('#num-input').val()
var num = 1
var remark = $('#remark-input').val()
if (resourceTypeId == '') {
return layer.msg('请选择资源类型')
}
if (resourceId == '') {
return layer.msg('请选择资源内容')
}
if (num == '') {
return layer.msg('请输入资源数量')
}
if (!isNumber(num)) {
return layer.msg('资源数量只能为正整数')
}
var html = '<tr class="normal-row" data-resource-id="' + resourceId + '" data-resource-type-id="' + resourceTypeId + '" >' +
'<td>' + resourceTypeName + '</td>' +
'<td>' + resourceName + '</td>' +
'<td class="amount">' + amount + '</td>' +
'<td class="num"><input name="num" type="text" value="' + num + '" readonly></td>' +
'<td class="remark"><input name="remark" type="text" value="' + remark + '"></td>' +
'<td><button class="delete-row" type="button" class="danger-btn">删除</button></td>' +
'</tr>';
$('#resource-table tbody').append(html)
rowCount ++
$(".select_gallery").select2()
statQuota()
}
$('#resource-table').on('click', '.delete-row', function () {
var tr = $(this).parents('tr').eq(0)
rowCount --
tr.remove()
statQuota()
})
$('#resource-table').on('blur', 'input[name=num]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
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()
var verifyQuota = 0
if (hasItf == 1) {
$('#resource-table').find('.normal-row').each(function (index, ele) {
verifyQuota += $(ele).find('.amount').html() * $(ele).find('.num').children('input').val()
})
} else {
$('#resource-table').find('.normal-row').each(function (index, ele) {
verifyQuota += parseInt($(ele).find('.amount').children('input').val())
})
}
$('#verify-quota').html(verifyQuota)
$('#quota').html(quota-verifyQuota)
}
function getUserRoles(bindRoleId, gameId, callback) {
$.ajax({
url: "{:U('getUserRoles')}",
type: "post",
data: { role_id: bindRoleId, game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var roles = result.data.roles
callback(roles)
} else {
layer.msg(result.message)
}
}
})
}
$('#bind_role_id').on({
blur: function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var serverId = $('#server-select').val()
if (serverId == 0) {
return layer.msg('请选择区服')
}
var bindRoleId = $('#bind_role_id').val()
if (bindRoleId == '') {
return layer.msg('请输入角色ID')
}
getUserRoles(bindRoleId, gameId, function(roles) {
if (roles.length == 0) {
return layer.msg('未查询到角色')
}
var html = "<option value=''>请选择角色</option>";
for (var i in roles){
html += "<option value='"+roles[i].role_id+"'>"+roles[i].role_name+"</option>"
}
$("#bind-role-select").html(html);
$("#bind-role-select").select2();
})
}
})
function getRecords() {
var records = []
var hasItf = $('#hasItf').val()
if (hasItf == 1) {
$('#resource-table tbody tr').each(function (index, tr) {
var num = $(tr).find('input[name=num]').val()
var remark = $(tr).find('input[name=remark]').val()
var resourceId = $(tr).attr('data-resource-id')
var resourceTypeId = $(tr).attr('data-resource-type-id')
records.push({
resource_id: resourceId,
resource_type_id: resourceTypeId,
num: num,
remark: remark,
})
})
} else {
$('#resource-table tbody tr').each(function (index, tr) {
var amount = $(tr).find('input[name=amount]').val()
var remark = $(tr).find('input[name=remark]').val()
records.push({
amount: amount,
remark: remark,
})
})
}
return records
}
$('#bind-btn').click(function () {
var box = $('#bind-box')
layer.open({
@ -556,77 +251,68 @@ body {
})
});
$('#submit-bind').click(function () {
$('#search-role-btn').click(function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var roleId = $('#role-select').val()
if (roleId == 0) {
return layer.msg('请选择测试账号角色')
}
var bindRoleId = $('#bind-role-select').val()
if (bindRoleId == 0) {
return layer.msg('请选择玩家角色')
var roleId = $('#role-id').val()
if (roleId == '') {
return layer.msg('请输入角色ID')
}
$.ajax({
url: "{:U('bindRole')}",
type: "post",
data: { game_id: gameId, bind_role_id: bindRoleId, testing_role_id: roleId},
url: "{:U('Ajax/searchRoleInfo')}",
type: "get",
data: { base_game_id: gameId, role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
$('#role-name').html(result.data.role_name)
$('#server-name').html(result.data.server_name)
$('#pay-amount').html(result.data.pay_amount)
} else {
layer.msg(result.message)
$('#role-name').html('查询失败')
$('#server-name').html('查询失败')
$('#pay-amount').html('查询失败')
}
}
})
})
})
$('#submit-btn').on({
click: function () {
var records = getRecords()
if (records.length == 0) {
return layer.msg('至少添加一项资源申请')
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
for (var i in records) {
if (records[i].num == '') {
return layer.msg('请输入资源数量')
}
var roleId = $('#role-id').val()
if (roleId == '') {
return layer.msg('请输入角色ID')
}
var gameId = $('#game-select').val()
var serverId = $('#server-select').val()
var userAccount = $('#test_account').val()
var roleId = $('#role-select').val()
var amount = $('#amount').val()
var remark = $('#remark').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
if (serverId == 0) {
return layer.msg('请选择区服')
}
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
if (roleId == '') {
return layer.msg('请输入角色ID')
}
if (roleId == 0) {
return layer.msg('请选择角色')
if (amount == '') {
return layer.msg('请输入模拟发放金额')
}
$.ajax({
url: "{:U('doApply')}",
url: "{:U('saveSimulateSpend')}",
type: "post",
data: { records: records, game_id: gameId, server_id: serverId, user_account: userAccount, role_id: roleId},
data: { base_game_id: gameId, amount: amount, remark: remark, role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
parent.window.location.href = "{:U('roles')}"
parent.window.location.href = parent.window.location.href
})
} else {
layer.msg(result.message)

@ -59,6 +59,46 @@
.data_list table td .status-2 {
color: #f56c6c;
}
.tooltip {
position: relative;
display: inline-block;
color: #056dae;
}
.tooltip .tooltiptext {
visibility: hidden;
width: auto;
min-width: 50px;
background-color: #fff;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 10px 10px;
position: absolute;
z-index: 1;
right: 80%;
top: 0;
margin-bottom: 70%;
border: #000 solid 1px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
left: 100%;
top: 20px;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent transparent black;
}
.tooltip:hover .tooltiptext {
color: #000;
visibility: visible;
line-height: 20px;
}
</style>
</block>
<block name="body">
@ -106,11 +146,11 @@
</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="订单生成开始时间"/>
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="订单生成结束时间"/>
placeholder="添加结束时间"/>
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
@ -125,19 +165,9 @@
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="review_status" class="select_gallery" style="width:120px;">
<select name="status" class="select_gallery" style="width:120px;">
<option value="-1">请选择审核状态</option>
<?php foreach($reviewStatusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="send_status" class="select_gallery" style="width:120px;">
<option value="-1">请选择发放状态</option>
<?php foreach($sendStatusList as $key => $name):?>
<?php foreach($statusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
@ -202,7 +232,11 @@
<!-- 列表 -->
<tbody>
<empty name ="records">
<?php if ($error):?>
<td colspan="99" class="text-center"><?=$error?></td>
<?php else:?>
<td colspan="99" class="text-center">aOh! 暂时还没有内容!</td>
<?php endif;?>
<else />
<volist name="records" id="data">
<tr data-id="<?=$data['id']?>">
@ -231,6 +265,7 @@
</td>
<td>{$data.review_time}</td>
<td>{$data.reviewer_username}</td>
<td><div class="tooltip"><span style="color: red">查看</span><span class="tooltiptext"><span style="margin-left: -10px">{$data.remark}</span></span></div></td>
</tr>
</volist>
</empty>

Loading…
Cancel
Save