diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 174a4a507..0bb388ebd 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -26,9 +26,9 @@ class GameApiController extends Think { 'sdk_version' => 1, ]; $order = [ - 'ref_amount' => 10, - 'ref_id' => '8', - 'remark' => 'ELF测试资源发放', + 'ref_amount' => 100, + 'ref_id' => '10', + 'remark' => 'ELF测试资源发放1', 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', ]; $service = new TestingResourceService(); diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index 63d1ee001..ba98ac36b 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -77,9 +77,10 @@ class TestingResourceController extends BaseController $users = []; $bindings = []; $bindingRoles = []; + $applyRecords = []; if (count($roles) > 0) { - $users = M('user', 'tab_')->field(['id', 'phone'])->where(['id' => ['in', $userIds]])->select(); - $uesrs = index_by_column('id', $users); + $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(); $bindingRoleIds = []; foreach ($bindingRows as $bindingRow) { @@ -93,6 +94,56 @@ class TestingResourceController extends BaseController ->select(); $bindingRoles = index_by_column('game_role_id', $bindingRoles); } + + $verifyItems = M('testing_resource_batch', 'tab_') + ->field('sum(apply_amount) amount, game_id, role_id') + ->where([ + 'verify_status' => 0, + '_string' => implode(' or ', $bindingOrWhere) + ]) + ->group('game_id,role_id')->select(); + $verifyRecords = []; + foreach ($verifyItems as $item) { + $verifyRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ; + } + + $provideItems = M('testing_resource_batch', 'tab_') + ->field('sum(provide_amount) amount, game_id, role_id') + ->where([ + 'verify_status' => 1, + '_string' => implode(' or ', $bindingOrWhere) + ]) + ->group('game_id,role_id')->select(); + $provideRecords = []; + foreach ($provideItems as $item) { + $provideRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ; + } + + $todayProvideItems = M('testing_resource_batch', 'tab_') + ->field('sum(provide_amount) amount, game_id, role_id') + ->where([ + 'verify_status' => 1, + '_string' => implode(' or ', $bindingOrWhere), + 'provide_time' => ['egt', strtotime(date('Y-m-d 00:00:00'))], + 'provide_time' => ['elt', strtotime(date('Y-m-d 23:59:59'))], + ]) + ->group('game_id,role_id')->select(); + $todayProvideRecords = []; + foreach ($todayProvideItems as $item) { + $todayProvideRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ; + } + + $applyItems = M('testing_resource_batch', 'tab_') + ->field('sum(apply_amount) amount, game_id, role_id') + ->where([ + '_string' => implode(' or ', $bindingOrWhere), + ]) + ->group('game_id,role_id')->select(); + $applyRecords = []; + foreach ($applyItems as $item) { + $applyRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ; + } + } $spendItems = []; if (count($bindingRoles) > 0) { @@ -132,11 +183,11 @@ class TestingResourceController extends BaseController 'base_quota' => $binding ? $binding['base_quota'] : 0, 'other_quota' => $binding ? $binding['other_quota'] : 0, 'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0, - 'verify_amount' => 0, - 'provide_amount' => 0, - 'today_amount' => 0, - 'apply_amount' => 0, - 'status' => '可用', + 'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0, + '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 ? '正常' : '锁定', 'create_time' => date('Y-m-d H:i:s', $role['create_time']) ]; } @@ -469,7 +520,7 @@ class TestingResourceController extends BaseController } $bindingRole = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'user_id', 'promote_id']) + ->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)) { diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html index 6e771e30a..76f9e27e1 100644 --- a/Application/Home/View/default/TestingResource/apply.html +++ b/Application/Home/View/default/TestingResource/apply.html @@ -81,6 +81,10 @@ display: inline-block; margin-left: 10px; } + .info-row button.bind-btn { + background: #409eff; + color: #fff; + }