master
ELF 4 years ago
parent 461f347b1a
commit 367345ea8d

@ -0,0 +1,126 @@
<?php
namespace Base\Service;
use Base\Facade\Request;
use Base\Tool\GameCatClient;
class TestingResourceService
{
public static $provideStatusList = [
'0' => '待发放',
'1' => '已发放',
'2' => '异常',
];
public static $verifyStatusList = [
'0' => '未审核',
'1' => '审核通过',
'2' => '审核拒绝',
];
public function getProvideStatusText($provideStatus)
{
return self::$provideStatusList[$provideStatus] ?? '未知';
}
public function getVerifyStatusText($verifyStatus)
{
return self::$verifyStatusList[$verifyStatus] ?? '未知';
}
public function verify($batch)
{
if ($batch['verify_status'] != 0) {
throw new \Exception('审核状态异常');
}
$batchData = [];
$batchData['verify_time'] = time();
$batchData['update_time'] = time();
if (!in_array($batch['game_id'], [229, 230])) {
$batchData['verify_status'] = 2;
$batchData['verify_remark'] = '该游戏发放功能暂未实现';
M('testing_resource_batch', 'tab_')->where(['id' => $batch['id']])->save($batchData);
throw new \Exception('该游戏发放功能暂未实现');
}
$batchData['verify_status'] = 1;
$batchData['verify_remark'] = '审核成功';
M('testing_resource_batch', 'tab_')->where(['id' => $batch['id']])->save($batchData);
}
public function provide($batch)
{
if ($batch['provide_status'] != 0) {
throw new \Exception('发放状态异常');
}
$role = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'promote_id'])
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
->find();
$orders = M('testing_resource_order', 'tab_')
->where(['batch_id' => $batch['id']])
->select();
$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;
}
$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']])
->save($orderData);
}
$batchData = [];
if ($hasError) {
$batchData['provide_status'] = 2;
}
$batchData['provide_time'] = time();
$batchData['provide_amount'] = $provideAmount;
$batchData['update_time'] = time();
M('testing_resource_batch', 'tab_')
->where(['id' => $batch['id']])
->save($batchData);
}
public function provideFromGameCat($order, $role)
{
$gameCatClient = new GameCatClient();
$result = $gameCatClient->api('provide', [
'roleId' => $role['role_id'],
'amount' => $order['ref_amount'],
'supportItem' => $order['ref_id'],
'supportType' => 0,
'channelUid' => $role['user_id'],
'applyRemark' => $order['remark'],
'applyId' => $order['order_no'],
'device_type' => $deviceType,
]);
if ($result['code'] == 1 && $result['data']) {
return [
'status' => true,
'message' => $result['message'],
'code' => 1,
];
} else {
return [
'status' => false,
'message' => $result['message'],
'code' => $result['code'],
];
}
}
}

