Merge branch 'hotfix/test_resource_new' of wmtx/platform into release

优化测试资源
master
廖金灵 5 years ago committed by Gogs
commit 0824f24b69

@ -19,6 +19,14 @@ class GameApiController extends Think {
C(api('Config/lists'));
}
public function verify()
{
$batch = M('testing_resource_batch', 'tab_')->where(['id' => 3])->find();
$service = new TestingResourceService();
// $service->verify($batch);
$service->provide($batch);
}
public function provice() {
$role = [
'role_id' => '6810778',

@ -53,12 +53,16 @@ class TestingResourceService
public function provide($batch)
{
if ($batch['verify_status'] != 1) {
throw new \Exception('该申请未审核通过');
}
if ($batch['provide_status'] != 0) {
throw new \Exception('发放状态异常');
}
$role = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'promote_id'])
->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version'])
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
->find();
$orders = M('testing_resource_order', 'tab_')
@ -75,9 +79,10 @@ class TestingResourceService
if (!$result['status']) {
$hasError = true;
$orderData['provide_status'] = 2;
} else {
$orderData['provide_status'] = 1;
}
$provideAmount += round($order['ref_amount'] * $order['num'], 2);
$orderData['provide_status'] = 1;
$orderData['provide_time'] = time();
M('testing_resource_order', 'tab_')
->where(['id' => $order['id']])
@ -87,6 +92,8 @@ class TestingResourceService
$batchData = [];
if ($hasError) {
$batchData['provide_status'] = 2;
} else {
$batchData['provide_status'] = 1;
}
$batchData['provide_time'] = time();
$batchData['provide_amount'] = $provideAmount;
@ -98,6 +105,22 @@ class TestingResourceService
public function provideFromGameCat($order, $role)
{
var_dump([
'roleId' => $role['role_id'],
'amount' => $order['ref_amount'],
'supportItem' => $order['ref_id'],
'supportType' => '0',
'channelUid' => $role['user_account'],
'applyRemark' => $order['remark'],
'applyId' => $order['order_no'],
'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios',
]);
return [
'status' => true,
'message' => '发送成功',
'code' => 1,
];
$gameCatClient = new GameCatClient();
$result = $gameCatClient->api('provide', [
'roleId' => $role['role_id'],

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

@ -112,11 +112,13 @@
<?php endif;?>
<a href="{:U('Safe/promoteLogs')}" class="<if condition='CONTROLLER_NAME eq Safe and (ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs ) '>active</if> ">操作日志</a>
</div>
<?php if($loginer['level'] < 4):?>
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>测试资源</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">
<a href="{:U('TestingResource/index')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq index '>active</if> ">测试资源申请</a>
<a href="{:U('TestingResource/batches')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq batches '>active</if> ">测试资源申请记录</a>
</div>
<?php endif;?>
<!--<eq name="parent_id" value="0">
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>扶持管理</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">

@ -17,6 +17,15 @@
border-radius: 4px;
cursor: pointer;
}
.normal_table td .status-0 {
color: #e6a23c;
}
.normal_table td .status-1 {
color: #67c23a;
}
.normal_table td .status-2 {
color: #f56c6c;
}
</style>
</block>
@ -108,11 +117,11 @@
<th>手机号</th>
<th>所属推广员</th>
<th>申请人</th>
<th>发放总金额</th>
<!-- <th>发放总金额</th> -->
<th>申请金额</th>
<th>发放金额</th>
<!-- <th>审核状态</th> -->
<!-- <th>审核时间</th> -->
<th>审核状态</th>
<th>审核时间</th>
<th>发放状态</th>
<th>发放时间</th>
<!-- <th>资源内容</th> -->
@ -136,16 +145,20 @@
<td>{$record.user_phone}</td>
<td>{$record.promote_account}</td>
<td>{$record.apply_promote_account}</td>
<td>{$record.history_provide_amount}</td>
<!-- <td>{$record.history_provide_amount}</td> -->
<td>{$record.apply_amount}</td>
<td>{$record.provide_amount}</td>
<!-- <td>{$record.verify_status_text}</td> -->
<!-- <td>
<td>
<span class="status-{$record.verify_status}">{$record.verify_status_text}</span>
</td>
<td>
<?=substr($record['verify_time'], 0, 10)?>
<br>
<?=substr($record['verify_time'], 10)?>
</td> -->
<td>{$record.provide_status_text}</td>
</td>
<td>
<span class="status-{$record.provide_status}">{$record.provide_status_text}</span>
</td>
<td>
<?=substr($record['provide_time'], 0, 10)?>
<br>

@ -181,8 +181,8 @@
<th>角色名称</th>
<th>绑定账号</th>
<th>绑定角色</th>
<!-- <th>初始额度</th> -->
<!-- <th>额外额度</th> -->
<th>初始额度</th>
<th>额外额度</th>
<th>累计额度</th>
<th>待审核金额</th>
<th>累计发放资源</th>
@ -214,8 +214,8 @@
<td>{$record.role_name}</td>
<td>{$record.bind_user_account}</td>
<td>{$record.bind_role_name}</td>
<!-- <td>{$record.base_quota}</td> -->
<!-- <td>{$record.other_quota}</td> -->
<td>{$record.base_quota}</td>
<td>{$record.other_quota}</td>
<td>{$record.quota}</td>
<td>{$record.verify_amount}</td>
<td>{$record.provide_amount}</td>

@ -81,6 +81,15 @@
display: inline-block;
margin-left: 10px;
}
.normal_table td .status-0 {
color: #e6a23c;
}
.normal_table td .status-1 {
color: #67c23a;
}
.normal_table td .status-2 {
color: #f56c6c;
}
</style>
<div class="page-search normal_list promoteCoin-record-search" style="padding: 20px;">
<div class="trunk-content article">
@ -123,7 +132,7 @@
<td>{$record.num}</td>
<td>{$record.amount}</td>
<td>{$record.remark}</td>
<td>{$record.provide_status_text}</td>
<td><span class="status-{$record.provide_status}">{$record.provide_status_text}</span></td>
</tr>
</volist>
</empty>

@ -2421,8 +2421,6 @@ CREATE TABLE `tab_testing_binding` (
`role_id` varchar(50) NOT NULL default '' COMMENT '角色ID',
`bind_user_id` int(11) unsigned NOT NULL default 0 COMMENT '绑定用户ID',
`bind_role_id` varchar(50) NOT NULL default '' COMMENT '绑定角色ID',
`base_quota` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '初始额度',
`other_quota` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '额外额度',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
PRIMARY KEY (`id`)
@ -2486,5 +2484,6 @@ CREATE TABLE `tab_testing_resource_batch` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table tab_user_play_info add column `game_role_id` varchar(80) DEFAULT '' COMMENT '角色' after role_level;
alter table tab_user_play_info add column `testing_other_quota` decimal(12, 2) DEFAULT '0.00' COMMENT '测试资源额外额度' after promote_account;
update tab_user_play_info set game_role_id = concat(game_id, '#', role_id);
ALTER TABLE `tab_user_play_info` ADD INDEX `index_unique_role`(`game_role_id`);
Loading…
Cancel
Save