master
ELF 4 years ago
parent 2690db95ab
commit 8dee426c5f

@ -9,6 +9,7 @@ use Base\Service\TestingResourceService;
use Base\Service\PartnerService; use Base\Service\PartnerService;
use Base\Repository\TestingResourceRepository; use Base\Repository\TestingResourceRepository;
use Base\Repository\GameRepository; use Base\Repository\GameRepository;
use Base\Service\GameService;
class TestingResourceController extends ThinkController class TestingResourceController extends ThinkController
{ {
@ -439,11 +440,21 @@ class TestingResourceController extends ThinkController
$bindingRole = null; $bindingRole = null;
if ($role) { if ($role) {
$servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select(); $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select();
$game = M('game', 'tab_')->where(['id' => $role['game_id']])->find(['id', 'data_share']);
$binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find();
if ($binding) { if ($binding) {
$gameIds = [$role['game_id']];
if ($game['data_share'] == 1) {
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
$bindingRole = M('user_play_info', 'tab_') $bindingRole = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name']) ->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']]) ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']])
->find(); ->find();
if ($bindingRole) { if ($bindingRole) {
$bindingRole['binding_time'] = $binding['create_time']; $bindingRole['binding_time'] = $binding['create_time'];
@ -577,31 +588,6 @@ class TestingResourceController extends ThinkController
return $this->ajaxReturn(['status' => 1, 'message' => '设置成功']); 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() public function getResourceTypes()
{ {
$gameId = I('game_id', 0); $gameId = I('game_id', 0);
@ -759,4 +745,33 @@ class TestingResourceController extends ThinkController
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
} }
} }
public function getUserRoles()
{
$gameId = I('game_id', 0);
$roleId = I('role_id', 0);
$game = M('game', 'tab_')->where(['id' => $gameId])->find();
if (is_null($game)) {
return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']);
}
$gameIds = [$gameId];
if ($game['data_share'] == 1) {
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames);
if (is_null($baseGame)) {
return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']);
}
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
$roles = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'role_name'])
->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]])
->select();
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]);
}
} }