@ -3,7 +3,8 @@ namespace Base\Service;
use Base\Facade\Request; use Base\Facade\Request;
class UserService { class UserService
{
public function isAccountExist($account) public function isAccountExist($account)
{ {

@ -17,7 +17,7 @@ class GameCatClient
private $apis = [ private $apis = [
'get-pay-type' => ['uri' => '/game/support/items/v1', 'method' => 'post'], 'get-pay-type' => ['uri' => '/game/support/items/v1', 'method' => 'post'],
'internal-pay' => ['uri' => '/game/support/provide/v1', 'method' => 'post'], 'provide' => ['uri' => '/game/support/provide/v1', 'method' => 'post'],
]; ];
private $appIds = [ private $appIds = [
@ -58,7 +58,7 @@ class GameCatClient
return $this->request($api, $params); return $this->request($api, $params);
} catch (\Exception $e) { } catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod'); $env = C('APP_ENV', null, 'prod');
return ['code' => '1000', 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
} }
} }

@ -8,6 +8,7 @@ use Base\Service\PromoteService;
use OSS\Core\OssException; use OSS\Core\OssException;
use Base\Tool\GameCatClient; use Base\Tool\GameCatClient;
use Think\Model; use Think\Model;
use Base\Service\TestingResourceService;
class TestingResourceController extends BaseController class TestingResourceController extends BaseController
{ {
@ -261,17 +262,7 @@ class TestingResourceController extends BaseController
} }
} }
$provideStatusList = [ $testingResourceService = new TestingResourceService();
'0' => '待发放',
'1' => '已发放',
'2' => '拒绝',
'3' => '异常',
];
$verifyStatusList = [
'0' => '未审核',
'1' => '审核通过',
'2' => '审核拒绝',
];
$records = []; $records = [];
foreach ($batches as $batch) { foreach ($batches as $batch) {
@ -295,16 +286,17 @@ class TestingResourceController extends BaseController
'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'],
'verify_status_text' => $verifyStatusList[$batch['verify_status']], 'verify_status_text' => $testingResourceService->getVerifyStatusText($batch['verify_status']),
'verify_time' => $batch['verify_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['verify_time']), 'verify_time' => $batch['verify_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['verify_time']),
'provide_status' => $batch['provide_status'], 'provide_status' => $batch['provide_status'],
'provide_status_text' => $provideStatusList[$batch['provide_status']], 'provide_status_text' => $testingResourceService->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' => $content,
]; ];
} }
$this->assign('provideStatusList', $provideStatusList); $this->assign('verifyStatusList', TestingResourceService::$verifyStatusList);
$this->assign('provideStatusList', TestingResourceService::$provideStatusList);
$this->assign('servers', $this->getServersByGameId($gameId)); $this->assign('servers', $this->getServersByGameId($gameId));
$this->assign('games', $this->getGames()); $this->assign('games', $this->getGames());
$this->assign('count', $count); $this->assign('count', $count);
@ -330,17 +322,7 @@ class TestingResourceController extends BaseController
$query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc'); $query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc');
list($orders, $pagination, $count) = $this->paginate($query); list($orders, $pagination, $count) = $this->paginate($query);
$provideStatusList = [ $testingResourceService = new TestingResourceService();
'0' => '待发放',
'1' => '已发放',
'2' => '拒绝',
'3' => '异常',
];
$verifyStatusList = [
'0' => '未审核',
'1' => '审核通过',
'2' => '审核拒绝',
];
foreach ($orders as $order) { foreach ($orders as $order) {
$records[] = [ $records[] = [
'id' => $order['id'], 'id' => $order['id'],
@ -356,10 +338,8 @@ class TestingResourceController extends BaseController
'num' => $order['num'], 'num' => $order['num'],
'amount' => $order['num'] * $order['ref_amount'], 'amount' => $order['num'] * $order['ref_amount'],
'remark' => $order['remark'], 'remark' => $order['remark'],
'verify_status' => $batch['provide_status'], 'provide_status' => $order['provide_status'],
'verify_status_text' => $verifyStatusList[$batch['verify_status']], 'provide_status_text' => $testingResourceService->getProvideStatusText($order['provide_status']),
'provide_status' => $batch['provide_status'],
'provide_status_text' => $provideStatusList[$batch['provide_status']],
]; ];
} }
@ -375,8 +355,13 @@ class TestingResourceController extends BaseController
->where(['game_id' => $gameId, 'game_player_id' => $bindRoleId]) ->where(['game_id' => $gameId, 'game_player_id' => $bindRoleId])
->group('game_id,game_player_id') ->group('game_id,game_player_id')
->sum('pay_amount'); ->sum('pay_amount');
$usedQuota = M('testing_resource_batch', 'tab_')->where(['game_id' => $gameId, 'role_id' => $testingRoleId])->sum('provide_amount'); $providedQuota = M('testing_resource_batch', 'tab_')
return round(floatval($totalQuota) - floatval($usedQuota), 2); ->where(['provide_status' => [in, [1, 2]], 'game_id' => $gameId, 'role_id' => $testingRoleId])
->sum('provide_amount');
$providingQuota = M('testing_resource_batch', 'tab_')
->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $gameId, 'role_id' => $testingRoleId])
->sum('provide_amount');
return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2);
} }
public function apply() public function apply()
@ -709,14 +694,6 @@ class TestingResourceController extends BaseController
private function getGameCatResources($deviceType) private function getGameCatResources($deviceType)
{ {
/* return [
1 => ['ref_id' => 1, 'name' => '礼包钻石6', 'amount' => 6],
2 => ['ref_id' => 2, 'name' => '礼包钻石18', 'amount' => 18],
3 => ['ref_id' => 3, 'name' => '礼包钻石30', 'amount' => 30],
4 => ['ref_id' => 4, 'name' => '礼包钻石98', 'amount' => 98],
5 => ['ref_id' => 5, 'name' => '礼包钻石128', 'amount' => 128],
6 => ['ref_id' => 6, 'name' => '礼包钻石648', 'amount' => 648],
]; */
$resources = []; $resources = [];
$gameCatClient = new GameCatClient(); $gameCatClient = new GameCatClient();
$result = $gameCatClient->api('get-pay-type', ['device_type' => $deviceType]); $result = $gameCatClient->api('get-pay-type', ['device_type' => $deviceType]);

@ -114,10 +114,8 @@
</div> </div>
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>测试资源</span><i class="arrow_icon"></i></div> <div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>测试资源</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent"> <div class="navContent jsnavContent">
<a href="{:U('TestResource/index')}" class="<if condition='CONTROLLER_NAME eq TestResource and (ACTION_NAME eq index or ACTION_NAME eq add or ACTION_NAME eq apply ) '>active</if> ">测试资源申请</a> <a href="{:U('TestingResource/index')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq index '>active</if> ">测试资源申请</a>
<a href="{:U('TestResource/lists')}" class="<if condition='CONTROLLER_NAME eq TestResource and ACTION_NAME eq lists '>active</if> ">测试资源申请记录</a> <a href="{:U('TestingResource/batches')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq batches '>active</if> ">测试资源申请记录</a>
<a href="{:U('TestResource/supportNumberList')}" class="<if condition='CONTROLLER_NAME eq TestResource and (ACTION_NAME eq supportNumberList or ACTION_NAME eq freezeSupport or ACTION_NAME eq unfreezeSupport or ACTION_NAME eq rechangePassward ) '>active</if> ">测试号管理</a>
<a href="{:U('TestResource/protectLogList')}" class="<if condition='CONTROLLER_NAME eq TestResource and ACTION_NAME eq protectLogList '>active</if> ">日志管理</a>
</div> </div>
<!--<eq name="parent_id" value="0"> <!--<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="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>扶持管理</span><i class="arrow_icon"></i></div>

@ -548,7 +548,7 @@
success: function(result){ success: function(result){
if (result.status == 1) { if (result.status == 1) {
layer.msg(result.message, function(){ layer.msg(result.message, function(){
parent.window.location.href = parent.window.location.href parent.window.location.href = "{:U('batches')}"
}) })
} else { } else {
layer.msg(result.message) layer.msg(result.message)

@ -115,7 +115,7 @@
<!-- <th>审核时间</th> --> <!-- <th>审核时间</th> -->
<th>发放状态</th> <th>发放状态</th>
<th>发放时间</th> <th>发放时间</th>
<th>资源内容</th> <!-- <th>资源内容</th> -->
<th>操作</th> <th>操作</th>
</tr> </tr>
<empty name="records"> <empty name="records">
@ -151,7 +151,7 @@
<br> <br>
<?=substr($record['provide_time'], 10)?> <?=substr($record['provide_time'], 10)?>
</td> </td>
<td>{$record.content}</td> <!-- <td>{$record.content}</td> -->
<td><button class="view-detail">操作</button></td> <td><button class="view-detail">操作</button></td>
</tr> </tr>
</volist> </volist>

@ -2457,9 +2457,11 @@ CREATE TABLE `tab_testing_resource_order` (
`ref_name` varchar(150) NOT NULL COMMENT '测试资源名称(第三方)', `ref_name` varchar(150) NOT NULL COMMENT '测试资源名称(第三方)',
`ref_amount` decimal(12, 2) not null default '0.00' comment '测试资源价值(第三方)', `ref_amount` decimal(12, 2) not null default '0.00' comment '测试资源价值(第三方)',
`num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量', `num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量',
`provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常', `provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝',
`provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发放时间',
`amount` decimal(12, 2) not null default '0.00' comment '申请金额', `amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注', `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
`result` varchar(255) NOT NULL DEFAULT '' COMMENT '发放结果',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -2472,10 +2474,10 @@ CREATE TABLE `tab_testing_resource_batch` (
`role_id` varchar(50) NOT NULL DEFAULT '' COMMENT '角色ID', `role_id` varchar(50) NOT NULL DEFAULT '' COMMENT '角色ID',
`apply_amount` decimal(12, 2) not null default '0.00' comment '申请金额', `apply_amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`provide_amount` decimal(12, 2) not null default '0.00' comment '发放金额', `provide_amount` decimal(12, 2) not null default '0.00' comment '发放金额',
`provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常', `provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 异常',
`provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间', `provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发放时间',
`apply_promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请推广员ID', `apply_promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请推广员ID',
`verify_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未审核 1 审核通过 1 未审核通过', `verify_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未审核 1 审核通过 2 未审核通过',
`verify_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注', `verify_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
`verify_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间', `verify_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',

Loading…
Cancel
Save