From 247c4e9aae744f3aade1480fe8672f4414273ed2 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Tue, 18 Aug 2020 18:32:34 +0800
Subject: [PATCH 1/2] ss
---
.../TestingResourceController.class.php | 44 ++++++++++---------
.../View/default/TestingResource/index.html | 8 ++--
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index ba98ac36b..a75ffe8f3 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -180,7 +180,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'] : 0,
+ 'base_quota' => $binding ? $binding['base_quota'] : 300,
'other_quota' => $binding ? $binding['other_quota'] : 0,
'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0,
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
@@ -487,9 +487,9 @@ class TestingResourceController extends BaseController
}
$binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find();
- if (is_null($binding)) {
+ /* if (is_null($binding)) {
return $this->ajaxReturn(['status' => 0, 'message' => '该角色未绑定玩家角色']);
- }
+ } */
$user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find();
if (is_null($user)) {
@@ -508,7 +508,7 @@ class TestingResourceController extends BaseController
$promoteService = new PromoteService();
$role = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'promote_id'])
+ ->field(['id', 'role_id', 'promote_id', 'game_id'])
->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id'], 'role_id' => $roleId])
->find();
if (is_null($role)) {
@@ -519,20 +519,22 @@ class TestingResourceController extends BaseController
return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']);
}
- $bindingRole = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id'])
- ->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']])
- ->find();
- if (is_null($bindingRole)) {
- return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']);
- }
- $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
- if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) {
- return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']);
- }
-
- if ($testPromote['id'] != $bindPromote['id']) {
- return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']);
+ $bindingRole = null;
+ if ($binding) {
+ $bindingRole = M('user_play_info', 'tab_')
+ ->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id'])
+ ->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']])
+ ->find();
+ if (is_null($bindingRole)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']);
+ }
+ $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
+ if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']);
+ }
+ /* if ($testPromote['id'] != $bindPromote['id']) {
+ return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']);
+ } */
}
$amount = 0;
@@ -553,7 +555,7 @@ class TestingResourceController extends BaseController
}
}
- $remainQuota = $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id']);
+ $remainQuota = $this->getRemainQuota($role['game_id'], $bindingRole ? $bindingRole['role_id'] : null, $role['role_id']);
if ($amount > $remainQuota) {
return $this->ajaxReturn(['status' => 0, 'message' => '额度不足']);
}
@@ -643,9 +645,9 @@ class TestingResourceController extends BaseController
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号所属推广员异常']);
}
- if ($testPromote['id'] != $bindPromote['id']) {
+ /* if ($testPromote['id'] != $bindPromote['id']) {
return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号与测试账号非同一推广员']);
- }
+ } */
$bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find();
if ($bindIsTesting) {
diff --git a/Application/Home/View/default/TestingResource/index.html b/Application/Home/View/default/TestingResource/index.html
index f7f9fdefd..c08639370 100644
--- a/Application/Home/View/default/TestingResource/index.html
+++ b/Application/Home/View/default/TestingResource/index.html
@@ -181,8 +181,8 @@
角色名称 |
绑定账号 |
绑定角色 |
-
-
+ 初始额度 |
+ 额外额度 |
累计额度 |
待审核金额 |
累计发放资源 |
@@ -214,8 +214,8 @@
{$record.role_name} |
{$record.bind_user_account} |
{$record.bind_role_name} |
-
-
+ {$record.base_quota} |
+ {$record.other_quota} |
{$record.quota} |
{$record.verify_amount} |
{$record.provide_amount} |
From 06c4d5f1f1c2d2be35ed8b6c57219fd6de77ee3d Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Wed, 19 Aug 2020 10:15:45 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E8=B5=84=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/GameApiController.class.php | 8 +++++
.../Service/TestingResourceService.class.php | 27 ++++++++++++--
.../TestingResourceController.class.php | 36 +++++++++++--------
.../View/default/Public/promote_base.html | 2 ++
.../View/default/TestingResource/batches.html | 29 ++++++++++-----
.../View/default/TestingResource/orders.html | 11 +++++-
Data/update.sql | 3 +-
7 files changed, 89 insertions(+), 27 deletions(-)
diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php
index 0bb388ebd..bdb89b333 100644
--- a/Application/Admin/Controller/GameApiController.class.php
+++ b/Application/Admin/Controller/GameApiController.class.php
@@ -19,6 +19,14 @@ class GameApiController extends Think {
C(api('Config/lists'));
}
+ public function verify()
+ {
+ $batch = M('testing_resource_batch', 'tab_')->where(['id' => 3])->find();
+ $service = new TestingResourceService();
+ // $service->verify($batch);
+ $service->provide($batch);
+ }
+
public function provice() {
$role = [
'role_id' => '6810778',
diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php
index d8cd58347..24bc4ce46 100644
--- a/Application/Base/Service/TestingResourceService.class.php
+++ b/Application/Base/Service/TestingResourceService.class.php
@@ -53,12 +53,16 @@ class TestingResourceService
public function provide($batch)
{
+ if ($batch['verify_status'] != 1) {
+ throw new \Exception('该申请未审核通过');
+ }
+
if ($batch['provide_status'] != 0) {
throw new \Exception('发放状态异常');
}
$role = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'user_id', 'promote_id'])
+ ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version'])
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
->find();
$orders = M('testing_resource_order', 'tab_')
@@ -75,9 +79,10 @@ class TestingResourceService
if (!$result['status']) {
$hasError = true;
$orderData['provide_status'] = 2;
+ } else {
+ $orderData['provide_status'] = 1;
}
$provideAmount += round($order['ref_amount'] * $order['num'], 2);
- $orderData['provide_status'] = 1;
$orderData['provide_time'] = time();
M('testing_resource_order', 'tab_')
->where(['id' => $order['id']])
@@ -87,6 +92,8 @@ class TestingResourceService
$batchData = [];
if ($hasError) {
$batchData['provide_status'] = 2;
+ } else {
+ $batchData['provide_status'] = 1;
}
$batchData['provide_time'] = time();
$batchData['provide_amount'] = $provideAmount;
@@ -98,6 +105,22 @@ class TestingResourceService
public function provideFromGameCat($order, $role)
{
+ var_dump([
+ 'roleId' => $role['role_id'],
+ 'amount' => $order['ref_amount'],
+ 'supportItem' => $order['ref_id'],
+ 'supportType' => '0',
+ 'channelUid' => $role['user_account'],
+ 'applyRemark' => $order['remark'],
+ 'applyId' => $order['order_no'],
+ 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios',
+ ]);
+ return [
+ 'status' => true,
+ 'message' => '发送成功',
+ 'code' => 1,
+ ];
+
$gameCatClient = new GameCatClient();
$result = $gameCatClient->api('provide', [
'roleId' => $role['role_id'],
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index a75ffe8f3..07baaa1de 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -12,6 +12,10 @@ use Base\Service\TestingResourceService;
class TestingResourceController extends BaseController
{
+ private $gameBaseQuota = [
+ 229 => 300,
+ 230 => 300,
+ ];
public function index()
{
@@ -180,8 +184,8 @@ class TestingResourceController extends BaseController
'role_name' => $role['role_name'],
'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '',
'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '',
- 'base_quota' => $binding ? $binding['base_quota'] : 300,
- 'other_quota' => $binding ? $binding['other_quota'] : 0,
+ 'base_quota' => $this->gameBaseQuota[$role['game_id']] ?? 0,
+ 'other_quota' => $role['testing_other_quota'],
'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0,
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
@@ -346,7 +350,7 @@ class TestingResourceController extends BaseController
'user_phone' => $user ? $user['phone'] : '',
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
'promote_account' => $promote['account'],
- 'history_provide_amount' => 0.00,
+ // 'history_provide_amount' => 0.00,
'apply_amount' => $batch['apply_amount'],
'provide_amount' => $batch['provide_amount'],
'verify_status' => $batch['verify_status'],
@@ -413,17 +417,20 @@ class TestingResourceController extends BaseController
$this->display();
}
- private function getRemainQuota($gameId, $bindRoleId, $testingRoleId)
+ private function getRemainQuota($role, $bindRole = null)
{
- $totalQuota = M('spend', 'tab_')
- ->where(['game_id' => $gameId, 'game_player_id' => $bindRoleId])
- ->group('game_id,game_player_id')
- ->sum('pay_amount');
+ $totalQuota = $role['testing_other_quota'] + ($this->gameBaseQuota[$role['game_id']] ?? 0);
+ if (!is_null($bindRole)) {
+ $totalQuota += M('spend', 'tab_')
+ ->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id']])
+ ->group('game_id,game_player_id')
+ ->sum('pay_amount');
+ }
$providedQuota = M('testing_resource_batch', 'tab_')
- ->where(['provide_status' => [in, [1, 2]], 'game_id' => $gameId, 'role_id' => $testingRoleId])
+ ->where(['provide_status' => [in, [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']])
->sum('provide_amount');
$providingQuota = M('testing_resource_batch', 'tab_')
- ->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $gameId, 'role_id' => $testingRoleId])
+ ->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']])
->sum('apply_amount');
return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2);
}
@@ -435,7 +442,7 @@ class TestingResourceController extends BaseController
$role = null;
if ($id != 0) {
$role = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name'])
+ ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name', 'testing_other_quota'])
->where(['id' => $id])
->find();
}
@@ -461,7 +468,7 @@ class TestingResourceController extends BaseController
$this->assign('servers', $servers);
$this->assign('bindingRole', $bindingRole);
$this->assign('role', $role);
- $this->assign('quota', $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id']));
+ $this->assign('quota', $this->getRemainQuota($role, $bindingRole));
$this->display();
}
@@ -508,12 +515,13 @@ class TestingResourceController extends BaseController
$promoteService = new PromoteService();
$role = M('user_play_info', 'tab_')
- ->field(['id', 'role_id', 'promote_id', 'game_id'])
+ ->field(['id', 'role_id', 'promote_id', 'game_id', 'testing_other_quota'])
->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id'], 'role_id' => $roleId])
->find();
if (is_null($role)) {
return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在']);
}
+
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $role['promote_id']])->find();
if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $loginPromote)) {
return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']);
@@ -555,7 +563,7 @@ class TestingResourceController extends BaseController
}
}
- $remainQuota = $this->getRemainQuota($role['game_id'], $bindingRole ? $bindingRole['role_id'] : null, $role['role_id']);
+ $remainQuota = $this->getRemainQuota($role, $bindingRole);
if ($amount > $remainQuota) {
return $this->ajaxReturn(['status' => 0, 'message' => '额度不足']);
}
diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html
index 1067b8c35..5bbbdbbe4 100644
--- a/Application/Home/View/default/Public/promote_base.html
+++ b/Application/Home/View/default/Public/promote_base.html
@@ -112,11 +112,13 @@
操作日志
+
测试资源
+
申请金额 |
发放金额 |
-
-
+ 审核状态 |
+ 审核时间 |
发放状态 |
发放时间 |
@@ -136,16 +145,20 @@
{$record.user_phone} |
{$record.promote_account} |
{$record.apply_promote_account} |
- {$record.history_provide_amount} |
+
{$record.apply_amount} |
{$record.provide_amount} |
-
-
- {$record.provide_status_text} |
+
+
+ {$record.provide_status_text}
+ |
=substr($record['provide_time'], 0, 10)?>
diff --git a/Application/Home/View/default/TestingResource/orders.html b/Application/Home/View/default/TestingResource/orders.html
index 02719445e..605af3cd7 100644
--- a/Application/Home/View/default/TestingResource/orders.html
+++ b/Application/Home/View/default/TestingResource/orders.html
@@ -81,6 +81,15 @@
display: inline-block;
margin-left: 10px;
}
+ .normal_table td .status-0 {
+ color: #e6a23c;
+ }
+ .normal_table td .status-1 {
+ color: #67c23a;
+ }
+ .normal_table td .status-2 {
+ color: #f56c6c;
+ }
@@ -123,7 +132,7 @@
{$record.num} |
{$record.amount} |
{$record.remark} |
- {$record.provide_status_text} |
+ {$record.provide_status_text} |
diff --git a/Data/update.sql b/Data/update.sql
index 00504fb84..ee9ad0d4a 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2421,8 +2421,6 @@ CREATE TABLE `tab_testing_binding` (
`role_id` varchar(50) NOT NULL default '' COMMENT '角色ID',
`bind_user_id` int(11) unsigned NOT NULL default 0 COMMENT '绑定用户ID',
`bind_role_id` varchar(50) NOT NULL default '' COMMENT '绑定角色ID',
- `base_quota` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '初始额度',
- `other_quota` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '额外额度',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
PRIMARY KEY (`id`)
@@ -2486,5 +2484,6 @@ CREATE TABLE `tab_testing_resource_batch` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table tab_user_play_info add column `game_role_id` varchar(80) DEFAULT '' COMMENT '角色' after role_level;
+alter table tab_user_play_info add column `testing_other_quota` decimal(12, 2) DEFAULT '0.00' COMMENT '测试资源额外额度' after promote_account;
update tab_user_play_info set game_role_id = concat(game_id, '#', role_id);
ALTER TABLE `tab_user_play_info` ADD INDEX `index_unique_role`(`game_role_id`);
\ No newline at end of file
|