diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php
index 85cf9a5a9..3c10092fa 100644
--- a/Application/Admin/Controller/ConsoleController.class.php
+++ b/Application/Admin/Controller/ConsoleController.class.php
@@ -134,21 +134,6 @@ class ConsoleController extends Think {
echo M('game', 'tab_')->where('id>2')->field(['id', 'game_name'])->where('sdk_version=1')->select(false);
}
- public function testGameCat()
- {
- $key = '123456';
- $params = [
-
- ];
- ksort($params);
- $paramsStr = http_build_query($params) . '&key=' . $key;
- $sign = md5($paramsStr);
-
- $client = new AggregateClient();
- $result = $client->api('game-data', ['unique_codes' => ['w123'], 'started_at' => '2019-06-27', 'ended_at' => '2020-07-27']);
- var_dump($result);
- }
-
public function initMarketAdmin()
{
$marketService = new MarketService();
@@ -616,6 +601,40 @@ class ConsoleController extends Think {
// ARPU (当日充值金额/当日活跃用户数)
// ARRPU (当日充值金额/当日充值用户数)
}
+
+ public function checkAndfreezeTestingUser()
+ {
+ $pageCount = 100;
+ $hasNext = true;
+ $lastId = 0;
+ do {
+ $testingUsers = M('testing_user', 'tab_')
+ ->where(['status' => ['in', [1, 2]], 'id' => ['gt', $lastId]])
+ ->order('id asc')
+ ->limit($pageCount)
+ ->select();
+ if (count($testingUser) < $pageCount) {
+ $hasNext = false;
+ }
+ $userIds = array_column($testingUsers, 'user_id');
+ $users = M('user', 'tab_')->field(['id', 'account', 'login_time'])->where(['id' => ['in', $userIds]])->select();
+ $users = index_by_column('id', $users);
+ $unloginLimitTime = 7 * 24 * 3600;
+ $unloginUserIds = [];
+ foreach ($testingUsers as $testingUser) {
+ $user = $users[$testingUser['user_id']] ?? null;
+ if ($user && (time() - $user['login_time']) > $unloginLimitTime) {
+ $unloginUserIds[] = $user['id'];
+ }
+ $lastId = $testingUser['id'];
+ }
+ if (count($unloginUserIds) > 0) {
+ M('testing_user', 'tab_')->where(['user_id' => ['in', $unloginUserIds]])->save([
+ 'status' => 3
+ ]);
+ }
+ } while($hasNext);
+ }
public function statUserRetention()
{
diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php
index e52bd0396..fed0e08b4 100644
--- a/Application/Admin/Controller/GameApiController.class.php
+++ b/Application/Admin/Controller/GameApiController.class.php
@@ -10,7 +10,7 @@ use Base\Tool\TaskClient;
use Base\Service\TestingResourceService;
use GuzzleHttp\Client;
use think\Db;
-use Base\Tool\GameCatClient;
+use Base\Tool\GameResource;
class GameApiController extends Think {
@@ -24,13 +24,18 @@ class GameApiController extends Think {
$service = new TestingResourceService();
$gameIds = $service->getHasItfGameIds();
- $map = ['verify_status' => 0];
+ $map = ['verify_status' => 0, 'auto_verify' => 1];
if (count($gameIds) > 0) {
$map['game_id'] = ['in', $gameIds];
}
$batches = M('testing_resource_batch', 'tab_')->where($map)->select();
foreach ($batches as $batch) {
- $service->verify($batch);
+ try {
+ $service->verify($batch);
+ echo 'SUCCESS [' . $batch['id'] . ']审核成功' . PHP_EOL;
+ } catch (\Exception $e) {
+ echo 'ERROR [' . $batch['id'] . ']审核异常' . PHP_EOL;
+ }
}
}
@@ -46,13 +51,33 @@ class GameApiController extends Think {
}
$batches = M('testing_resource_batch', 'tab_')->where($map)->select();
foreach ($batches as $batch) {
- $service->provide($batch);
+ try {
+ $service->provide($batch);
+ echo 'SUCCESS [' . $batch['id'] . ']发放成功' . PHP_EOL;
+ } catch (\Exception $e) {
+ echo 'ERROR [' . $batch['id'] . ']发放异常' . PHP_EOL;
+ }
}
}
public function send()
{
- $role = [
+ // 229
+ // 231
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 231])->find();
+ // $gameResource1 = new GameResource($game);
+ /* $resources = $gameResource1->getResources(1);
+ return; */
+ /* $successCount = 0;
+ for ($i = 0; $i < 10; $i ++) {
+ $resources = $gameResource1->getResources(1);
+ if (count($resources) > 0) {
+ $successCount ++;
+ }
+ }
+ var_dump($successCount);
+ return; */
+ /* $role = [
'role_id' => '6819493',
'user_account' => 'qh11102',
'sdk_version' => 1,
@@ -62,9 +87,31 @@ class GameApiController extends Think {
'ref_id' => '8',
'remark' => '测试',
'order_no' => date('YmdHis') . rand(1000, 9999) . '_1',
+ ]; */
+ $role = [
+ 'role_id' => '9571794000008',
+ 'server_id' => '8',
+ 'sdk_version' => 1,
];
- $service = new TestingResourceService();
- $result = $service->provideFromGameCat($order, $role);
+ $order = [
+ 'ref_id' => '9000',
+ 'remark' => '测试',
+ 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1',
+ ];
+ /* $role = [
+ 'role_id' => '466500506',
+ 'server_id' => '49000152',
+ 'sdk_version' => 2,
+ ];
+ $order = [
+ // 'ref_id' => '9000',
+ 'ref_amount' => 6,
+ 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1',
+ ]; */
+
+ $gameResource = new GameResource($game);
+ // $result = $gameResource->getResources();
+ $result = $gameResource->apply($order, $role);
var_dump($result);
}
}
diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php
index b2f28a187..1946fa047 100644
--- a/Application/Admin/Controller/TestingResourceController.class.php
+++ b/Application/Admin/Controller/TestingResourceController.class.php
@@ -18,14 +18,15 @@ class TestingResourceController extends ThinkController
$gameId = $params['game_id'] ?? 0;
$repository = new TestingResourceRepository();
- $query = $repository->getTestingUsersQuery($params);
+ $query = $repository->getTestingRolesQuery($params);
[$roles, $page, $count] = $this->paginate($query);
- $records = $repository->makeTestingUserRecords($roles);
+ $records = $repository->makeTestingRoleRecords($roles);
$gameRepository = new GameRepository();
+ $this->assign('statusList', TestingResourceRepository::$userStatusList);
$this->assign('games', $gameRepository->getChoiceGames());
$this->assign('servers', $gameRepository->getServersByGameId($gameId));
$this->assign('count', $count);
@@ -34,6 +35,24 @@ class TestingResourceController extends ThinkController
$this->display();
}
+ public function users()
+ {
+ $params = I('get.');
+
+ $repository = new TestingResourceRepository();
+ $query = $repository->getTestingUsersQuery($params);
+
+ [$testingUsers, $page, $count] = $this->paginate($query);
+
+ $records = $repository->makeTestingUserRecords($testingUsers);
+
+ $this->assign('statusList', TestingResourceRepository::$userStatusList);
+ $this->assign('count', $count);
+ $this->assign('records', $records);
+ $this->assign('_page', $page);
+ $this->display();
+ }
+
public function getServers()
{
$gameId = I('game_id', 0);
@@ -277,7 +296,6 @@ class TestingResourceController extends ThinkController
->find();
}
-
$hasItf = 0;
$servers = [];
@@ -290,6 +308,9 @@ class TestingResourceController extends ThinkController
->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']])
->find();
+ if ($bindingRole) {
+ $bindingRole['binding_time'] = $binding['create_time'];
+ }
}
$repository = new TestingResourceRepository();
@@ -443,17 +464,28 @@ class TestingResourceController extends ThinkController
public function getResourceTypes()
{
$gameId = I('game_id', 0);
- $testingResourceService = new TestingResourceService();
- $resourceTypes = $testingResourceService->getResourceTypes($gameId);
- return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
+ try {
+ $testingResourceService = new TestingResourceService();
+ $resourceTypes = $testingResourceService->getResourceTypes($game);
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resourceTypes' => []]]);
+ }
}
public function getResources()
{
$typeId = I('type_id', 0);
- $testingResourceService = new TestingResourceService();
- $resources = $testingResourceService->getResources($typeId);
- return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
+ $gameId = I('game_id', 0);
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
+ try {
+ $testingResourceService = new TestingResourceService();
+ $resources = $testingResourceService->getResources($game, $typeId);
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resources' => []]]);
+ }
}
public function exportOrders()
@@ -531,4 +563,53 @@ class TestingResourceController extends ThinkController
'provide_status_text' => '发放状态'
]);
}
+
+ public function deleteTestingUser()
+ {
+ $userId = I('user_id', 0);
+ try {
+ $testingResourceService = new TestingResourceService();
+ $testingResourceService->deleteTestingUser($userId);
+ return $this->ajaxReturn(['status' => 1, 'message' => '删除成功']);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
+ }
+ }
+
+ public function verifyTestingUsers()
+ {
+ $userIds = I('user_ids', 0);
+ $verifyStatus = I('verify_status', 1);
+ try {
+ $testingResourceService = new TestingResourceService();
+ $testingResourceService->verifyTestingUser($userIds, $verifyStatus);
+ return $this->ajaxReturn(['status' => 1, 'message' => '审核成功']);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
+ }
+ }
+
+ public function unfreezeTestingUser()
+ {
+ $userId = I('user_id', 0);
+ try {
+ $testingResourceService = new TestingResourceService();
+ $testingResourceService->unfreezeTestingUser($userId);
+ return $this->ajaxReturn(['status' => 1, 'message' => '解禁成功']);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
+ }
+ }
+
+ public function freezeTestingUser()
+ {
+ $userId = I('user_id', 0);
+ try {
+ $testingResourceService = new TestingResourceService();
+ $testingResourceService->freezeTestingUser($userId);
+ return $this->ajaxReturn(['status' => 1, 'message' => '禁用成功']);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
+ }
+ }
}
\ No newline at end of file
diff --git a/Application/Admin/View/TestingResource/apply.html b/Application/Admin/View/TestingResource/apply.html
index 1a7211ef0..802c4de3d 100644
--- a/Application/Admin/View/TestingResource/apply.html
+++ b/Application/Admin/View/TestingResource/apply.html
@@ -100,10 +100,11 @@ body {
background: #E5E5E5;
color: #535875;
border: none;
- border-radius: 4px;
+ border-radius: 3px;
cursor: pointer;
display: inline-block;
margin-left: 10px;
+ padding: 0px 10px;
}
.info-row button.bind-btn {
background: #409eff;
@@ -365,7 +366,7 @@ body {
$.ajax({
url: "{:U('getResources')}",
type: "post",
- data: { type_id: typeId },
+ data: { game_id: globalGameId, type_id: typeId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
diff --git a/Application/Admin/View/TestingResource/index.html b/Application/Admin/View/TestingResource/index.html
index 7d82a6907..a0ba8f644 100644
--- a/Application/Admin/View/TestingResource/index.html
+++ b/Application/Admin/View/TestingResource/index.html
@@ -113,6 +113,14 @@
+
+
+
diff --git a/Application/Admin/View/TestingResource/users.html b/Application/Admin/View/TestingResource/users.html
new file mode 100644
index 000000000..96313ce1e
--- /dev/null
+++ b/Application/Admin/View/TestingResource/users.html
@@ -0,0 +1,338 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
测试账号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 测试账号 |
+ 账号状态 |
+ 推广员 |
+ 添加时间 |
+ 操作 |
+
+
+
+
+
+
+ aOh! 暂时还没有内容! |
+
+
+
+ {$record.user_account} |
+ {$record.status_text} |
+ {$record.promote_account} |
+ {$record.create_time} |
+
+
+ 解禁
+
+ 禁用
+
+ |
+
+
+
+
+
+
+
+
+
+ 导出
+
+ {$_page|default=''}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php
index ec7be34f2..ad62b42b0 100644
--- a/Application/Base/Repository/TestingResourceRepository.class.php
+++ b/Application/Base/Repository/TestingResourceRepository.class.php
@@ -19,6 +19,18 @@ class TestingResourceRepository
'2' => '审核拒绝',
];
+ public static $userVerifyStatusList = [
+ '0' => '待审核',
+ '1' => '审核通过',
+ '2' => '审核拒绝',
+ ];
+
+ public static $userStatusList = [
+ '1' => '正常',
+ '2' => '警告',
+ '3' => '禁用',
+ ];
+
public function getProvideStatusText($provideStatus)
{
return self::$provideStatusList[$provideStatus] ?? '未知';
@@ -208,7 +220,10 @@ class TestingResourceRepository
$bindings = [];
$bindingRoles = [];
$applyRecords = [];
+ $testingUsers = [];
if (count($roles) > 0) {
+ $testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select();
+ $testingUsers = index_by_column('user_id', $testingUsers);
$users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select();
$users = index_by_column('id', $users);
$bindingRows = M('testing_binding', 'tab_')->where(['_string' => implode(' or ', $bindingOrWhere)])->select();
@@ -285,7 +300,20 @@ class TestingResourceRepository
'pay_status' => 1,
'_string' => '(' . implode(' or ', $spendOrWhere) . ')',
];
- $spendList = M('spend', 'tab_')->field('sum(pay_amount) amount, game_id, game_player_id')->where($spendCondition)->group('game_id,game_player_id')->select();
+ $subBindingSql = M('testing_binding', 'tab_')
+ ->where([
+ '_string' =>
+ 'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' .
+ 'tab_testing_binding.game_id = tab_spend.game_id and ' .
+ 'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time'
+ ])
+ ->select(false);
+ $spendCondition['_string'] .= ' and exists(' . $subBindingSql . ')';
+ $spendList = M('spend', 'tab_')
+ ->field('sum(pay_amount) amount, game_id, game_player_id')
+ ->where($spendCondition)
+ ->group('game_id,game_player_id')
+ ->select();
foreach ($spendList as $item) {
$spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $item['amount'];
}
@@ -301,13 +329,15 @@ class TestingResourceRepository
'verifyRecords' => $verifyRecords,
'todayProvideRecords' => $todayProvideRecords,
'gameSettings' => $gameSettings,
+ 'testingUsers' => $testingUsers,
];
}
- public function makeTestingUserRecords($roles)
+ public function makeTestingRoleRecords($roles)
{
$result = $this->statByRoles($roles);
$users = $result['users'];
+ $testingUsers = $result['testingUsers'];
$spendItems = $result['spendItems'];
$gameSettings = $result['gameSettings'];
$bindings = $result['bindings'];
@@ -324,6 +354,7 @@ class TestingResourceRepository
$records = [];
foreach ($roles as $role) {
$user = $users[$role['user_id']] ?? null;
+ $testingUser = $testingUsers[$role['user_id']] ?? null;
$binding = $bindings[$role['game_role_id']] ?? null;
$bindingRole = null;
if ($binding) {
@@ -339,6 +370,21 @@ class TestingResourceRepository
$spendQuota = $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0;
$quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0;
+ $statusText = '正常';
+ if (is_null($user) || is_null($testingUser)) {
+ $statusText = '错误';
+ } elseif ($testingUser['status'] == 2) {
+ $statusText = '警告';
+ } elseif ($testingUser['status'] == 3) {
+ $statusText = '禁用';
+ }
+
+ if (is_null($user)) {
+ $statusText .= '(账号不存在)';
+ } elseif ($user['lock_status'] != 1) {
+ $statusText .= '(账号锁定)';
+ }
+
$records[] = [
'id' => $role['id'],
'game_name' => $role['game_name'],
@@ -358,20 +404,21 @@ class TestingResourceRepository
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
'today_amount' => $todayProvideRecords[$role['game_role_id']] ?? 0,
'apply_amount' => $applyRecords[$role['game_role_id']] ?? 0,
- 'status' => $user && $user['lock_status'] == 1 ? '正常' : '锁定',
+ 'status' => $statusText,
'create_time' => date('Y-m-d H:i:s', $role['create_time'])
];
}
return $records;
}
- public function getTestingUsersQuery($params, array $promote = null)
+ public function getTestingRolesQuery($params, array $promote = null)
{
$createTimeStart = $params['create_time_start'] ?? '';
$createTimeEnd = $params['create_time_end'] ?? '';
$gameId = $params['game_id'] ?? 0;
$serverId = $params['server_id'] ?? '';
$account = $params['account'] ?? '';
+ $status = $params['status'] ?? 0;
$roleName = $params['role_name'] ?? '';
$conditions = [];
@@ -405,7 +452,11 @@ class TestingResourceRepository
if ($createTimeEnd) {
$strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
}
+ if ($status != 0) {
+ $subConditions['status'] = $status;
+ }
+ $subConditions['verify_status'] = 1;
$subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
$strCondition .= ' and user_id in (' . $subSql . ')';
@@ -429,4 +480,70 @@ class TestingResourceRepository
$conditions['_string'] = $strCondition;
return M('user_play_info', 'tab_')->where($conditions)->order('create_time desc');
}
+
+ public function getTestingUsersQuery($params, array $promote = null)
+ {
+ $createTimeStart = $params['create_time_start'] ?? '';
+ $createTimeEnd = $params['create_time_end'] ?? '';
+ $status = $params['status'] ?? 0;
+ $verifyStatus = $params['verify_status'] ?? -1;
+ $account = $params['account'] ?? '';
+
+ $conditions = [];
+ $strCondition = '1=1';
+
+ /* $promoteService = new PromoteService();
+ if ($promote) {
+ $subSql = M('user', 'tab_')->field('id')->where('promote_id in (' . $promoteService->subInSql($promote) . ')')->select(false);
+ $strCondition .= ' and user_id in (' . $subSql . ')';
+ } */
+
+ if ($account) {
+ $conditions['user_account'] = ['like', '%' . $account . '%'];
+ }
+ if ($verifyStatus != -1) {
+ $conditions['verify_status'] = $verifyStatus;
+ }
+ if ($status != 0) {
+ $conditions['status'] = $status;
+ }
+ if ($createTimeStart) {
+ $strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
+ }
+ if ($createTimeEnd) {
+ $strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
+ }
+
+ $conditions['_string'] = $strCondition;
+ return M('testing_user', 'tab_')->where($conditions);
+ }
+
+ public function makeTestingUserRecords($testingUsers)
+ {
+ $ids = array_column($testingUsers, 'user_id');
+ if (count($ids) == 0) {
+ return [];
+ }
+ $users = M('user', 'tab_')->field(['id', 'login_time', 'promote_account'])->where(['id' => ['in', $ids]])->select();
+ $users = index_by_column('id', $users);
+
+ $records = [];
+ foreach ($testingUsers as $testingUser) {
+ $user = $users[$testingUser['user_id']] ?? null;
+
+ $records[] = [
+ 'user_id' => $testingUser['user_id'],
+ 'user_account' => $testingUser['user_account'],
+ 'status_text' => self::$userStatusList[$testingUser['status']] ?? '未知',
+ 'verify_status_text' => self::$userVerifyStatusList[$testingUser['verify_status']] ?? '未知',
+ 'verify_status' => $testingUser['verify_status'],
+ 'status' => $testingUser['status'],
+ 'verify_time' => $testingUser['verify_time'] == 0 ? '' : date('Y-m-d H:i:s', $testingUser['verify_time']),
+ 'create_time' => date('Y-m-d H:i:s', $testingUser['create_time']),
+ 'promote_account' => $user ? $user['promote_account'] : '--',
+ 'login_time' => $user ? date('Y-m-d H:i:s', $user['login_time']) : '--',
+ ];
+ }
+ return $records;
+ }
}
\ No newline at end of file
diff --git a/Application/Base/Service/PromoteGradeService.class.php b/Application/Base/Service/PromoteGradeService.class.php
index f15d088d6..8e644d771 100644
--- a/Application/Base/Service/PromoteGradeService.class.php
+++ b/Application/Base/Service/PromoteGradeService.class.php
@@ -2,7 +2,6 @@
namespace Base\Service;
use Base\Facade\Request;
-use Base\Tool\GameCatClient;
class PromoteGradeService
{
diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php
index bb9aea68a..9d28e4856 100644
--- a/Application/Base/Service/TestingResourceService.class.php
+++ b/Application/Base/Service/TestingResourceService.class.php
@@ -2,7 +2,7 @@
namespace Base\Service;
use Base\Facade\Request;
-use Base\Tool\GameCatClient;
+use Base\Tool\GameResource;
use Base\Repository\TestingResourceRepository;
use Think\Model;
@@ -92,21 +92,24 @@ class TestingResourceService
throw new \Exception('该游戏不支持发放测试资源');
}
$role = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version'])
+ ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version', 'server_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();
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $batch['game_id']])->find();
+
$hasError = false;
$provideAmount = 0;
foreach ($orders as $order) {
$orderData = [];
if ($gameSetting['has_itf'] == 1) {
- $result = $this->provideFromGameCat($order, $role);
+ $gameResource = new GameResource($game);
+ $result = $gameResource->apply($order, $role);
$orderData = [
- 'result' => json_encode(['code' => $result['code'], 'message' => $result['message']]),
+ 'result' => json_encode($result),
];
if (!$result['status']) {
$hasError = true;
@@ -138,34 +141,6 @@ class TestingResourceService
->save($batchData);
}
- public function provideFromGameCat($order, $role)
- {
- $gameCatClient = new GameCatClient();
- $result = $gameCatClient->api('provide', [
- 'roleId' => $role['role_id'],
- 'amount' => intval($order['ref_amount']),
- 'supportItem' => $order['ref_id'],
- 'supportType' => '0',
- 'channelUid' => $role['user_account'],
- 'applyRemark' => $order['remark'] == '' ? '测试资源申请' : $order['remark'],
- 'applyId' => $order['order_no'],
- 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios',
- ]);
- if ($result['state'] == 1 && $result['data']) {
- return [
- 'status' => true,
- 'message' => $result['msg'],
- 'code' => 1,
- ];
- } else {
- return [
- 'status' => false,
- 'msg' => $result['msg'],
- 'code' => $result['state'],
- ];
- }
- }
-
public function getRemainQuota($role, $bindRole = null, $gameSetting = null)
{
if (is_null($gameSetting)) {
@@ -178,8 +153,14 @@ class TestingResourceService
$totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0);
if (!is_null($bindRole)) {
+ $bindTime = $bindRole['binding_time'] ?? 0;
$spendQuota += M('spend', 'tab_')
- ->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id'], 'pay_status' => 1])
+ ->where([
+ 'game_id' => $role['game_id'],
+ 'game_player_id' => $bindRole['role_id'],
+ 'pay_status' => 1,
+ 'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))]
+ ])
->group('game_id,game_player_id')
->sum('pay_amount');
$totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2);
@@ -195,6 +176,15 @@ class TestingResourceService
public function addTestingUsers($accounts, $promote = null)
{
+ // 测试账号是否自动审核
+ $isAutoVerify = true;
+ $verifyStatus = 0;
+ $verifyTime = 0;
+ if ($isAutoVerify) {
+ $verifyStatus = 1;
+ $verifyTime = time();
+ }
+
$accounts = array_unique($accounts);
$existAccounts = M('testing_user', 'tab_')->where(['user_account' => ['in', $accounts]])->getField('user_account', true);
$existAccounts = $existAccounts ?? [];
@@ -221,6 +211,8 @@ class TestingResourceService
'user_id' => $user['id'],
'user_account' => $user['account'],
'status' => 1,
+ 'verify_status' => $verifyStatus,
+ 'verify_time' => $verifyTime,
'create_time' => time(),
'update_time' => time(),
];
@@ -284,6 +276,14 @@ class TestingResourceService
throw new \Exception('测试账号不存在');
}
+ if ($testingUser['verify_status'] != 1) {
+ throw new \Exception('测试账号未审核通过');
+ }
+
+ if (!in_array($testingUser['status'], [1, 2])) {
+ throw new \Exception('测试账号已禁用');
+ }
+
$promoteService = new PromoteService();
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $testingRole['promote_id']])->find();
if (is_null($testPromote) || ($promote && !$promoteService->isSubOrSelf($testPromote, $promote))) {
@@ -353,12 +353,8 @@ class TestingResourceService
throw new \Exception('权限不足');
}
- $resources = [];
- if ($gameId == 229) {
- $resources = $this->getGameCatResources('android');
- } elseif ($gameId == 230) {
- $resources = $this->getGameCatResources('ios');
- }
+ $game = M('game', 'tab_')->where(['id' => $gameId])->find();
+ $resources = $this->getResources($game);
$gameSetting = $this->repository->getGameSettingByGameId($gameId);
if (is_null($gameSetting)) {
@@ -378,7 +374,13 @@ class TestingResourceService
if (is_null($testingUser)) {
throw new \Exception('测试账号不存在');
}
+ if ($testingUser['verify_status'] != 1) {
+ throw new \Exception('测试账号未审核通过');
+ }
+ if (!in_array($testingUser['status'], [1, 2])) {
+ throw new \Exception('测试账号已禁用');
+ }
$server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find();
if (is_null($server)) {
throw new \Exception('区服不存在');
@@ -421,6 +423,7 @@ class TestingResourceService
if (is_null($bindingRole)) {
throw new \Exception('绑定玩家角色不存在');
}
+ $bindingRole['binding_time'] = $binding['create_time'];
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
if (is_null($bindPromote) || ($promote && !$promoteService->isSubOrSelf($bindPromote, $promote))) {
throw new \Exception('绑定角色所属推广员异常');
@@ -461,11 +464,15 @@ class TestingResourceService
}
}
- $remainQuota = $this->getRemainQuota($role, $bindingRole);
+ $remainQuota = $this->getRemainQuota($role, $bindingRole, $gameSetting);
if ($amount > $remainQuota) {
throw new \Exception('额度不足');
}
+ $olderBatch = M('testing_resource_batch', 'tab_')
+ ->field(['id'])
+ ->where(['user_id' => $testingUser['user_id'], 'game_id' => $gameId, 'verify_status' => 1])
+ ->find();
$batchNo = date('YmdHis') . substr(md5($roleId . strval(microtime(true)) . rand(0, 9999)), 8, 16);
try {
@@ -482,6 +489,7 @@ class TestingResourceService
'apply_amount' => $amount,
'provide_status' => 0,
'verify_status' => 0,
+ 'auto_verify' => $gameSetting['has_itf'] == 1 && $olderBatch ? 1 : 0,
'create_time' => time(),
'update_time' => time(),
];
@@ -508,52 +516,24 @@ class TestingResourceService
}
}
- public function getResourceTypes($gameId)
- {
- $resourceTypes = [];
-
- /**
- * @todo 目前固定游戏猫
- */
- if ($gameId == 229) {
- $resourceTypes[] = ['id' => 1, 'name' => '通用'];
- } elseif ($gameId == 230) {
- $resourceTypes[] = ['id' => 2, 'name' => '通用'];
- }
- return $resourceTypes;
- }
-
- public function getResources($typeId)
+ public function getResourceTypes($game)
{
- $resources = [];
-
- /**
- * @todo 目前固定游戏猫资源类型ID
- */
- if ($typeId == 2) {
- $resources = $this->getGameCatResources('ios');
- } elseif ($typeId == 1) {
- $resources = $this->getGameCatResources('andriod');
+ $gameSetting = $this->repository->getGameSettingByGameId($game['id']);
+ if ($gameSetting['has_itf'] == 0) {
+ return [];
}
- return $resources;
+ $gameResource = new GameResource($game);
+ return $gameResource->getResourceTypes();
}
- private function getGameCatResources($deviceType)
+ public function getResources($game, $typeId = null)
{
- $resources = [];
- $gameCatClient = new GameCatClient();
- $result = $gameCatClient->api('get-pay-type', ['device_type' => $deviceType]);
- if ($result['state'] == 1) {
- $items = $result['data'];
- foreach ($items as $item) {
- $resources[$item['supportItem']] = [
- 'ref_id' => $item['supportItem'],
- 'name' => $item['content'],
- 'amount' => $item['amount'],
- ];
- }
+ $gameSetting = $this->repository->getGameSettingByGameId($game['id']);
+ if ($gameSetting['has_itf'] == 0) {
+ return [];
}
- return $resources;
+ $gameResource = new GameResource($game);
+ return $gameResource->getResources($typeId);
}
public function getHasItfGameIds()
@@ -575,4 +555,59 @@ class TestingResourceService
return array_merge(array_column($baseGames, 'android_game_id'), array_column($baseGames, 'ios_game_id'));
}
}
+
+ public function verifyTestingUser($userIds, $verifyStatus)
+ {
+ if (count($userIds) == 0) {
+ throw new \Exception('请选择要审核的测试账号');
+ }
+
+ if (!in_array($verifyStatus, [1, 2])) {
+ throw new \Exception('状态值异常');
+ }
+
+ $testingUsers = M('testing_user', 'tab_')->where(['verify_status' => 0, 'user_id' => ['in', $userIds]])->get();
+ if (count($testingUsers) == 0) {
+ throw new \Exception('含有非待审核的测试账号');
+ }
+
+ M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->save([
+ 'status' => $verifyStatus
+ ]);
+ }
+
+ public function freezeTestingUser($userId)
+ {
+ $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find();
+ if (is_null($testingUser)) {
+ throw new \Exception('测试账号不存在');
+ }
+ M('testing_user', 'tab_')->where(['user_id' => $userId])->save([
+ 'status' => 3
+ ]);
+ }
+
+ public function unfreezeTestingUser($userId)
+ {
+ $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find();
+ if (is_null($testingUser)) {
+ throw new \Exception('测试账号不存在');
+ }
+ M('testing_user', 'tab_')->where(['user_id' => $userId])->save([
+ 'status' => 1
+ ]);
+ }
+
+ public function deleteTestingUser($userId)
+ {
+ $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find();
+ if (is_null($testingUser)) {
+ throw new \Exception('测试账号不存在');
+ }
+ if ($testingUser['verify_status'] != 2) {
+ throw new \Exception('只有审核拒绝的测试账号才能删除');
+ }
+
+ M('testing_user', 'tab_')->where(['user_id' => $userId])->delete();
+ }
}
\ No newline at end of file
diff --git a/Application/Base/Tool/GameResource.class.php b/Application/Base/Tool/GameResource.class.php
new file mode 100644
index 000000000..f408cba90
--- /dev/null
+++ b/Application/Base/Tool/GameResource.class.php
@@ -0,0 +1,63 @@
+ JtxcClient::class,
+ 192 => JtxcClient::class,
+ 231 => LsxxClient::class,
+ 232 => LsxxClient::class,
+ 229 => YzchzbClient::class,
+ 230 => YzchzbClient::class,
+ ];
+
+ public function __construct($game)
+ {
+ $this->game = $game;
+ $this->client = $this->createClient();
+ }
+
+ private function createClient()
+ {
+ $clientClass = '';
+ $gameId = intval($this->game['id']);
+ if (isset($this->clientMap[$gameId])) {
+ $clientClass = $this->clientMap[$gameId];
+ } else {
+ throw new \Exception('游戏资源客户端未配置');
+ }
+ return new $clientClass();
+ }
+
+ public function getResourceTypes()
+ {
+ $deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios';
+ return $this->client->getResourceTypes($deviceType);
+ }
+
+ public function getResources($typeId = null)
+ {
+ $deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios';
+ return $this->client->getResources($typeId, $deviceType);
+ }
+
+ public function apply($order, $role)
+ {
+ return $this->client->apply($order, $role);
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Tool/GameResource/JtxcClient.class.php b/Application/Base/Tool/GameResource/JtxcClient.class.php
new file mode 100644
index 000000000..a1ef1b961
--- /dev/null
+++ b/Application/Base/Tool/GameResource/JtxcClient.class.php
@@ -0,0 +1,155 @@
+ ['uri' => '/api/game/sendGold/zhuimeng/jxlm/57972', 'method' => 'post'],
+ ];
+
+ public function __construct()
+ {
+ $this->client = new Client([
+ 'base_uri' => 'http://chat.leniu.com',
+ 'timeout' => 10.0,
+ ]);
+ }
+
+ public function api($api, array $params = [])
+ {
+ $api = $this->apis[$api] ?? null;
+ if (is_null($api)) {
+ throw new \Exception('接口不存在');
+ }
+ $params[self::SIGN_NAME] = $this->sign($params);
+ try {
+ return $this->request($api, $params);
+ } catch (\Exception $e) {
+ $env = C('APP_ENV', null, 'prod');
+ return $e->getMessage();
+ }
+ }
+
+ public function request($api, $params)
+ {
+ if ($api['method'] == 'get') {
+ return $this->get($api['uri'], $params);
+ } else {
+ return $this->post($api['uri'], $params);
+ }
+ }
+
+ protected function post($uri, array $params = [])
+ {
+ $response = $this->client->post($uri, [
+ 'verify' => false,
+ 'form_params' => $params,
+ ]);
+ return (string)$response->getBody();
+ }
+
+ protected function get($uri, array $params = [])
+ {
+ $response = $this->client->get($uri, [
+ 'verify' => false,
+ 'query' => $params,
+ ]);
+ return (string)$response->getBody();
+ }
+
+ protected function sign($params)
+ {
+ unset($params[self::SIGN_NAME]);
+ ksort($params);
+ $signRows = [];
+ foreach ($params as $key => $value) {
+ $signRows[] = $key . '=' . $value;
+ }
+ return md5(implode('&', $signRows) . self::KEY);
+ }
+
+ public function apply($order, $role)
+ {
+ $result = $this->api('provide', [
+ 'role_id' => $role['role_id'],
+ 'money' => intval($order['ref_amount']) * 10,
+ 'type' => 2,
+ // 'goods_id' => 0,
+ 'server_no' => $role['server_id'],
+ ]);
+ if ($result == 'SUCCESS') {
+ return [
+ 'status' => true,
+ 'message' => $result,
+ 'result' => ['result' => $result]
+ ];
+ } else {
+ return [
+ 'status' => false,
+ 'message' => $result,
+ 'result' => ['result' => $result]
+ ];
+ }
+ }
+
+ public function getResourceTypes($deviceType)
+ {
+ if ($deviceType == 'andriod') {
+ return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']];
+ } elseif ($deviceType == 'ios') {
+ return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']];
+ }
+ }
+
+ public function getResources($typeId, $deviceType)
+ {
+ return [
+ 1 => ['ref_id' => 1, 'name' => '60元宝', 'amount' => 6],
+ 2 => ['ref_id' => 2, 'name' => '300元宝', 'amount' => 30],
+ 3 => ['ref_id' => 3, 'name' => '980元宝', 'amount' => 98],
+ 4 => ['ref_id' => 4, 'name' => '1280元宝', 'amount' => 128],
+ 5 => ['ref_id' => 5, 'name' => '1980元宝', 'amount' => 198],
+ 6 => ['ref_id' => 6, 'name' => '3280元宝', 'amount' => 328],
+ 7 => ['ref_id' => 7, 'name' => '6480元宝', 'amount' => 648],
+ 8 => ['ref_id' => 8, 'name' => '10000元宝', 'amount' => 1000],
+ 9 => ['ref_id' => 9, 'name' => '20000元宝', 'amount' => 2000],
+ 10 => ['ref_id' => 10, 'name' => '30000元宝', 'amount' => 3000],
+ 11 => ['ref_id' => 11, 'name' => '50000元宝', 'amount' => 5000],
+ 12 => ['ref_id' => 12, 'name' => '100000元宝', 'amount' => 10000],
+ 13 => ['ref_id' => 13, 'name' => '200000元宝', 'amount' => 20000],
+ 14 => ['ref_id' => 14, 'name' => '680元宝', 'amount' => 68],
+ ];
+
+ /* return [
+ ['ref_id' => 121209, 'name' => '6元充值卡', 'amount' => 6],
+ ['ref_id' => 121210, 'name' => '30元充值卡', 'amount' => 30],
+ ['ref_id' => 121211, 'name' => '98元充值卡', 'amount' => 98],
+ ['ref_id' => 121212, 'name' => '128元充值卡', 'amount' => 128],
+ ['ref_id' => 121213, 'name' => '198元充值卡', 'amount' => 198],
+ ['ref_id' => 121214, 'name' => '328元充值卡', 'amount' => 328],
+ ['ref_id' => 121215, 'name' => '648元充值卡', 'amount' => 648],
+ ['ref_id' => 121216, 'name' => '1000元充值卡', 'amount' => 1000],
+ ['ref_id' => 121217, 'name' => '2000元充值卡', 'amount' => 2000],
+ ['ref_id' => 121218, 'name' => '3000元充值卡', 'amount' => 3000],
+ ['ref_id' => 121219, 'name' => '5000元充值卡', 'amount' => 5000],
+ ['ref_id' => 121220, 'name' => '10000元充值卡', 'amount' => 10000],
+ ['ref_id' => 121221, 'name' => '20000元充值卡', 'amount' => 20000],
+ ['ref_id' => 121222, 'name' => '68元充值卡', 'amount' => 68],
+ ]; */
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Tool/GameResource/LsxxClient.class.php b/Application/Base/Tool/GameResource/LsxxClient.class.php
new file mode 100644
index 000000000..733ee7595
--- /dev/null
+++ b/Application/Base/Tool/GameResource/LsxxClient.class.php
@@ -0,0 +1,134 @@
+ ['uri' => '/wanmeng/prop.php', 'method' => 'get'],
+ 'provide' => ['uri' => '/wanmeng/prop.php?action=prop', 'method' => 'post'],
+ ];
+
+ public function __construct()
+ {
+ $this->client = new Client([
+ 'base_uri' => 'http://47.114.91.166:1096',
+ 'timeout' => 10.0,
+ ]);
+ }
+
+ public function api($api, array $params = [])
+ {
+ $api = $this->apis[$api] ?? null;
+ if (is_null($api)) {
+ throw new \Exception('接口不存在');
+ }
+ $params[self::SIGN_NAME] = $this->sign($params);
+ try {
+ return $this->request($api, $params);
+ } catch (\Exception $e) {
+ $env = C('APP_ENV', null, 'prod');
+ return ['status' => 0, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
+ }
+ }
+
+ public function request($api, $params)
+ {
+ if ($api['method'] == 'get') {
+ return $this->get($api['uri'], $params);
+ } else {
+ return $this->post($api['uri'], $params);
+ }
+ }
+
+ protected function post($uri, array $params = [])
+ {
+ $response = $this->client->post($uri, [
+ 'verify' => false,
+ 'form_params' => $params,
+ ]);
+ $result = (string)$response->getBody();
+ return json_decode($result, true);
+ }
+
+ protected function get($uri, array $params = [])
+ {
+ $response = $this->client->get($uri, [
+ 'verify' => false,
+ 'query' => $params,
+ ]);
+ $result = (string)$response->getBody();
+ return json_decode($result, true);
+ }
+
+ protected function sign($params)
+ {
+ unset($params[self::SIGN_NAME]);
+ ksort($params);
+ $signRows = [];
+ foreach ($params as $key => $value) {
+ $signRows[] = $key . '=' . $value;
+ }
+ return md5(implode('&', $signRows) . self::KEY);
+ }
+
+ public function apply($order, $role)
+ {
+ $result = $this->api('provide', [
+ 'role_id' => $role['role_id'],
+ 'goods_id' => $order['ref_id'],
+ 'server_no' => $role['server_id'],
+ 'send_time' => time()
+ ]);
+ if ($result['status'] == 1) {
+ return [
+ 'status' => true,
+ 'message' => $result['msg'],
+ 'result' => $result
+ ];
+ } else {
+ return [
+ 'status' => false,
+ 'message' => $result['msg'],
+ 'result' => $result ?? []
+ ];
+ }
+ }
+
+ public function getResourceTypes($deviceType)
+ {
+ if ($deviceType == 'andriod') {
+ return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']];
+ } elseif ($deviceType == 'ios') {
+ return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']];
+ }
+ }
+
+ public function getResources($typeId, $deviceType)
+ {
+ $resources = [];
+ $result = $this->api('get-pay-type', ['action' => 'getItems']);
+ if ($result['status'] == 1) {
+ $items = $result['data'];
+ foreach ($items as $item) {
+ $resources[$item['id']] = [
+ 'ref_id' => $item['id'],
+ 'name' => $item['name'],
+ 'amount' => $item['money'],
+ ];
+ }
+ }
+ return $resources;
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Tool/GameCatClient.class.php b/Application/Base/Tool/GameResource/YzchzbClient.class.php
similarity index 59%
rename from Application/Base/Tool/GameCatClient.class.php
rename to Application/Base/Tool/GameResource/YzchzbClient.class.php
index 594c1964c..1efb656ec 100644
--- a/Application/Base/Tool/GameCatClient.class.php
+++ b/Application/Base/Tool/GameResource/YzchzbClient.class.php
@@ -1,14 +1,14 @@
$params,
]);
$result = (string)$response->getBody();
- /* var_dump($uri);
- var_dump($params);
- var_dump($result); */
return json_decode($result, true);
}
@@ -105,4 +102,57 @@ class GameCatClient
// var_dump(implode('&', $signRows));
return md5(implode('&', $signRows));
}
+
+ public function apply($order, $role)
+ {
+ $result = $this->api('provide', [
+ 'roleId' => $role['role_id'],
+ 'amount' => intval($order['ref_amount']),
+ 'supportItem' => $order['ref_id'],
+ 'supportType' => '0',
+ 'channelUid' => $role['user_account'],
+ 'applyRemark' => $order['remark'] == '' ? '测试资源申请' : $order['remark'],
+ 'applyId' => $order['order_no'],
+ 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios',
+ ]);
+ if ($result['state'] == 1 && $result['data']) {
+ return [
+ 'status' => true,
+ 'message' => $result['msg'],
+ 'result' => $result
+ ];
+ } else {
+ return [
+ 'status' => false,
+ 'message' => $result['msg'],
+ 'result' => $result ?? []
+ ];
+ }
+ }
+
+ public function getResourceTypes($deviceType)
+ {
+ if ($deviceType == 'andriod') {
+ return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']];
+ } elseif ($deviceType == 'ios') {
+ return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']];
+ }
+ }
+
+ public function getResources($typeId, $deviceType)
+ {
+ $resources = [];
+ $result = $this->api('get-pay-type', ['device_type' => $deviceType]);
+ if ($result['state'] == 1) {
+ $items = $result['data'];
+ foreach ($items as $item) {
+ $resources[$item['supportItem']] = [
+ 'ref_id' => $item['supportItem'],
+ 'name' => $item['content'],
+ 'amount' => $item['amount'],
+ ];
+ }
+ }
+ return $resources;
+ }
}
\ No newline at end of file
diff --git a/Application/Base/Tool/IPTool.class.php b/Application/Base/Tool/IPTool.class.php
new file mode 100644
index 000000000..043430f56
--- /dev/null
+++ b/Application/Base/Tool/IPTool.class.php
@@ -0,0 +1,41 @@
+getLoginPromote();
$repository = new TestingResourceRepository();
- $query = $repository->getTestingUsersQuery($params, $loginPromote);
+ $query = $repository->getTestingRolesQuery($params, $loginPromote);
[$roles, $pagination, $count] = $this->paginate($query);
- $records = $repository->makeTestingUserRecords($roles);
+ $records = $repository->makeTestingRoleRecords($roles);
$gameRepository = new GameRepository();
@@ -35,7 +34,7 @@ class TestingResourceController extends BaseController
$this->assign('records', $records);
$this->display();
}
-
+
public function addTestingUsers()
{
$loginPromote = $this->getLoginPromote();
@@ -143,6 +142,9 @@ class TestingResourceController extends BaseController
->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']])
->find();
+ if ($bindingRole) {
+ $bindingRole['binding_time'] = $binding['create_time'];
+ }
}
$repository = new TestingResourceRepository();
@@ -202,17 +204,28 @@ class TestingResourceController extends BaseController
public function getResourceTypes()
{
$gameId = I('game_id', 0);
- $testingResourceService = new TestingResourceService();
- $resourceTypes = $testingResourceService->getResourceTypes($gameId);
- return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
+ try {
+ $testingResourceService = new TestingResourceService();
+ $resourceTypes = $testingResourceService->getResourceTypes($game);
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resourceTypes' => []]]);
+ }
}
public function getResources()
{
$typeId = I('type_id', 0);
- $testingResourceService = new TestingResourceService();
- $resources = $testingResourceService->getResources($typeId);
- return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
+ $gameId = I('game_id', 0);
+ $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find();
+ try {
+ $testingResourceService = new TestingResourceService();
+ $resources = $testingResourceService->getResources($game, $typeId);
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
+ } catch (\Throwable $e) {
+ return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resources' => []]]);
+ }
}
public function getUserRoles()
diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html
index 56e488239..f8b4a740d 100644
--- a/Application/Home/View/default/TestingResource/apply.html
+++ b/Application/Home/View/default/TestingResource/apply.html
@@ -76,10 +76,11 @@
background: #E5E5E5;
color: #535875;
border: none;
- border-radius: 4px;
+ border-radius: 3px;
cursor: pointer;
display: inline-block;
margin-left: 10px;
+ padding: 0px 10px;
}
.info-row button.bind-btn {
background: #409eff;
@@ -318,7 +319,7 @@
$.ajax({
url: "{:U('getResources')}",
type: "post",
- data: { type_id: typeId },
+ data: { game_id: globalGameId, type_id: typeId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
diff --git a/Data/update.sql b/Data/update.sql
index badd46a76..76b9e30db 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2706,4 +2706,11 @@ CREATE TABLE `tab_testing_game_setting` (
ALTER TABLE `tab_promote_grade_setting`
ADD COLUMN `base_game_id` int(11) not NULL DEFAULT 0 COMMENT '游戏ID' AFTER `name`,
ADD COLUMN `month_begin` int(11) not NULL DEFAULT 0 COMMENT '规则截止月份' AFTER `base_game_id`,
-ADD COLUMN `month_end` int(11) not NULL DEFAULT 0 COMMENT '规则开始月份' AFTER `month_begin`;
\ No newline at end of file
+ADD COLUMN `month_end` int(11) not NULL DEFAULT 0 COMMENT '规则开始月份' AFTER `month_begin`;
+
+ALTER TABLE `tab_testing_user`
+ADD COLUMN `verify_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '审核状态' AFTER `status`;
+ALTER TABLE `tab_testing_user`
+ADD COLUMN `verify_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间' AFTER `verify_status`;
+ALTER TABLE `tab_testing_resource_batch`
+ADD COLUMN `auto_verify` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否需要审核' AFTER `verify_status`;
\ No newline at end of file