|
|
@ -12,6 +12,10 @@ use Base\Service\TestingResourceService;
|
|
|
|
|
|
|
|
|
|
|
|
class TestingResourceController extends BaseController
|
|
|
|
class TestingResourceController extends BaseController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private $gameBaseQuota = [
|
|
|
|
|
|
|
|
229 => 300,
|
|
|
|
|
|
|
|
230 => 300,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -180,8 +184,8 @@ class TestingResourceController extends BaseController
|
|
|
|
'role_name' => $role['role_name'],
|
|
|
|
'role_name' => $role['role_name'],
|
|
|
|
'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '',
|
|
|
|
'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '',
|
|
|
|
'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '',
|
|
|
|
'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '',
|
|
|
|
'base_quota' => $binding ? $binding['base_quota'] : 0,
|
|
|
|
'base_quota' => $this->gameBaseQuota[$role['game_id']] ?? 0,
|
|
|
|
'other_quota' => $binding ? $binding['other_quota'] : 0,
|
|
|
|
'other_quota' => $role['testing_other_quota'],
|
|
|
|
'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0,
|
|
|
|
'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0,
|
|
|
|
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
|
|
|
|
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
|
|
|
|
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
|
|
|
|
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
|
|
|
@ -346,7 +350,7 @@ class TestingResourceController extends BaseController
|
|
|
|
'user_phone' => $user ? $user['phone'] : '',
|
|
|
|
'user_phone' => $user ? $user['phone'] : '',
|
|
|
|
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
|
|
|
|
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
|
|
|
|
'promote_account' => $promote['account'],
|
|
|
|
'promote_account' => $promote['account'],
|
|
|
|
'history_provide_amount' => 0.00,
|
|
|
|
// 'history_provide_amount' => 0.00,
|
|
|
|
'apply_amount' => $batch['apply_amount'],
|
|
|
|
'apply_amount' => $batch['apply_amount'],
|
|
|
|
'provide_amount' => $batch['provide_amount'],
|
|
|
|
'provide_amount' => $batch['provide_amount'],
|
|
|
|
'verify_status' => $batch['verify_status'],
|
|
|
|
'verify_status' => $batch['verify_status'],
|
|
|
@ -413,17 +417,20 @@ class TestingResourceController extends BaseController
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getRemainQuota($gameId, $bindRoleId, $testingRoleId)
|
|
|
|
private function getRemainQuota($role, $bindRole = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$totalQuota = M('spend', 'tab_')
|
|
|
|
$totalQuota = $role['testing_other_quota'] + ($this->gameBaseQuota[$role['game_id']] ?? 0);
|
|
|
|
->where(['game_id' => $gameId, 'game_player_id' => $bindRoleId])
|
|
|
|
if (!is_null($bindRole)) {
|
|
|
|
->group('game_id,game_player_id')
|
|
|
|
$totalQuota += M('spend', 'tab_')
|
|
|
|
->sum('pay_amount');
|
|
|
|
->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id']])
|
|
|
|
|
|
|
|
->group('game_id,game_player_id')
|
|
|
|
|
|
|
|
->sum('pay_amount');
|
|
|
|
|
|
|
|
}
|
|
|
|
$providedQuota = M('testing_resource_batch', 'tab_')
|
|
|
|
$providedQuota = M('testing_resource_batch', 'tab_')
|
|
|
|
->where(['provide_status' => [in, [1, 2]], 'game_id' => $gameId, 'role_id' => $testingRoleId])
|
|
|
|
->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' => $gameId, 'role_id' => $testingRoleId])
|
|
|
|
->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);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -435,7 +442,7 @@ class TestingResourceController extends BaseController
|
|
|
|
$role = null;
|
|
|
|
$role = null;
|
|
|
|
if ($id != 0) {
|
|
|
|
if ($id != 0) {
|
|
|
|
$role = M('user_play_info', 'tab_')
|
|
|
|
$role = 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', 'testing_other_quota'])
|
|
|
|
->where(['id' => $id])
|
|
|
|
->where(['id' => $id])
|
|
|
|
->find();
|
|
|
|
->find();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -461,7 +468,7 @@ class TestingResourceController extends BaseController
|
|
|
|
$this->assign('servers', $servers);
|
|
|
|
$this->assign('servers', $servers);
|
|
|
|
$this->assign('bindingRole', $bindingRole);
|
|
|
|
$this->assign('bindingRole', $bindingRole);
|
|
|
|
$this->assign('role', $role);
|
|
|
|
$this->assign('role', $role);
|
|
|
|
$this->assign('quota', $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id']));
|
|
|
|
$this->assign('quota', $this->getRemainQuota($role, $bindingRole));
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -487,9 +494,9 @@ class TestingResourceController extends BaseController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find();
|
|
|
|
$binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find();
|
|
|
|
if (is_null($binding)) {
|
|
|
|
/* if (is_null($binding)) {
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '该角色未绑定玩家角色']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '该角色未绑定玩家角色']);
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
$user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find();
|
|
|
|
$user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find();
|
|
|
|
if (is_null($user)) {
|
|
|
|
if (is_null($user)) {
|
|
|
@ -508,31 +515,34 @@ class TestingResourceController extends BaseController
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
|
|
|
|
|
|
|
|
$role = M('user_play_info', 'tab_')
|
|
|
|
$role = M('user_play_info', 'tab_')
|
|
|
|
->field(['id', 'role_id', 'promote_id'])
|
|
|
|
->field(['id', 'role_id', 'promote_id', 'game_id', 'testing_other_quota'])
|
|
|
|
->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id'], 'role_id' => $roleId])
|
|
|
|
->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id'], 'role_id' => $roleId])
|
|
|
|
->find();
|
|
|
|
->find();
|
|
|
|
if (is_null($role)) {
|
|
|
|
if (is_null($role)) {
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $role['promote_id']])->find();
|
|
|
|
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $role['promote_id']])->find();
|
|
|
|
if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $loginPromote)) {
|
|
|
|
if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $loginPromote)) {
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$bindingRole = M('user_play_info', 'tab_')
|
|
|
|
$bindingRole = null;
|
|
|
|
->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id'])
|
|
|
|
if ($binding) {
|
|
|
|
->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']])
|
|
|
|
$bindingRole = M('user_play_info', 'tab_')
|
|
|
|
->find();
|
|
|
|
->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id'])
|
|
|
|
if (is_null($bindingRole)) {
|
|
|
|
->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']])
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']);
|
|
|
|
->find();
|
|
|
|
}
|
|
|
|
if (is_null($bindingRole)) {
|
|
|
|
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']);
|
|
|
|
if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) {
|
|
|
|
}
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']);
|
|
|
|
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
|
|
|
|
}
|
|
|
|
if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) {
|
|
|
|
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']);
|
|
|
|
if ($testPromote['id'] != $bindPromote['id']) {
|
|
|
|
}
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']);
|
|
|
|
/* if ($testPromote['id'] != $bindPromote['id']) {
|
|
|
|
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']);
|
|
|
|
|
|
|
|
} */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$amount = 0;
|
|
|
|
$amount = 0;
|
|
|
@ -553,7 +563,7 @@ class TestingResourceController extends BaseController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$remainQuota = $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id']);
|
|
|
|
$remainQuota = $this->getRemainQuota($role, $bindingRole);
|
|
|
|
if ($amount > $remainQuota) {
|
|
|
|
if ($amount > $remainQuota) {
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '额度不足']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '额度不足']);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -643,9 +653,9 @@ class TestingResourceController extends BaseController
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号所属推广员异常']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号所属推广员异常']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($testPromote['id'] != $bindPromote['id']) {
|
|
|
|
/* if ($testPromote['id'] != $bindPromote['id']) {
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号与测试账号非同一推广员']);
|
|
|
|
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号与测试账号非同一推广员']);
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
$bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find();
|
|
|
|
$bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find();
|
|
|
|
if ($bindIsTesting) {
|
|
|
|
if ($bindIsTesting) {
|
|
|
|