@ -264,9 +264,9 @@ body {
<div id="bind-box" class="layer-box" style="display: none;"> <div id="bind-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<label>玩家账号</label> <label>角色ID</label>
<div class="form-item" style="width: 250px"> <div class="form-item" style="width: 250px">
<input id="bind_account" name="account" type="text" class="form-input" style="width: 100%;"> <input id="bind_role_id" name="bind_role_id" type="text" class="form-input" style="width: 100%;">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -535,48 +535,17 @@ body {
$('#verify-quota').html(verifyQuota) $('#verify-quota').html(verifyQuota)
$('#quota').html(quota-verifyQuota) $('#quota').html(quota-verifyQuota)
} }
$('#test_account').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 userAccount = $('#test_account').val()
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
}
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) {
if (roles.length == 0) {
return layer.msg('当前账号在该区服未创建角色')
}
if (!isTestingAccount) {
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>"
}
$("#role-select").html(html);
$("#role-select").select2();
})
}
})
function getUserRoles(userAccount, gameId, serverId, callback) { function getUserRoles(bindRoleId, gameId, callback) {
$.ajax({ $.ajax({
url: "{:U('getUserRoles')}", url: "{:U('getUserRoles')}",
type: "post", type: "post",
data: { user_account: userAccount, game_id: gameId, server_id: serverId }, data: { role_id: bindRoleId, game_id: gameId },
dataType: 'json', dataType: 'json',
success: function(result){ success: function(result){
if (result.status == 1) { if (result.status == 1) {
var roles = result.data.roles var roles = result.data.roles
var isTestingAccount = result.data.is_testing_account callback(roles)
callback(roles, isTestingAccount)
} else { } else {
layer.msg(result.message) layer.msg(result.message)
} }
@ -584,7 +553,7 @@ body {
}) })
} }
$('#bind_account').on({ $('#bind_role_id').on({
blur: function () { blur: function () {
var gameId = $('#game-select').val() var gameId = $('#game-select').val()
if (gameId == 0) { if (gameId == 0) {
@ -594,16 +563,13 @@ body {
if (serverId == 0) { if (serverId == 0) {
return layer.msg('请选择区服') return layer.msg('请选择区服')
} }
var userAccount = $('#bind_account').val() var bindRoleId = $('#bind_role_id').val()
if (userAccount == '') { if (bindRoleId == '') {
return layer.msg('请输入玩家账号') return layer.msg('请输入角色ID')
} }
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) { getUserRoles(bindRoleId, gameId, function(roles) {
if (roles.length == 0) { if (roles.length == 0) {
return layer.msg('玩家账号在该区服未创建角色') return layer.msg('未查询到角色')
}
if (isTestingAccount) {
return layer.msg('此账号为测试账号,无法绑定')
} }
var html = "<option value=''>请选择角色</option>"; var html = "<option value=''>请选择角色</option>";
for (var i in roles){ for (var i in roles){

@ -2,6 +2,7 @@
namespace Base\Repository; namespace Base\Repository;
use Base\Service\GameService;
use Base\Tool\Registry; use Base\Tool\Registry;
use Base\Service\PromoteService; use Base\Service\PromoteService;
@ -222,7 +223,7 @@ class TestingResourceRepository
'provide_status' => $batch['provide_status'], 'provide_status' => $batch['provide_status'],
'provide_status_text' => $this->getProvideStatusText($batch['provide_status']), 'provide_status_text' => $this->getProvideStatusText($batch['provide_status']),
'provide_time' => $batch['provide_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['provide_time']), 'provide_time' => $batch['provide_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['provide_time']),
'content' => $content, 'content' => '',
]; ];
} }
return $records; return $records;
@ -317,6 +318,7 @@ class TestingResourceRepository
foreach ($roles as $role) { foreach ($roles as $role) {
$bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')'; $bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')';
} }
$bindingOrWhereStr = '(' . implode(' or ', $bindingOrWhere) . ')';
$userIds = array_unique(array_column($roles, 'user_id')); $userIds = array_unique(array_column($roles, 'user_id'));
$users = []; $users = [];
@ -325,15 +327,30 @@ class TestingResourceRepository
$applyRecords = []; $applyRecords = [];
$testingUsers = []; $testingUsers = [];
if (count($roles) > 0) { if (count($roles) > 0) {
$games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($roles, 'game_id')]])->select();
$games = index_by_column('id', $games);
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select(); $testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select();
$testingUsers = index_by_column('user_id', $testingUsers); $testingUsers = index_by_column('user_id', $testingUsers);
$users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select(); $users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select();
$users = index_by_column('id', $users); $users = index_by_column('id', $users);
$bindingRows = M('testing_binding', 'tab_')->where(['_string' => implode(' or ', $bindingOrWhere)])->select(); $bindingRows = M('testing_binding', 'tab_')->where(['_string' => $bindingOrWhereStr])->select();
$bindingRoleIds = []; $bindingRoleIds = [];
foreach ($bindingRows as $bindingRow) { foreach ($bindingRows as $bindingRow) {
$bindings[$this->getGameRoleId($bindingRow['game_id'], $bindingRow['role_id'])] = $bindingRow; $bindings[$this->getGameRoleId($bindingRow['game_id'], $bindingRow['role_id'])] = $bindingRow;
$bindingRoleIds[] = $this->getGameRoleId($bindingRow['game_id'], $bindingRow['bind_role_id']); $bindingRoleIds[] = $this->getGameRoleId($bindingRow['game_id'], $bindingRow['bind_role_id']);
$game = $games[$bindingRow['game_id']];
$gameIds = [$bindingRow['game_id']];
if ($game['data_share'] == 1) {
$baseGame = $gameRepository->getBaseGameByGameId($bindingRow['game_id'], $baseGames);
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
foreach ($gameIds as $gameId) {
$bindingRoleIds[] = $this->getGameRoleId($gameId, $bindingRow['bind_role_id']);
}
} }
if (count($bindings) > 0) { if (count($bindings) > 0) {
$bindingRoles = M('user_play_info', 'tab_') $bindingRoles = M('user_play_info', 'tab_')
@ -347,7 +364,7 @@ class TestingResourceRepository
->field('sum(apply_amount) amount, game_id, role_id') ->field('sum(apply_amount) amount, game_id, role_id')
->where([ ->where([
'verify_status' => 0, 'verify_status' => 0,
'_string' => implode(' or ', $bindingOrWhere) '_string' => $bindingOrWhereStr,
]) ])
->group('game_id,role_id')->select(); ->group('game_id,role_id')->select();
$verifyRecords = []; $verifyRecords = [];
@ -359,7 +376,7 @@ class TestingResourceRepository
->field('sum(provide_amount) amount, game_id, role_id') ->field('sum(provide_amount) amount, game_id, role_id')
->where([ ->where([
'verify_status' => 1, 'verify_status' => 1,
'_string' => implode(' or ', $bindingOrWhere) '_string' => $bindingOrWhereStr,
]) ])
->group('game_id,role_id')->select(); ->group('game_id,role_id')->select();
$provideRecords = []; $provideRecords = [];
@ -371,9 +388,8 @@ class TestingResourceRepository
->field('sum(provide_amount) amount, game_id, role_id') ->field('sum(provide_amount) amount, game_id, role_id')
->where([ ->where([
'verify_status' => 1, 'verify_status' => 1,
'_string' => implode(' or ', $bindingOrWhere), '_string' => $bindingOrWhereStr,
'provide_time' => ['egt', strtotime(date('Y-m-d 00:00:00'))], 'provide_time' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]],
'provide_time' => ['elt', strtotime(date('Y-m-d 23:59:59'))],
]) ])
->group('game_id,role_id')->select(); ->group('game_id,role_id')->select();
$todayProvideRecords = []; $todayProvideRecords = [];
@ -384,7 +400,7 @@ class TestingResourceRepository
$applyItems = M('testing_resource_batch', 'tab_') $applyItems = M('testing_resource_batch', 'tab_')
->field('sum(apply_amount) amount, game_id, role_id') ->field('sum(apply_amount) amount, game_id, role_id')
->where([ ->where([
'_string' => implode(' or ', $bindingOrWhere), '_string' => $bindingOrWhereStr,
]) ])
->group('game_id,role_id')->select(); ->group('game_id,role_id')->select();
$applyRecords = []; $applyRecords = [];
@ -466,11 +482,19 @@ class TestingResourceRepository
$testingUser = $testingUsers[$role['user_id']] ?? null; $testingUser = $testingUsers[$role['user_id']] ?? null;
$binding = $bindings[$role['game_role_id']] ?? null; $binding = $bindings[$role['game_role_id']] ?? null;
$bindingRole = null; $bindingRole = null;
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
if ($binding) { if ($binding) {
$bindGameRoleId = $this->getGameRoleId($binding['game_id'], $binding['bind_role_id']); $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
$bindingRole = $bindingRoles[$bindGameRoleId] ? $bindingRoles[$bindGameRoleId] : null; foreach ($gameIds as $gameId) {
$bindGameRoleId = $this->getGameRoleId($gameId, $binding['bind_role_id']);
if (isset($bindingRoles[$bindGameRoleId])) {
$bindingRole = $bindingRoles[$bindGameRoleId];
break;
}
}
} }
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
$gameSetting = null; $gameSetting = null;
if ($baseGame && isset($gameSettings[$baseGame['id']])) { if ($baseGame && isset($gameSettings[$baseGame['id']])) {
$gameSetting = $gameSettings[$baseGame['id']]; $gameSetting = $gameSettings[$baseGame['id']];

@ -2,6 +2,7 @@
namespace Base\Service; namespace Base\Service;
use Base\Facade\Request; use Base\Facade\Request;
use Base\Repository\GameRepository;
use Base\Tool\GameResource; use Base\Tool\GameResource;
use Base\Repository\TestingResourceRepository; use Base\Repository\TestingResourceRepository;
use Base\Repository\SpendRepository; use Base\Repository\SpendRepository;
@ -167,17 +168,16 @@ class TestingResourceService
$spendRepository = new SpendRepository(); $spendRepository = new SpendRepository();
$spendMap = $spendRepository->withIsCheck($spendMap); $spendMap = $spendRepository->withIsCheck($spendMap);
$spendQuota += M('spend', 'tab_') $spendQuota = M('spend', 'tab_')
->where($spendMap) ->where($spendMap)
->group('game_id,game_player_id')
->sum('pay_amount'); ->sum('pay_amount');
$totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2); $totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2);
} }
$providedQuota = M('testing_resource_batch', 'tab_') $providedQuota = M('testing_resource_batch', 'tab_')
->where(['provide_status' => [in, [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->where(['provide_status' => ['in', [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']])
->sum('provide_amount'); ->sum('provide_amount');
$providingQuota = M('testing_resource_batch', 'tab_') $providingQuota = M('testing_resource_batch', 'tab_')
->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->where(['verify_status' => ['in', [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']])
->sum('apply_amount'); ->sum('apply_amount');
return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2); return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2);
} }
@ -300,9 +300,24 @@ class TestingResourceService
throw new \Exception('测试角色所属推广员异常'); throw new \Exception('测试角色所属推广员异常');
} }
$game = M('game', 'tab_')->where(['id' => $gameId])->find();
if (is_null($game)) {
throw new \Exception('游戏不存在');
}
$gameIds = [$gameId];
if ($game['data_share'] == 1) {
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames);
if (is_null($baseGame)) {
throw new \Exception('游戏不存在');
}
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
$bindRole = M('user_play_info', 'tab_') $bindRole = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'promote_id']) ->field(['id', 'role_id', 'user_id', 'promote_id'])
->where(['game_role_id' => $bindGameRoleId]) ->where(['role_id' => $bindRoleId, 'game_id' => ['in', $gameIds]])
->find(); ->find();
if (is_null($bindRole)) { if (is_null($bindRole)) {
throw new \Exception('玩家角色不存在'); throw new \Exception('玩家角色不存在');

@ -10,6 +10,7 @@ use Think\Model;
use Base\Service\TestingResourceService; use Base\Service\TestingResourceService;
use Base\Repository\TestingResourceRepository; use Base\Repository\TestingResourceRepository;
use Base\Repository\GameRepository; use Base\Repository\GameRepository;
use Base\Service\GameService;
class TestingResourceController extends BaseController class TestingResourceController extends BaseController
{ {
@ -135,11 +136,21 @@ class TestingResourceController extends BaseController
$bindingRole = null; $bindingRole = null;
if ($role) { if ($role) {
$servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select(); $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select();
$game = M('game', 'tab_')->where(['id' => $role['game_id']])->find(['id', 'data_share']);
$binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find();
if ($binding) { if ($binding) {
$gameIds = [$role['game_id']];
if ($game['data_share'] == 1) {
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
$bindingRole = M('user_play_info', 'tab_') $bindingRole = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name']) ->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']]) ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']])
->find(); ->find();
if ($bindingRole) { if ($bindingRole) {
$bindingRole['binding_time'] = $binding['create_time']; $bindingRole['binding_time'] = $binding['create_time'];
@ -230,25 +241,29 @@ class TestingResourceController extends BaseController
public function getUserRoles() public function getUserRoles()
{ {
$gameId = I('game_id', 0); $gameId = I('game_id', 0);
$serverId = I('server_id', 0); $roleId = I('role_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(); $game = M('game', 'tab_')->where(['id' => $gameId])->find();
if (is_null($user)) { if (is_null($game)) {
return $this->ajaxReturn(['status' => 0, 'message' => '账号不存在']); return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']);
} }
$testingUser = M('testing_user', 'tab_')->where(['user_account' => $userAccount])->find(); $gameIds = [$gameId];
$isTestingAccount = is_null($testingUser) ? false : true; if ($game['data_share'] == 1) {
$gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames();
$baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames);
if (is_null($baseGame)) {
return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']);
}
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
}
$roles = M('user_play_info', 'tab_') $roles = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'role_name']) ->field(['id', 'role_id', 'role_name'])
->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']]) ->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]])
->select(); ->select();
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]);
} }
} }

@ -216,9 +216,9 @@
<div id="bind-box" class="layer-box" style="display: none;"> <div id="bind-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<label>玩家账号</label> <label>角色ID</label>
<div class="form-item" style="width: 250px"> <div class="form-item" style="width: 250px">
<input id="bind_account" name="account" type="text" class="form-input" style="width: 100%;"> <input id="bind_role_id" name="bind_role_id" type="text" class="form-input" style="width: 100%;">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -488,7 +488,7 @@
$('#verify-quota').html(verifyQuota) $('#verify-quota').html(verifyQuota)
$('#quota').html(quota-verifyQuota) $('#quota').html(quota-verifyQuota)
} }
$('#test_account').on({ /* $('#test_account').on({
blur: function() { blur: function() {
var gameId = $('#game-select').val() var gameId = $('#game-select').val()
if (gameId == 0) { if (gameId == 0) {
@ -517,19 +517,18 @@
$("#role-select").select2(); $("#role-select").select2();
}) })
} }
}) }) */
function getUserRoles(userAccount, gameId, serverId, callback) { function getUserRoles(bindRoleId, gameId, callback) {
$.ajax({ $.ajax({
url: "{:U('getUserRoles')}", url: "{:U('getUserRoles')}",
type: "post", type: "post",
data: { user_account: userAccount, game_id: gameId, server_id: serverId }, data: { role_id: bindRoleId, game_id: gameId },
dataType: 'json', dataType: 'json',
success: function(result){ success: function(result){
if (result.status == 1) { if (result.status == 1) {
var roles = result.data.roles var roles = result.data.roles
var isTestingAccount = result.data.is_testing_account callback(roles)
callback(roles, isTestingAccount)
} else { } else {
layer.msg(result.message) layer.msg(result.message)
} }
@ -537,26 +536,19 @@
}) })
} }
$('#bind_account').on({ $('#bind_role_id').on({
blur: function () { blur: function () {
var gameId = $('#game-select').val() var gameId = $('#game-select').val()
if (gameId == 0) { if (gameId == 0) {
return layer.msg('请选择游戏') return layer.msg('请选择游戏')
} }
var serverId = $('#server-select').val() var bindRoleId = $('#bind_role_id').val()
if (serverId == 0) { if (bindRoleId == '') {
return layer.msg('请选择区服') return layer.msg('请输入角色ID')
}
var userAccount = $('#bind_account').val()
if (userAccount == '') {
return layer.msg('请输入玩家账号')
} }
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) { getUserRoles(bindRoleId, gameId, function(roles) {
if (roles.length == 0) { if (roles.length == 0) {
return layer.msg('玩家账号在该区服未创建角色') return layer.msg('未查询到角色')
}
if (isTestingAccount) {
return layer.msg('此账号为测试账号,无法绑定')
} }
var html = "<option value=''>请选择角色</option>"; var html = "<option value=''>请选择角色</option>";
for (var i in roles){ for (var i in roles){

Loading…
Cancel
Save