From 49751b8760dae1da6fc932a0e06a93c4f32533a0 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Mon, 10 Aug 2020 15:29:37 +0800
Subject: [PATCH 01/57] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/ConsoleController.class.php | 15 +
.../Base/Service/PromoteService.class.php | 12 +
.../TestingResourceController.class.php | 271 ++++++++++
.../View/default/TestingResource/index.html | 491 ++++++++++++++++++
Data/update.sql | 74 +++
Public/Home/css/20180207/common.css | 6 +
6 files changed, 869 insertions(+)
create mode 100644 Application/Home/Controller/TestingResourceController.class.php
create mode 100644 Application/Home/View/default/TestingResource/index.html
diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php
index 771cf52d1..e094f86fe 100644
--- a/Application/Admin/Controller/ConsoleController.class.php
+++ b/Application/Admin/Controller/ConsoleController.class.php
@@ -131,6 +131,21 @@ class ConsoleController extends Think {
var_dump($result);
}
+ 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();
diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php
index 68962de83..2f54f9bbc 100644
--- a/Application/Base/Service/PromoteService.class.php
+++ b/Application/Base/Service/PromoteService.class.php
@@ -854,6 +854,18 @@ class PromoteService {
return M('promote', 'tab_')->field($fields)->where($conditions)->select();
}
+ public function subInSql($promote, $withSelf = true)
+ {
+ $conditions = [
+ 'chain' => ['like', $promote['chain'] . $promote['id'] . '/%']
+ ];
+ if ($withSelf != 0) {
+ $conditions['_logic'] = 'or';
+ $conditions['id'] = $promote['id'];
+ }
+ return M('promote', 'tab_')->field(['id'])->where($conditions)->select(false);
+ }
+
public function getLevelName($level)
{
return self::$levels[$level] ?? '未知';
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
new file mode 100644
index 000000000..496e2fa65
--- /dev/null
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -0,0 +1,271 @@
+getLoginPromote();
+
+ $conditions = [];
+ $subConditions = [
+ '_string' => 'user_id = tab_user_play_info.user_id',
+ 'promote_id' => $loginPromote['id'],
+ ];
+
+ if ($createTimeStart) {
+ $subConditions['create_time'] = ['egt', strtotime($createTimeStart . ' 00:00:00')];
+ }
+ if ($createTimeEnd) {
+ $subConditions['create_time'] = ['elt', strtotime($createTimeEnd . ' 23:59:59')];
+ }
+
+ $subSql = M('testing_user', 'tab_')->field(['1'])->where($subConditions)->select(false);
+ $strCondition = 'exists (' . $subSql . ')';
+
+ if ($account) {
+ $user = M('user', 'tab_')->field(['id'])->where('account like ' . $account . '%')->find();
+ if ($user) {
+ $conditions['user_id'] = $user['id'];
+ } else {
+ $strCondition .= ' and 1<>1';
+ }
+ }
+ if ($gameId) {
+ $conditions['game_id'] = $gameId;
+ }
+ if ($serverId) {
+ $conditions['server_id'] = $serverId;
+ }
+ if ($roleName) {
+ $conditions['role_name'] = ['like', $roleName . '%'];
+ }
+ $conditions['_string'] = $strCondition;
+
+ $query = M('user_play_info', 'tab_')->where($conditions)->order('create_time desc');
+
+ list($roles, $pagination, $count) = $this->paginate($query);
+
+ $roleIds = array_column($roles, 'id');
+ $userIds = array_unique(array_column($roles, 'user_id'));
+
+ $users = [];
+ $bindings = [];
+ $bindingRoles = [];
+ if (count($roles) > 0) {
+ $users = M('user', 'tab_')->field(['id', 'phone'])->where(['id' => ['in', $userIds]])->select();
+ $uesrs = index_by_column('id', $users);
+ $bindings = M('testing_binding', 'tab_')->field()->where(['role_id' => ['in', $roleIds]])->select();
+ $bindings = index_by_column('role_id', $bindings);
+ $bindingRoleIds = array_column($bindings, 'bind_role_id');
+ if (count($bindings) > 0) {
+ $bindingRoles = M('user_play_info', 'tab_')->field(['id', 'role_name'])->where(['id' => ['in', $bindingRoleIds]])->select();
+ $bindingRoles = index_by_column('id', $bindingRoles);
+ }
+ }
+
+ $records = [];
+ foreach ($roles as $role) {
+ $user = $users[$role['user_id']] ?? null;
+ $binding = $bindings[$role['id']] ?? null;
+ $bindingRole = $binding && $bindingRoles[$binding['bind_role_id']] ? $bindingRoles[$binding['bind_role_id']] : null;
+ $records[] = [
+ 'game_name' => $role['game_name'],
+ 'server_name' => $role['server_name'],
+ 'server_id' => $role['server_id'],
+ 'role_id' => $role['role_id'],
+ 'user_account' => $role['user_account'],
+ 'user_phone' => $user ? $user['phone'] : '',
+ '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'] : 1200,
+ 'other_quota' => $binding ? $binding['other_quota'] : 0,
+ 'quota' => 0,
+ 'verify_amount' => 0,
+ 'provide_amount' => 0,
+ 'today_amount' => 0,
+ 'apply_amount' => 0,
+ 'status' => '可用',
+ 'create_time' => date('Y-m-d H:i:s', $role['create_time'])
+ ];
+ }
+
+ $this->assign('count', $count);
+ $this->assign('pagination', $pagination);
+ $this->assign('records', $records);
+ $this->display();
+ }
+
+ public function addTestingUsers()
+ {
+ $loginPromote = $this->getLoginPromote();
+ $accountsStr = trim(I('accounts', ''), ',');
+ if ($accountsStr = '') {
+ return $this->ajaxReturn(['status' => 0, 'message' => '请输入测试资源账号']);
+ }
+ $accounts = explode(',', $accountsStr);
+ $accounts = array_unique($accounts);
+ $existAccounts = M('testing_user', 'tab_')->where(['user_account' => ['in', $accounts]])->getField('user_account', true);
+ $existCount = count($existAccounts);
+ $newAccounts = array_diff($accounts, $existAccounts);
+ $errorCount = 0;
+ $successCount = 0;
+ if (count($newAccounts)) {
+ $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts]])->select();
+ $errorAccounts = array_diff($newAccounts, array_column($users, 'account'));
+ $errorCount = count($errorAccounts);
+ foreach ($users as $user) {
+ if (in_array($user['account'], $errorAccounts)) {
+ continue;
+ }
+ $data = [
+ 'user_id' => $user['id'],
+ 'user_account' => $user['account'],
+ 'status' => 1,
+ 'promote_id' => $loginPromote['id'],
+ 'create_time' => time(),
+ 'update_time' => time(),
+ ];
+ M('testing_user', 'tab_')->add($data);
+ $successCount ++;
+ }
+ }
+ return $this->ajaxReturn(['status' => 1, 'message' => '请输入测试资源账号', 'data' => [
+ 'errorCount' => $errorCount,
+ 'successCount' => $successCount,
+ 'existCount' => $existCount,
+ ]]);
+ }
+
+ public function batches()
+ {
+ $verifyTimeStart = I('verify_time_start', '');
+ $verifyTimeEnd = I('verify_time_end', '');
+ $verifyStatus = I('verify_status', -1);
+ $status = I('status', -1);
+ $account = I('account');
+
+ $loginPromote = $this->getLoginPromote();
+ $promoteService = new PromoteService();
+
+ $conditions = [
+ '_string' => 'promote_id in (' . $promoteService->subInSql($loginPromote) . ')',
+ ];
+ if ($verifyTimeStart) {
+ $conditions['verify_time'] = ['egt', strtotime($verifyTimeStart . ' 00:00:00')];
+ }
+ if ($verifyTimeEnd) {
+ $conditions['verify_time'] = ['elt', strtotime($verifyTimeEnd . ' 23:59:59')];
+ }
+ if ($verifyStatus != -1) {
+ $conditions['verify_status'] = $verifyStatus;
+ }
+ if ($status != -1) {
+ $conditions['status'] = $status;
+ }
+ if ($account) {
+ $user = M('user', 'tab_')->field(['id'])->where('account like ' . $account . '%')->find();
+ if ($user) {
+ $conditions['user_id'] = $user['id'];
+ } else {
+ $conditions['_string'] = '1<>1';
+ }
+ }
+ $query = M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc')->select();
+ list($batches, $pagination, $count) = $this->paginate($query);
+
+ $this->assign('count', $count);
+ $this->assign('pagination', $pagination);
+ $this->assign('records', $records);
+ $this->display();
+ }
+
+ public function apply()
+ {
+ $records = I('records', []);
+ $batchNo = '';
+ $loginPromote = $this->getLoginPromote();
+
+ $amount = 0;
+ foreach ($records as $record) {
+ $amount += $record['num'] * $record['value'];
+ }
+
+ try {
+ $batch = [
+ 'batch_id' => $batchId,
+ 'order_no' => $orderNo,
+ 'user_id' => $record['user_id'],
+ 'game_id' => $record['game_id'],
+ 'promote_id' => $loginPromote['id'],
+ 'amount' => $amount,
+ 'status' => 0,
+ 'verify_status' => 0,
+ 'remark' => $record['remark'],
+ 'create_time' => time(),
+ 'update_time' => time(),
+ ];
+ $batchId = M('testing_resource_batch')->add($batch);
+ $i = 1;
+ foreach ($records as $record) {
+ $orderNo = $batchNo . '_' . $i;
+ $order = [
+ 'batch_id' => $batchId,
+ 'order_no' => $orderNo,
+ 'testing_resource_id' => $record['resource_id'],
+ 'num' => $record['num'],
+ 'amount' => $record['num'] * $record['value'],
+ 'remark' => $record['remark'],
+ ];
+ M('testing_resource_order')->add($order);
+ }
+ } catch (\Exception $e) {
+
+ }
+ }
+
+ public function bindRole()
+ {
+ $testingUserId = I('testing_user_id', 0);
+ $userAccount = I('user_account', '');
+ $roleId = I('role_id', '');
+
+ $user = M('user', 'tab_')->field(['id', 'account'])->where(['account' => $userAccount])->find();
+ if (is_null($user)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '用户不存在']);
+ }
+
+ $existBind = M('testing_user', 'tab_')->field(['id'])->where(['bind_user_id' => $user['id']])->find();
+ if ($existBind) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号已被绑定']);
+ }
+
+ M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->save([
+ 'role_id' => $roleId,
+ 'bind_user_id' => $user['id'],
+ 'bind_user_account' => $user['account'],
+ 'bind_role_id' => $roleId,
+ ]);
+ return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
+ }
+
+ public function getRolesByUser()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Application/Home/View/default/TestingResource/index.html b/Application/Home/View/default/TestingResource/index.html
new file mode 100644
index 000000000..8803d252b
--- /dev/null
+++ b/Application/Home/View/default/TestingResource/index.html
@@ -0,0 +1,491 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
申请测试资源
+
说明:申请测试资源
+
+
+
+
+
+
+
+
+
+
+
+
+
+
导出
+
+ {$pagination}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Data/update.sql b/Data/update.sql
index 764f5718e..42af73acb 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2401,3 +2401,77 @@ INSERT INTO `sys_kv`(`id`, `key`, `value`, `type`, `remark`) VALUES (4, 'cp_comp
ALTER TABLE `sj_game_channel`.`sj_cptogether_company`
ADD COLUMN `is_qualifity` tinyint(2) NULL COMMENT '是否具有游戏资质 0 否 1 是' AFTER `is_received`;
+
+
+CREATE TABLE `tab_testing_user` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `user_id` int(11) unsigned NOT NULL COMMENT '测试用户ID',
+ `user_account` varchar(50) not null comment '测试用户账号',
+ `promote_id` int(11) not null default 0 COMMENT '推广员ID',
+ `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 禁用 1 可用',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
+ `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_testing_binding` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `user_id` int(11) unsigned NOT NULL COMMENT '测试用户ID',
+ `role_id` int(11) NOT NULL default '0' COMMENT '角色ID',
+ `bind_user_id` int(11) unsigned NOT NULL default 0 COMMENT '绑定用户ID',
+ `bind_role_id` int(11) NOT NULL default '0' 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`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_testing_resource` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(120) NOT NULL DEFAULT COMMENT '测试资源名称',
+ `game_id` int(11) NOT NULL COMMENT '游戏ID',
+ `type_id` int(11) NOT NULL COMMENT '测试资源类型ID',
+ `price` decimal(12, 2) NOT NULL default '0.00' COMMENT '资源价值',
+ `identifier` varchar(50) NOT NULL default '与CP对应资源标识' COMMENT '标识符',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
+ `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_testing_resource_type` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(120) NOT NULL COMMENT '测试资源类型名称',
+ `game_id` int(11) NOT NULL COMMENT '游戏ID',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
+ `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_testing_resource_order` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `batch_id` int(11) NOT NULL COMMENT '批次ID',
+ `order_no` varchar(30) NOT NULL COMMENT '订单号',
+ `testing_resource_id` int(11) NOT NULL COMMENT '测试资源ID',
+ `num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量'
+ `amount` decimal(12, 2) not null default '0.00' comment '申请金额',
+ `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_testing_resource_batch` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `batch_no` varchar(30) NOT NULL COMMENT '批次号',
+ `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏ID',
+ `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
+ `role_id` int(11) NOT NULL DEFAULT '0' COMMENT '角色ID',
+ `amount` decimal(12, 2) not null default '0.00' comment '申请金额',
+ `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常',
+ `promote_id` int(11) not null default 0 COMMENT '推广员ID',
+ `verify_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未审核 1 审核通过 1 未审核通过',
+ `verify_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
+ `verify_time` 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`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/Public/Home/css/20180207/common.css b/Public/Home/css/20180207/common.css
index 1c304c5ac..83d318091 100644
--- a/Public/Home/css/20180207/common.css
+++ b/Public/Home/css/20180207/common.css
@@ -364,6 +364,12 @@ input,select,button{outline:none;font-size:14px;font-family:inherit;}
width: 380px;
}
+.layui-layer-content .layer-box .form-group textarea.form-input {
+ height: auto;
+ padding: 10px 15px;
+ width: auto;
+}
+
.layui-layer-content .layer-box .form-group .radio-item {
margin-right: 5px;
line-height: 34px;
From c0fe59864c401511ff50c06eedbfb9b0a3645815 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Tue, 11 Aug 2020 20:29:11 +0800
Subject: [PATCH 02/57] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Common/Common/extend.php | 10 +-
.../TestingResourceController.class.php | 21 ++--
.../View/default/TestingResource/apply.html | 96 +++++++++++++++++++
.../View/default/TestingResource/index.html | 37 +++++--
4 files changed, 150 insertions(+), 14 deletions(-)
create mode 100644 Application/Home/View/default/TestingResource/apply.html
diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php
index 6a50765dc..79d5ba2c7 100644
--- a/Application/Common/Common/extend.php
+++ b/Application/Common/Common/extend.php
@@ -833,7 +833,15 @@ function Status_recovery($msg){
if (empty($str)) {return $title;}
$find = array('%webname%','%gamename%','%newsname%','%giftname%','%gametype%', '%catetitle%', '%gamedevice%');
- $replace = array($title,$array['game_name'],$array['news_title'],$array['giftbag_name'],$array['game_type_name'],$array['cate_title'],$array['game_device']);
+ $replace = array(
+ $title,
+ $array['game_name'] ?? '',
+ $array['news_title'] ?? '',
+ $array['giftbag_name'] ?? '',
+ $array['game_type_name'] ?? '',
+ $array['cate_title'] ?? '',
+ $array['game_device'] ?? ''
+ );
$str = str_replace($find,$replace,$str);
return preg_replace('/((-|_)+)?((%[0-9A-Za-z_]*%)|%+)((-|_)+)?/','',$str);
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index 496e2fa65..564f08db1 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -23,7 +23,6 @@ class TestingResourceController extends BaseController
$conditions = [];
$subConditions = [
- '_string' => 'user_id = tab_user_play_info.user_id',
'promote_id' => $loginPromote['id'],
];
@@ -34,8 +33,8 @@ class TestingResourceController extends BaseController
$subConditions['create_time'] = ['elt', strtotime($createTimeEnd . ' 23:59:59')];
}
- $subSql = M('testing_user', 'tab_')->field(['1'])->where($subConditions)->select(false);
- $strCondition = 'exists (' . $subSql . ')';
+ $subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
+ $strCondition = 'user_id in (' . $subSql . ')';
if ($account) {
$user = M('user', 'tab_')->field(['id'])->where('account like ' . $account . '%')->find();
@@ -69,7 +68,7 @@ class TestingResourceController extends BaseController
if (count($roles) > 0) {
$users = M('user', 'tab_')->field(['id', 'phone'])->where(['id' => ['in', $userIds]])->select();
$uesrs = index_by_column('id', $users);
- $bindings = M('testing_binding', 'tab_')->field()->where(['role_id' => ['in', $roleIds]])->select();
+ $bindings = M('testing_binding', 'tab_')->where(['role_id' => ['in', $roleIds]])->select();
$bindings = index_by_column('role_id', $bindings);
$bindingRoleIds = array_column($bindings, 'bind_role_id');
if (count($bindings) > 0) {
@@ -115,12 +114,13 @@ class TestingResourceController extends BaseController
{
$loginPromote = $this->getLoginPromote();
$accountsStr = trim(I('accounts', ''), ',');
- if ($accountsStr = '') {
+ if ($accountsStr == '') {
return $this->ajaxReturn(['status' => 0, 'message' => '请输入测试资源账号']);
}
$accounts = explode(',', $accountsStr);
$accounts = array_unique($accounts);
$existAccounts = M('testing_user', 'tab_')->where(['user_account' => ['in', $accounts]])->getField('user_account', true);
+ $existAccounts = $existAccounts ?? [];
$existCount = count($existAccounts);
$newAccounts = array_diff($accounts, $existAccounts);
$errorCount = 0;
@@ -145,7 +145,7 @@ class TestingResourceController extends BaseController
$successCount ++;
}
}
- return $this->ajaxReturn(['status' => 1, 'message' => '请输入测试资源账号', 'data' => [
+ return $this->ajaxReturn(['status' => 1, 'message' => '请求成功', 'data' => [
'errorCount' => $errorCount,
'successCount' => $successCount,
'existCount' => $existCount,
@@ -196,6 +196,15 @@ class TestingResourceController extends BaseController
}
public function apply()
+ {
+ $records = [];
+ $pagination = '';
+ $this->assign('records', $records);
+ $this->assign('pagination', $pagination);
+ $this->display();
+ }
+
+ public function doApply()
{
$records = I('records', []);
$batchNo = '';
diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html
new file mode 100644
index 000000000..f1e997459
--- /dev/null
+++ b/Application/Home/View/default/TestingResource/apply.html
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+ {$pagination}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Home/View/default/TestingResource/index.html b/Application/Home/View/default/TestingResource/index.html
index 8803d252b..76a91aa4f 100644
--- a/Application/Home/View/default/TestingResource/index.html
+++ b/Application/Home/View/default/TestingResource/index.html
@@ -156,7 +156,7 @@
-
@@ -259,7 +259,7 @@
@@ -293,19 +293,36 @@
timepicker: false
});
+ $('#apply').click(function () {
+ var title = '添加测试资源申请'
+ var url = "{:U('TestingResource/apply')}"
+
+ layer.open({
+ title: title,
+ type: 2,
+ content: [url , 'no'],
+ area: ['1000px', '550px'],
+ zIndex: 250,
+ scrollbar: false,
+ })
+ })
+
$('#add').click(function () {
var box = $('#add-box')
layer.open({
title: '新增测试账号',
type: 1,
content: box,
- area: ['600px', '330px'],
+ area: ['800px', '330px'],
zIndex: 250,
})
});
$('#add-submit').on({
click: function () {
+ var box = $('#add-box')
+ var accounts = box.find('[name=accounts]').val()
+ console.log(accounts)
$.ajax({
async: false,
url: "{:U('addTestingUsers')}",
@@ -314,12 +331,18 @@
data: { accounts: accounts },
success: function (result) {
if (result.status == 0) {
- layer.msg(result.msg);
+ layer.msg(result.message);
} else {
- layer.msg('修改成功');
- setTimeout(function () {
+ var message = '成功' + result.data.successCount + '个, 失败' + result.data.errorCount + '个, 已存在' + result.data.existCount + '个。'
+ layer.confirm(message, {
+ btn: ['确定'] //按钮
+ }, function(){
+ location.reload();
+ })
+ // layer.msg(result.message);
+ /* setTimeout(function () {
location.reload();
- }, 1000);
+ }, 1000); */
}
},
error: function () {
From 3383b3d2d9c0ee5d83e3aa9b87f076e475451196 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Wed, 12 Aug 2020 20:04:39 +0800
Subject: [PATCH 03/57] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/GameApiController.class.php | 27 ++
Application/Base/Tool/GameCatClient.class.php | 84 ++++
.../TestingResourceController.class.php | 199 +++++++-
.../View/default/TestingResource/apply.html | 455 ++++++++++++++++--
.../View/default/TestingResource/batches.html | 0
.../View/default/TestingResource/index.html | 7 +-
.../View/default/TestingResource/orders.html | 0
Data/update.sql | 4 +-
8 files changed, 707 insertions(+), 69 deletions(-)
create mode 100644 Application/Admin/Controller/GameApiController.class.php
create mode 100644 Application/Base/Tool/GameCatClient.class.php
create mode 100644 Application/Home/View/default/TestingResource/batches.html
create mode 100644 Application/Home/View/default/TestingResource/orders.html
diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php
new file mode 100644
index 000000000..47fd29d50
--- /dev/null
+++ b/Application/Admin/Controller/GameApiController.class.php
@@ -0,0 +1,27 @@
+api('get-pay-type');
+
+ }
+}
diff --git a/Application/Base/Tool/GameCatClient.class.php b/Application/Base/Tool/GameCatClient.class.php
new file mode 100644
index 000000000..8204dbb3f
--- /dev/null
+++ b/Application/Base/Tool/GameCatClient.class.php
@@ -0,0 +1,84 @@
+ ['uri' => '/api/pay/GetPayType', 'method' => 'get'],
+ 'internal-pay' => ['uri' => '/api/pay/InternalPayOrder/yushi', 'method' => 'post'],
+ 'check-role' => ['uri' => '/api/pay/CheckActorID', 'method' => 'get']
+ ];
+
+ public function __construct()
+ {
+ $this->client = new Client([
+ 'base_uri' => C('GAME_CAT_URL'),
+ '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 ['code' => '1000', 'message' => '接口请求错误。' . ($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);
+ $params['key'] = C('GAME_CAT_KEY');
+ return md5(http_build_query($params));
+ }
+}
\ No newline at end of file
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index 564f08db1..06dc7680e 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -6,6 +6,8 @@ namespace Home\Controller;
use Base\Model\PromoteModel;
use Base\Service\PromoteService;
use OSS\Core\OssException;
+use Base\Tool\GameCatClient;
+use Think\Model;
class TestingResourceController extends BaseController
{
@@ -199,6 +201,12 @@ class TestingResourceController extends BaseController
{
$records = [];
$pagination = '';
+
+ /**
+ * @todo 目前固定游戏猫
+ */
+ $games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select();
+ $this->assign('games', $games);
$this->assign('records', $records);
$this->assign('pagination', $pagination);
$this->display();
@@ -206,21 +214,70 @@ class TestingResourceController extends BaseController
public function doApply()
{
+ $gameId = I('game_id', 0);
+ $roleId = I('role_id', 0);
+ $serverId = I('server_id', 0);
+ $userAccount = I('user_account', '');
$records = I('records', []);
- $batchNo = '';
$loginPromote = $this->getLoginPromote();
+ $resources = [];
+ /**
+ * @todo 目前仅限游戏猫
+ */
+ if (!in_array($gameId, [229, 230])) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '该游戏不可申请资源']);
+ } else {
+ $resources = $this->getGameCatResources();
+ }
+
+ $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_id' => $user['id']])->find();
+ if (is_null($testingUser)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']);
+ }
+
+ $server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find();
+ if (is_null($server)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '区服不存在']);
+ }
+
+ $role = M('user_play_info', 'tab_')
+ ->field(['id', 'role_id'])
+ ->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id']])
+ ->find();
+ if (is_null($role)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在']);
+ }
+
$amount = 0;
- foreach ($records as $record) {
- $amount += $record['num'] * $record['value'];
+ foreach ($records as $key => $record) {
+ if (isset($resources[$record['resource_id']])) {
+ $value = $resources[$record['resource_id']]['amount'];
+ $records[$key]['value'] = $value;
+ $records[$key]['resource_name'] = $resources[$record['resource_id']]['name'];
+ $amount += $record['num'] * $value;
+ } else {
+ return $this->ajaxReturn(['status' => 0, 'message' => '含有资源内容不存在']);
+ }
}
+ $batchNo = date('YmdHis') . substr(md5($loginPromote['id'] . strval(microtime(true)) . rand(0, 9999)), 8, 16);
+
try {
+ $model = new Model();
+ $model->startTrans();
+
$batch = [
'batch_id' => $batchId,
- 'order_no' => $orderNo,
- 'user_id' => $record['user_id'],
- 'game_id' => $record['game_id'],
+ 'batch_no' => $batchNo,
+ 'user_id' => $testingUser['user_id'],
+ 'game_id' => $gameId,
+ 'role_id' => $roleId,
+ 'server_id' => $serverId,
'promote_id' => $loginPromote['id'],
'amount' => $amount,
'status' => 0,
@@ -236,39 +293,65 @@ class TestingResourceController extends BaseController
$order = [
'batch_id' => $batchId,
'order_no' => $orderNo,
- 'testing_resource_id' => $record['resource_id'],
+ 'ref_id' => $record['resource_id'],
+ 'ref_name' => $record['resource_name'],
'num' => $record['num'],
'amount' => $record['num'] * $record['value'],
'remark' => $record['remark'],
];
M('testing_resource_order')->add($order);
}
+ $model->commit();
+ return $this->ajaxReturn(['status' => 1, 'message' => '申请成功,等待审核']);
} catch (\Exception $e) {
-
+ $model->rollback();
+ return $this->ajaxReturn(['status' => 0, 'message' => '系统异常']);
}
}
public function bindRole()
{
$testingUserId = I('testing_user_id', 0);
- $userAccount = I('user_account', '');
- $roleId = I('role_id', '');
+ $testingRoleId = I('testing_role_id', 0);
+ $bindUserId = I('bind_user_id', 0);
+ $bindRoleId = I('bind_role_id', 0);
- $user = M('user', 'tab_')->field(['id', 'account'])->where(['account' => $userAccount])->find();
- if (is_null($user)) {
+ $bindUser = M('user', 'tab_')->field(['id', 'account'])->where(['id' => $bindUserId])->find();
+ if (is_null($bindUser)) {
return $this->ajaxReturn(['status' => 0, 'message' => '用户不存在']);
}
- $existBind = M('testing_user', 'tab_')->field(['id'])->where(['bind_user_id' => $user['id']])->find();
+ $testingUser = M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->find();
+ if (is_null($testingUser)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']);
+ }
+
+ $testingRole = M('user_play_info', 'tab_')
+ ->field(['id', 'role_id'])
+ ->where(['id' => $testingRoleId])
+ ->find();
+ if (is_null($testingRole)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '测试账号角色不存在']);
+ }
+ $bindRole = M('user_play_info', 'tab_')
+ ->field(['id', 'role_id'])
+ ->where(['id' => $bindRoleId])
+ ->find();
+ if (is_null($bindRole)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '玩家角色不存在']);
+ }
+
+
+ $existBind = M('testing_user', 'tab_')->field(['id'])->where(['bind_user_id' => $bindUser['id']])->find();
if ($existBind) {
return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号已被绑定']);
}
M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->save([
- 'role_id' => $roleId,
- 'bind_user_id' => $user['id'],
- 'bind_user_account' => $user['account'],
- 'bind_role_id' => $roleId,
+ 'role_id' => $testingRole['id'],
+ 'bind_user_id' => $bindUser['id'],
+ 'bind_user_account' => $bindUser['account'],
+ 'bind_role_id' => $bindRoleId,
]);
return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
}
@@ -277,4 +360,86 @@ class TestingResourceController extends BaseController
{
}
+
+ public function getServers()
+ {
+ $gameId = I('game_id', 0);
+ $map = [];
+ $map['game_id'] = $gameId;
+ $servers = M('server', 'tab_')
+ ->field('id,server_name,server_id')
+ ->where($map)
+ ->order('server_id asc')
+ ->select();
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
+ }
+
+ public function getResourceTypes()
+ {
+ $gameId = I('game_id', 0);
+ $resourceTypes = [];
+
+ /**
+ * @todo 目前固定游戏猫
+ */
+ if (in_array($gameId, [229, 230])) {
+ $resourceTypes[] = ['id' => 1, 'name' => '通用'];
+ }
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
+ }
+
+ public function getResources()
+ {
+ $typeId = I('type_id', 0);
+
+ $resources = [];
+
+ /**
+ * @todo 目前固定游戏猫资源类型ID
+ */
+ if ($typeId == 1) {
+ $resources = $this->getGameCatResources();
+ }
+
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
+ }
+
+ 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' => '区服不存在']);
+ }
+ $roles = M('user_play_info', 'tab_')
+ ->field(['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]]);
+ }
+
+ private function getGameCatResources()
+ {
+ $resources = [];
+ $gameCatClient = new GameCatClient();
+ $result = $gameCatClient->api('get-pay-type');
+ if ($result['code'] == 1) {
+ $payTypeList = $result['paytypelist'];
+ foreach ($payTypeList as $item) {
+ $resources[$item['PayType']] = [
+ 'ref_id' => $item['PayType'],
+ 'name' => $item['Text'],
+ 'amount' => $item['Amount'],
+ ];
+ }
+ }
+ return $resources;
+ }
+
+ private function getRemainAmount($user)
+ {
+
+ }
}
\ No newline at end of file
diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html
index f1e997459..e0f176b39 100644
--- a/Application/Home/View/default/TestingResource/apply.html
+++ b/Application/Home/View/default/TestingResource/apply.html
@@ -25,71 +25,434 @@
color: #fff;
border: none;
border-radius: 4px;
+ cursor: pointer;
}
- .normal_table td button.danger-btn {
+ .normal_table td button.delete-row {
background-color: rgb(249,104,104);
}
+ .btn-row {
+ position: relative;
+ font-size: 11px;
+ margin-top: 28px;
+ text-align: center;
+ }
+ .btn-row button {
+ width: 70px;
+ height: 35px;
+ display: block;
+ background: #409eff;
+ color: #fff;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ display: inline-block;
+ }
+ .btn-row button.close-btn {
+ background: #E5E5E5;
+ color: #535875;
+ }
+ .form-group .static-input {
+ line-height: 32px;
+ display: inline-block;
+ }
+ .trunk-search button {
+ width: 70px;
+ height: 35px;
+ display: block;
+ background: #409eff;
+ color: #fff;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ display: inline-block;
+ }
+ .info-row {
+ margin-top: 10px;
+ }
+ .info-row button {
+ width: 120px;
+ height: 25px;
+ display: block;
+ background: #E5E5E5;
+ color: #535875;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ display: inline-block;
+ margin-left: 10px;
+ }
+
diff --git a/Application/Home/View/default/TestingResource/batches.html b/Application/Home/View/default/TestingResource/batches.html
new file mode 100644
index 000000000..e69de29bb
diff --git a/Application/Home/View/default/TestingResource/index.html b/Application/Home/View/default/TestingResource/index.html
index 76a91aa4f..986f073dd 100644
--- a/Application/Home/View/default/TestingResource/index.html
+++ b/Application/Home/View/default/TestingResource/index.html
@@ -240,9 +240,6 @@
@@ -262,7 +259,7 @@
确定
-
+
@@ -313,7 +310,7 @@
title: '新增测试账号',
type: 1,
content: box,
- area: ['800px', '330px'],
+ area: ['700px', '330px'],
zIndex: 250,
})
});
diff --git a/Application/Home/View/default/TestingResource/orders.html b/Application/Home/View/default/TestingResource/orders.html
new file mode 100644
index 000000000..e69de29bb
diff --git a/Data/update.sql b/Data/update.sql
index 42af73acb..782acec80 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2452,7 +2452,8 @@ CREATE TABLE `tab_testing_resource_order` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`batch_id` int(11) NOT NULL COMMENT '批次ID',
`order_no` varchar(30) NOT NULL COMMENT '订单号',
- `testing_resource_id` int(11) NOT NULL COMMENT '测试资源ID',
+ `ref_id` varchar(30) NOT NULL COMMENT '测试资源ID(第三方)',
+ `ref_name` varchar(150) NOT NULL COMMENT '测试资源名称(第三方)',
`num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量'
`amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
@@ -2464,6 +2465,7 @@ CREATE TABLE `tab_testing_resource_batch` (
`batch_no` varchar(30) NOT NULL COMMENT '批次号',
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏ID',
`user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
+ `server_id` int(11) NOT NULL DEFAULT '0' COMMENT '区服ID',
`role_id` int(11) NOT NULL DEFAULT '0' COMMENT '角色ID',
`amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常',
From 9c59ba06e20153a22fd9a17fc93f9dd4ed24e2b7 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Thu, 13 Aug 2020 20:30:32 +0800
Subject: [PATCH 04/57] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/GameApiController.class.php | 2 +-
Application/Base/Tool/GameCatClient.class.php | 24 +-
.../TestingResourceController.class.php | 175 ++++++---
.../View/default/TestingResource/apply.html | 150 ++++++--
.../View/default/TestingResource/batches.html | 353 ++++++++++++++++++
.../View/default/TestingResource/index.html | 13 +-
.../View/default/TestingResource/orders.html | 143 +++++++
Data/update.sql | 11 +-
8 files changed, 776 insertions(+), 95 deletions(-)
diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php
index 47fd29d50..d8b43e514 100644
--- a/Application/Admin/Controller/GameApiController.class.php
+++ b/Application/Admin/Controller/GameApiController.class.php
@@ -22,6 +22,6 @@ class GameApiController extends Think {
public function getGameCatPayTypes() {
$gameCatClient = new GameCatClient();
$result = $gameCatClient->api('get-pay-type');
-
+ var_dump($result);
}
}
diff --git a/Application/Base/Tool/GameCatClient.class.php b/Application/Base/Tool/GameCatClient.class.php
index 8204dbb3f..0b23bac3d 100644
--- a/Application/Base/Tool/GameCatClient.class.php
+++ b/Application/Base/Tool/GameCatClient.class.php
@@ -10,15 +10,24 @@ use GuzzleHttp\Exception\RequestException;
*/
class GameCatClient
{
- const SIGN_NAME = 'Sign';
+ const SIGN_NAME = 'sign';
const SUCCESS = '0000';
protected $client;
private $apis = [
- 'get-pay-type' => ['uri' => '/api/pay/GetPayType', 'method' => 'get'],
- 'internal-pay' => ['uri' => '/api/pay/InternalPayOrder/yushi', 'method' => 'post'],
- 'check-role' => ['uri' => '/api/pay/CheckActorID', 'method' => 'get']
+ 'get-pay-type' => ['uri' => '/game/support/items/v1', 'method' => 'post'],
+ 'internal-pay' => ['uri' => '/game/support/provide/v1', 'method' => 'post'],
+ ];
+
+ private $appIds = [
+ 'andriod' => 1746,
+ 'ios' => 1747,
+ ];
+
+ private $channelIds = [
+ 'andriod' => 11595,
+ 'ios' => 11596,
];
public function __construct()
@@ -35,6 +44,13 @@ class GameCatClient
if (is_null($api)) {
throw new \Exception('接口不存在');
}
+ $deviceType = 'andriod';
+ if (isset($params['device_type'])) {
+ $deviceType = $params['device_type'];
+ unset($params['device_type']);
+ }
+ $params['appId'] = $this->appIds[$deviceType] ?? $this->appIds['andriod'];
+ $params['channelId'] = $this->channelIds[$deviceType] ?? $this->channelIds['andriod'];
$params[self::SIGN_NAME] = $this->sign($params);
try {
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index 06dc7680e..3f4b050d5 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -24,9 +24,7 @@ class TestingResourceController extends BaseController
$loginPromote = $this->getLoginPromote();
$conditions = [];
- $subConditions = [
- 'promote_id' => $loginPromote['id'],
- ];
+ $subConditions = [];
if ($createTimeStart) {
$subConditions['create_time'] = ['egt', strtotime($createTimeStart . ' 00:00:00')];
@@ -38,6 +36,9 @@ class TestingResourceController extends BaseController
$subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
$strCondition = 'user_id in (' . $subSql . ')';
+ $promoteService = new PromoteService();
+ $strCondition .= ' and promote_id in (' . $promoteService->subInSql($loginPromote) . ')';
+
if ($account) {
$user = M('user', 'tab_')->field(['id'])->where('account like ' . $account . '%')->find();
if ($user) {
@@ -74,17 +75,23 @@ class TestingResourceController extends BaseController
$bindings = index_by_column('role_id', $bindings);
$bindingRoleIds = array_column($bindings, 'bind_role_id');
if (count($bindings) > 0) {
- $bindingRoles = M('user_play_info', 'tab_')->field(['id', 'role_name'])->where(['id' => ['in', $bindingRoleIds]])->select();
+ $bindingRoles = M('user_play_info', 'tab_')->field(['id', 'role_id', 'role_name', 'user_account'])->where(['id' => ['in', $bindingRoleIds]])->select();
$bindingRoles = index_by_column('id', $bindingRoles);
}
}
+ if (count($bindingRoles) > 0) {
+ M('spend', 'tab_')->where();
+ }
+
+
$records = [];
foreach ($roles as $role) {
$user = $users[$role['user_id']] ?? null;
$binding = $bindings[$role['id']] ?? null;
$bindingRole = $binding && $bindingRoles[$binding['bind_role_id']] ? $bindingRoles[$binding['bind_role_id']] : null;
$records[] = [
+ 'id' => $role['id'],
'game_name' => $role['game_name'],
'server_name' => $role['server_name'],
'server_id' => $role['server_id'],
@@ -94,7 +101,7 @@ 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'] : 1200,
+ 'base_quota' => $binding ? $binding['base_quota'] : 0,
'other_quota' => $binding ? $binding['other_quota'] : 0,
'quota' => 0,
'verify_amount' => 0,
@@ -128,7 +135,11 @@ class TestingResourceController extends BaseController
$errorCount = 0;
$successCount = 0;
if (count($newAccounts)) {
- $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts]])->select();
+
+ $promoteService = new PromoteService();
+ $strCondition = 'promote_id in (' . $promoteService->subInSql($loginPromote) . ')';
+
+ $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts], '_string' => $strCondition])->select();
$errorAccounts = array_diff($newAccounts, array_column($users, 'account'));
$errorCount = count($errorAccounts);
foreach ($users as $user) {
@@ -139,7 +150,6 @@ class TestingResourceController extends BaseController
'user_id' => $user['id'],
'user_account' => $user['account'],
'status' => 1,
- 'promote_id' => $loginPromote['id'],
'create_time' => time(),
'update_time' => time(),
];
@@ -191,6 +201,48 @@ class TestingResourceController extends BaseController
$query = M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc')->select();
list($batches, $pagination, $count) = $this->paginate($query);
+ $records = [];
+ foreach ($batches as $batch) {
+ $records[] = [
+ 'id' => $batch['id'],
+ 'batch_no' => $batch['batch_no'],
+ 'create_time' => date('Y-m-d H:i:s', $batch['create_time']),
+ 'game_name' => $batch['game_id'],
+ 'server_name' => $batch['server_id'],
+ 'role_name' => $batch['role_id'],
+ 'user_account' => $batch['user_id'],
+ 'user_phone' => $batch['batch_no'],
+ 'creator_account' => $batch['batch_no'],
+ 'history_provide_amount' => 0.00,
+ 'apply_amount' => $batch['apply_amount'],
+ 'provide_amount' => $batch['provide_amount'],
+ 'remark' => $batch['remark'],
+ 'verify_status_text' => $batch['verify_status'],
+ 'verify_time' => date('Y-m-d H:i:s', $batch['verify_time']),
+ 'status_text' => $batch['status'],
+ 'provide_status_text' => $batch['provide_status'],
+ 'provide_time' => date('Y-m-d H:i:s', $batch['provide_time']),
+ 'content' => $content,
+ ];
+ }
+
+ $this->assign('count', $count);
+ $this->assign('pagination', $pagination);
+ $this->assign('records', $records);
+ $this->display();
+ }
+
+ public function orders()
+ {
+ $batchId = I('batch_id', 0);
+
+ $query = M('testing_resource_order', 'tab_')->where(['batch_id' => $batchId])->order('create_time desc')->select();
+ list($orders, $pagination, $count) = $this->paginate($query);
+
+ /**
+ * @todo
+ */
+
$this->assign('count', $count);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
@@ -199,16 +251,31 @@ class TestingResourceController extends BaseController
public function apply()
{
- $records = [];
- $pagination = '';
+ $roleId = I('role_id', 0);
+
+ $role = null;
+ if ($roleId > 0) {
+ $role = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name'])->where(['id' => $roleId])->find();
+ }
+
+ $servers = [];
+ $bindingRole = null;
+ if ($role) {
+ $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select();
+ $binding = M('testing_binding', 'tab_')->where(['role_id' => $roleId])->find();
+ if ($binding) {
+ $bindingRole = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name'])->where(['id' => $binding['bind_role_id']])->find();
+ }
+ }
/**
* @todo 目前固定游戏猫
*/
$games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select();
$this->assign('games', $games);
- $this->assign('records', $records);
- $this->assign('pagination', $pagination);
+ $this->assign('servers', $servers);
+ $this->assign('bindingRole', $bindingRole);
+ $this->assign('role', $role);
$this->display();
}
@@ -311,56 +378,56 @@ class TestingResourceController extends BaseController
public function bindRole()
{
- $testingUserId = I('testing_user_id', 0);
$testingRoleId = I('testing_role_id', 0);
- $bindUserId = I('bind_user_id', 0);
$bindRoleId = I('bind_role_id', 0);
- $bindUser = M('user', 'tab_')->field(['id', 'account'])->where(['id' => $bindUserId])->find();
- if (is_null($bindUser)) {
- return $this->ajaxReturn(['status' => 0, 'message' => '用户不存在']);
- }
-
- $testingUser = M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->find();
- if (is_null($testingUser)) {
- return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']);
- }
-
$testingRole = M('user_play_info', 'tab_')
- ->field(['id', 'role_id'])
+ ->field(['id', 'role_id', 'user_id'])
->where(['id' => $testingRoleId])
->find();
if (is_null($testingRole)) {
return $this->ajaxReturn(['status' => 0, 'message' => '测试账号角色不存在']);
}
+
+ $testingUser = M('testing_user', 'tab_')->where(['user_id' => $testingRole['user_id']])->find();
+ if (is_null($testingUser)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']);
+ }
+
$bindRole = M('user_play_info', 'tab_')
- ->field(['id', 'role_id'])
+ ->field(['id', 'role_id', 'user_id'])
->where(['id' => $bindRoleId])
->find();
if (is_null($bindRole)) {
return $this->ajaxReturn(['status' => 0, 'message' => '玩家角色不存在']);
}
-
- $existBind = M('testing_user', 'tab_')->field(['id'])->where(['bind_user_id' => $bindUser['id']])->find();
+ $bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find();
+ if ($bindIsTesting) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号为测试账号,无法绑定']);
+ }
+
+ $existBind = M('testing_binding', 'tab_')->field(['id'])->where(['bind_role_id' => $bindRoleId])->find();
if ($existBind) {
- return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号已被绑定']);
+ return $this->ajaxReturn(['status' => 0, 'message' => '该玩家角色已被绑定']);
+ }
+
+ $testExistBind = M('testing_binding', 'tab_')->field(['id'])->where(['role_id' => $testingRoleId])->find();
+ if ($testExistBind) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '该测试账号角色已绑定有角色']);
}
- M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->save([
+ M('testing_binding', 'tab_')->add([
+ 'user_id' => $testingRole['user_id'],
'role_id' => $testingRole['id'],
- 'bind_user_id' => $bindUser['id'],
- 'bind_user_account' => $bindUser['account'],
- 'bind_role_id' => $bindRoleId,
+ 'bind_user_id' => $bindRole['user_id'],
+ 'bind_role_id' => $bindRole['id'],
+ 'create_time' => time(),
+ 'update_time' => time()
]);
return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
}
- public function getRolesByUser()
- {
-
- }
-
public function getServers()
{
$gameId = I('game_id', 0);
@@ -382,8 +449,10 @@ class TestingResourceController extends BaseController
/**
* @todo 目前固定游戏猫
*/
- if (in_array($gameId, [229, 230])) {
+ if ($gameId == 229) {
$resourceTypes[] = ['id' => 1, 'name' => '通用'];
+ } elseif ($gameId == 230) {
+ $resourceTypes[] = ['id' => 2, 'name' => '通用'];
}
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
}
@@ -397,8 +466,10 @@ class TestingResourceController extends BaseController
/**
* @todo 目前固定游戏猫资源类型ID
*/
- if ($typeId == 1) {
- $resources = $this->getGameCatResources();
+ if ($typeId == 2) {
+ $resources = $this->getGameCatResources('ios');
+ } elseif ($typeId == 1) {
+ $resources = $this->getGameCatResources('andriod');
}
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]);
@@ -413,25 +484,29 @@ class TestingResourceController extends BaseController
if (is_null($server)) {
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_name'])
->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']])
->select();
- return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]);
+ return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]);
}
- private function getGameCatResources()
+ private function getGameCatResources($deviceType)
{
$resources = [];
$gameCatClient = new GameCatClient();
- $result = $gameCatClient->api('get-pay-type');
- if ($result['code'] == 1) {
- $payTypeList = $result['paytypelist'];
- foreach ($payTypeList as $item) {
- $resources[$item['PayType']] = [
- 'ref_id' => $item['PayType'],
- 'name' => $item['Text'],
- 'amount' => $item['Amount'],
+ $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'],
];
}
}
diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html
index e0f176b39..9c09f1b07 100644
--- a/Application/Home/View/default/TestingResource/apply.html
+++ b/Application/Home/View/default/TestingResource/apply.html
@@ -88,30 +88,44 @@