Merge branch 'master' of 47.111.118.107:wmtx/platform into feature/finance_statement_three

master
chenzhi 5 years ago
commit 7ceafb1d42

@ -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();

@ -0,0 +1,57 @@
<?php
/**
* 定时自动完成
*/
namespace Admin\Controller;
use Admin\Model\SpendModel;
use Think\Think;
use Base\Tool\Printer;
use Base\Tool\TaskClient;
use Base\Service\TestingResourceService;
use GuzzleHttp\Client;
use think\Db;
use Base\Tool\GameCatClient;
class GameApiController extends Think {
protected function _initialize()
{
C(api('Config/lists'));
}
public function verify()
{
$service = new TestingResourceService();
$batches = M('testing_resource_batch', 'tab_')->where(['verify_status' => 0])->select();
foreach ($batches as $batch) {
$service->verify($batch);
}
}
public function provide()
{
$service = new TestingResourceService();
$batches = M('testing_resource_batch', 'tab_')->where(['verify_status' => 1, 'provide_status' => 0])->select();
foreach ($batches as $batch) {
$service->provide($batch);
}
}
public function send()
{
$role = [
'role_id' => '6819493',
'user_account' => 'qh11102',
'sdk_version' => 1,
];
$order = [
'ref_amount' => '10.00',
'ref_id' => '8',
'remark' => '测试',
'order_no' => date('YmdHis') . rand(1000, 9999) . '_1',
];
$service = new TestingResourceService();
$result = $service->provideFromGameCat($order, $role);
var_dump($result);
}
}

@ -825,6 +825,32 @@ class PromoteService {
return $chain == '' ? 1 : count(explode('/', $chain));
}
public function getIdsByChain($chain)
{
$chain = trim($chain, '/');
return $chain == '' ? [] : explode('/', $chain);
}
public function isSub($promote, $parent)
{
$chainList = $this->getIdsByChain($promote['chain']);
if (in_array($parent['id'], $chainList)) {
return true;
}
return false;
}
public function isSubOrSelf($promote, $parent)
{
if ($promote['id'] == $parent['id']) {
return true;
} elseif ($this->isSub($promote, $parent)) {
return true;
} else {
return false;
}
}
/**
* 获取最上级的推广员
*/
@ -854,6 +880,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] ?? '未知';
@ -1122,7 +1160,7 @@ class PromoteService {
$selfGameIds = $topGameIds;
// $selfGameIds = $promote['game_ids'] == '' ? [] : explode(',', $promote['game_ids']);
// $selfGameIds = array_intersect($topGameIds, $selfGameIds);
if ($promote['level'] == 1) {
return $selfGameIds;
}

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

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

@ -0,0 +1,108 @@
<?php
namespace Base\Tool;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
/**
* 游戏猫接口客户端
*/
class GameCatClient
{
const SIGN_NAME = 'sign';
const SUCCESS = '0000';
protected $client;
private $apis = [
'get-pay-type' => ['uri' => '/game/support/items/v1', 'method' => 'post'],
'provide' => ['uri' => '/game/support/provide/v1', 'method' => 'post'],
];
private $appIds = [
'andriod' => 1746,
'ios' => 1747,
];
private $channelIds = [
'andriod' => 11595,
'ios' => 11596,
];
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('接口不存在');
}
$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['timestamp'] = time();
$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, 'state' => 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();
/* var_dump($uri);
var_dump($params);
var_dump($result); */
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');
$signRows = [];
foreach ($params as $key => $value) {
$signRows[] = $key . '=' . $value;
}
// var_dump(implode('&', $signRows));
return md5(implode('&', $signRows));
}
}

@ -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);

@ -1446,18 +1446,18 @@ class DownloadController extends BaseController {
if (!empty(I('begtime')) && empty(I('endtime'))) {
$map['tab_spend.pay_time'] = ['egt', strtotime(I('begtime'))];
$map['tab_spend.spend_time'] = ['egt', strtotime(I('begtime'))];
} elseif (empty(I('begtime')) && !empty(I('endtime'))) {
$map['tab_spend.pay_time'] = ['elt', strtotime(I('endtime')) + 86399];
$map['tab_spend.spend_time'] = ['elt', strtotime(I('endtime')) + 86399];
} elseif (!empty(I('begtime')) && !empty(I('endtime'))) {
$map['tab_spend.pay_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]];
$map['tab_spend.spend_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]];
}else {
$nowTime = date('Y-m-d');
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initEndTime = date('Y-m-d');
$initBegTime = strtotime($initBegTime);
$initEndTime = strtotime($initEndTime);
$map['tab_spend.pay_time'] = ['between',[$initBegTime,$initEndTime]];
$map['tab_spend.spend_time'] = ['between',[$initBegTime,$initEndTime]];
}
empty(I('relation_game_id')) || $map['tab_game.relation_game_id'] = I('relation_game_id');

@ -99,7 +99,7 @@ class QueryController extends BaseController
$map['tab_spend.pay_status'] = $payStatus;
}
}
$map['tab_spend.pay_time'] = ['between', [$begTime, $endTime - 1]];
$map['tab_spend.spend_time'] = ['between', [$begTime, $endTime - 1]];
$data = [];
$count = 0;

@ -0,0 +1,824 @@
<?php
namespace Home\Controller;
use Base\Model\PromoteModel;
use Base\Service\PromoteService;
use OSS\Core\OssException;
use Base\Tool\GameCatClient;
use Think\Model;
use Base\Service\TestingResourceService;
class TestingResourceController extends BaseController
{
private $gameBaseQuota = [
229 => 300,
230 => 300,
];
public function index()
{
$createTimeStart = I('create_time_start', '');
$createTimeEnd = I('create_time_end', '');
$gameId = I('game_id', 0);
$serverId = I('server_id', '');
$account = I('account');
$roleName = I('role_name');
$loginPromote = $this->getLoginPromote();
$conditions = [];
$subConditions = [
'_string' => '1=1'
];
$promoteService = new PromoteService();
$visibleGameIds = $promoteService->getVisibleGameIds($loginPromote);
$strCondition = 'game_id in (0)';
if (count($visibleGameIds) > 0) {
$strCondition = 'game_id in (' . implode(',', $visibleGameIds) . ')';
}
/**
* @todo 仅有游戏猫
*/
$strCondition .= ' and game_id in (229, 230)';
if ($createTimeStart) {
$strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
}
if ($createTimeEnd) {
$strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
}
$subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
$strCondition .= ' and user_id in (' . $subSql . ')';
$strCondition .= ' and promote_id in (' . $promoteService->subInSql($loginPromote) . ')';
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);
$bindingOrWhere = [];
foreach ($roles as $role) {
$bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')';
}
$userIds = array_unique(array_column($roles, 'user_id'));
$users = [];
$bindings = [];
$bindingRoles = [];
$applyRecords = [];
if (count($roles) > 0) {
$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) {
$bindings[$this->getGameRoleId($bindingRow['game_id'], $bindingRow['role_id'])] = $bindingRow;
$bindingRoleIds[] = $this->getGameRoleId($bindingRow['game_id'], $bindingRow['bind_role_id']);
}
if (count($bindings) > 0) {
$bindingRoles = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'role_name', 'user_account', 'game_id', 'game_role_id'])
->where(['game_role_id' => ['in', $bindingRoleIds]])
->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) {
$spendOrWhere = [];
foreach ($bindingRoles as $bindingRole) {
$spendOrWhere[] = '(game_player_id="' . $bindingRole['role_id'] . '" and game_id=' . $bindingRole['game_id'] . ')';
}
$spendCondition = [
'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();
foreach ($spendList as $item) {
$spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $item['amount'];
}
}
$records = [];
foreach ($roles as $role) {
$user = $users[$role['user_id']] ?? null;
$binding = $bindings[$role['game_role_id']] ?? null;
$bindingRole = null;
if ($binding) {
$bindGameRoleId = $this->getGameRoleId($binding['game_id'], $binding['bind_role_id']);
$bindingRole = $bindingRoles[$bindGameRoleId] ? $bindingRoles[$bindGameRoleId] : null;
}
$records[] = [
'id' => $role['id'],
'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' => $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,
'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'])
];
}
$this->assign('games', $this->getGames());
$this->assign('servers', $this->getServersByGameId($gameId));
$this->assign('count', $count);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
$this->display();
}
private function getGameRoleId($gameId, $roleId)
{
return $gameId . '#' . $roleId;
}
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);
$existAccounts = $existAccounts ?? [];
$existCount = count($existAccounts);
$newAccounts = array_diff($accounts, $existAccounts);
$errorCount = 0;
$successCount = 0;
if (count($newAccounts)) {
$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) {
if (in_array($user['account'], $errorAccounts)) {
continue;
}
$data = [
'user_id' => $user['id'],
'user_account' => $user['account'],
'status' => 1,
'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()
{
$gameId = I('game_id', 0);
$serverId = I('server_id', '');
$createTimeStart = I('create_time_start', '');
$createTimeEnd = I('create_time_end', '');
$verifyStatus = I('verify_status', -1);
$provideStatus = I('provide_status', -1);
$account = I('account');
$loginPromote = $this->getLoginPromote();
$promoteService = new PromoteService();
$subSql = M('user', 'tab_')
->where('id=tab_testing_resource_batch.user_id and promote_id in (' . $promoteService->subInSql($loginPromote) . ')')
->select(false);
$conditions = [
'_string' => 'exists (' . $subSql . ')'
];
if ($createTimeStart) {
$conditions['_string'] .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
}
if ($createTimeEnd) {
$conditions['_string'] .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
}
if ($verifyStatus != -1) {
$conditions['verify_status'] = $verifyStatus;
}
if ($provideStatus != -1) {
$conditions['provide_status'] = $provideStatus;
}
if ($gameId) {
$conditions['game_id'] = $gameId;
}
if ($serverId) {
$conditions['server_id'] = $serverId;
}
if ($account) {
$user = M('user', 'tab_')->field(['id'])->where('account like "' . $account . '%"')->find();
if ($user) {
$conditions['user_id'] = $user['id'];
} else {
$conditions['_string'] .= ' and 1<>1';
}
}
$query = M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc');
list($batches, $pagination, $count) = $this->paginate($query);
$roles = [];
$applyPromotes = [];
$users = [];
$promotes = [];
if (count($batches) > 0) {
$gameRoleIds = [];
foreach ($batches as $batch) {
$gameRoleIds[] = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
}
$roles = M('user_play_info', 'tab_')
->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account'])
->where(['game_role_id' => ['in', $gameRoleIds]])
->select();
$roles = index_by_column('game_role_id', $roles);
$users = M('user', 'tab_')->field(['id', 'account', 'phone', 'promote_id'])->where(['id' => ['in', array_column($batches, 'user_id')]])->select();
$users = index_by_column('id', $users);
$applyPromotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($batches, 'apply_promote_id')]])->select();
$applyPromotes = index_by_column('id', $applyPromotes);
if (count($users) > 0) {
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($users, 'promote_id')]])->select();
$promotes = index_by_column('id', $promotes);
}
}
$testingResourceService = new TestingResourceService();
$records = [];
foreach ($batches as $batch) {
$roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
$role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
$user = $users[$batch['user_id']] ?? null;
$applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
$promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
$records[] = [
'id' => $batch['id'],
'batch_no' => substr($batch['batch_no'], 14),
'create_time' => date('Y-m-d H:i:s', $batch['create_time']),
'game_name' => $role ? $role['game_name'] : '--',
'server_name' => $role ? $role['server_name'] : '--',
'role_name' => $role ? $role['role_name'] : '--',
'user_account' => $role ?$role['user_account'] : '--',
'user_phone' => $user ? $user['phone'] : '',
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
'promote_account' => $promote['account'],
// 'history_provide_amount' => 0.00,
'apply_amount' => $batch['apply_amount'],
'provide_amount' => $batch['provide_amount'],
'verify_status' => $batch['verify_status'],
'verify_status_text' => $testingResourceService->getVerifyStatusText($batch['verify_status']),
'verify_time' => $batch['verify_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['verify_time']),
'provide_status' => $batch['provide_status'],
'provide_status_text' => $testingResourceService->getProvideStatusText($batch['provide_status']),
'provide_time' => $batch['provide_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['provide_time']),
'content' => $content,
];
}
$this->assign('verifyStatusList', TestingResourceService::$verifyStatusList);
$this->assign('provideStatusList', TestingResourceService::$provideStatusList);
$this->assign('servers', $this->getServersByGameId($gameId));
$this->assign('games', $this->getGames());
$this->assign('count', $count);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
$this->display();
}
public function orders()
{
$id = I('id', 0);
$batch = M('testing_resource_batch', 'tab_')->where(['id' => $id])->find();
$role = M('user_play_info', 'tab_')
->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account'])
->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']])
->find();
$applyPromote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $batch['apply_promote_id']])->find();
$promote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $role['apply_promote_id']])->find();
$query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc');
list($orders, $pagination, $count) = $this->paginate($query);
$testingResourceService = new TestingResourceService();
foreach ($orders as $order) {
$records[] = [
'id' => $order['id'],
'create_time' => $batch['create_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['create_time']),
'game_name' => $role['game_name'],
'user_account' => $role['user_account'],
'server_name' => $role['server_name'],
'role_name' => $role['role_name'],
'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '',
'promote_account' => $promote['account'],
'ref_name' => $order['ref_name'],
'ref_amount' => $order['ref_amount'],
'num' => $order['num'],
'amount' => $order['num'] * $order['ref_amount'],
'remark' => $order['remark'],
'provide_status' => $order['provide_status'],
'provide_status_text' => $testingResourceService->getProvideStatusText($order['provide_status']),
];
}
$this->assign('count', $count);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
$this->display();
}
private function getRemainQuota($role, $bindRole = null)
{
$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'], 'pay_status' => 1])
->group('game_id,game_player_id')
->sum('pay_amount');
}
$providedQuota = M('testing_resource_batch', 'tab_')
->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' => $role['game_id'], 'role_id' => $role['role_id']])
->sum('apply_amount');
return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2);
}
public function apply()
{
$id = I('id', 0);
$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', 'testing_other_quota'])
->where(['id' => $id])
->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(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find();
if ($binding) {
$bindingRole = M('user_play_info', 'tab_')
->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();
}
}
/**
* @todo 目前固定游戏猫
*/
$games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select();
$this->assign('games', $games);
$this->assign('servers', $servers);
$this->assign('bindingRole', $bindingRole);
$this->assign('role', $role);
$this->assign('quota', $this->getRemainQuota($role, $bindingRole));
$this->display();
}
public function doApply()
{
$gameId = I('game_id', 0);
$roleId = I('role_id', '');
$serverId = I('server_id', 0);
$userAccount = I('user_account', '');
$records = I('records', []);
$loginPromote = $this->getLoginPromote();
if ($loginPromote['level'] > 2) {
return $this->ajaxReturn(['status' => 0, 'message' => '权限不足']);
}
$resources = [];
/**
* @todo 目前仅限游戏猫
*/
if ($gameId == 229) {
$resources = $this->getGameCatResources('android');
} elseif ($gameId == 230) {
$resources = $this->getGameCatResources('ios');
} else {
return $this->ajaxReturn(['status' => 0, 'message' => '该游戏不可申请资源']);
}
$binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find();
/* 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)) {
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' => '区服不存在']);
}
$promoteService = new PromoteService();
$role = M('user_play_info', 'tab_')
->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' => '角色不存在']);
}
$otherRoleBatch = M('testing_resource_batch', 'tab_')
->where([
'user_id' => $user['id'],
'game_id' => $gameId,
'server_id' => $server['server_id'],
'role_id' => ['neq', $roleId],
'verify_status' => ['in', [0, 1]],
])
->find();
if ($otherRoleBatch) {
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' => '测试角色所属推广员异常']);
}
$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;
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' => '含有资源内容不存在']);
}
/**
* @todo 游戏猫只能每个资源数量只能为1
*/
if ($record['num'] != 1) {
return $this->ajaxReturn(['status' => 0, 'message' => '该游戏每次申请单项资源数量只能为1']);
}
}
$remainQuota = $this->getRemainQuota($role, $bindingRole);
if ($amount > $remainQuota) {
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_no' => $batchNo,
'user_id' => $testingUser['user_id'],
'game_id' => $gameId,
'role_id' => $roleId,
'server_id' => $serverId,
'apply_promote_id' => $loginPromote['id'],
'apply_amount' => $amount,
'provide_status' => 0,
'verify_status' => 0,
'create_time' => time(),
'update_time' => time(),
];
$batchId = M('testing_resource_batch', 'tab_')->add($batch);
$i = 1;
foreach ($records as $record) {
$orderNo = $batchNo . '_' . $i;
$order = [
'batch_id' => $batchId,
'order_no' => $orderNo,
'ref_id' => $record['resource_id'],
'ref_name' => $record['resource_name'],
'ref_amount' => $record['value'],
'num' => $record['num'],
'amount' => $record['num'] * $record['value'],
'remark' => $record['remark'],
];
M('testing_resource_order', 'tab_')->add($order);
}
$model->commit();
return $this->ajaxReturn(['status' => 1, 'message' => '申请成功,等待审核']);
} catch (\Exception $e) {
$model->rollback();
return $this->ajaxReturn(['status' => 0, 'message' => '系统异常' . $e->getMessage()]);
}
}
public function bindRole()
{
$gameId = I('game_id', 0);
$testingRoleId = I('testing_role_id', '');
$bindRoleId = I('bind_role_id', '');
$loginPromote = $this->getLoginPromote();
$testingGameRoleId = $this->getGameRoleId($gameId, $testingRoleId);
$bindGameRoleId = $this->getGameRoleId($gameId, $bindRoleId);
$testingRole = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'game_id', 'promote_id'])
->where(['game_role_id' => $testingGameRoleId])
->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' => '测试账号不存在']);
}
$promoteService = new PromoteService();
$testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $testingRole['promote_id']])->find();
if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $loginPromote)) {
return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']);
}
$bindRole = M('user_play_info', 'tab_')
->field(['id', 'role_id', 'user_id', 'promote_id'])
->where(['game_role_id' => $bindGameRoleId])
->find();
if (is_null($bindRole)) {
return $this->ajaxReturn(['status' => 0, 'message' => '玩家角色不存在']);
}
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindRole['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' => '玩家账号与测试账号非同一推广员']);
} */
$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(['game_id' => $gameId, 'bind_role_id' => $bindRoleId])->find();
if ($existBind) {
return $this->ajaxReturn(['status' => 0, 'message' => '该玩家角色已被绑定']);
}
$testExistBind = M('testing_binding', 'tab_')->field(['id'])->where(['game_id' => $gameId, 'role_id' => $testingRoleId])->find();
if ($testExistBind) {
return $this->ajaxReturn(['status' => 0, 'message' => '该测试账号角色已绑定有角色']);
}
M('testing_binding', 'tab_')->add([
'game_id' => $testingRole['game_id'],
'user_id' => $testingRole['user_id'],
'role_id' => $testingRole['role_id'],
'bind_user_id' => $bindRole['user_id'],
'bind_role_id' => $bindRole['role_id'],
'create_time' => time(),
'update_time' => time()
]);
return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
}
private function getGames()
{
$map = [
'id' => ['in', [229, 230]]
];
$loginPromote = $this->getLoginPromote();
$promoteService = new PromoteService();
$visibleGameIds = $promoteService->getVisibleGameIds($loginPromote);
$map['_string'] = 'id in (0)';
if (count($visibleGameIds) > 0) {
$map['_string'] = 'id in (' . implode(',', $visibleGameIds) . ')';
}
return M('game', 'tab_')->field('id,game_name')->where($map)->select();
}
private function getServersByGameId($gameId = 0)
{
if ($gameId == 0) {
return [];
}
$map = [];
$map['game_id'] = $gameId;
return M('server', 'tab_')
->field('id,server_name,server_id')
->where($map)
->order('server_id asc')
->select();
}
public function getServers()
{
$gameId = I('game_id', 0);
$servers = $this->getServersByGameId($gameId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
}
public function getResourceTypes()
{
$gameId = I('game_id', 0);
$resourceTypes = [];
/**
* @todo 目前固定游戏猫
*/
if ($gameId == 229) {
$resourceTypes[] = ['id' => 1, 'name' => '通用'];
} elseif ($gameId == 230) {
$resourceTypes[] = ['id' => 2, 'name' => '通用'];
}
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]);
}
public function getResources()
{
$typeId = I('type_id', 0);
$resources = [];
/**
* @todo 目前固定游戏猫资源类型ID
*/
if ($typeId == 2) {
$resources = $this->getGameCatResources('ios');
} elseif ($typeId == 1) {
$resources = $this->getGameCatResources('andriod');
}
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' => '区服不存在']);
}
$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_account' => $userAccount])->find();
$isTestingAccount = is_null($testingUser) ? false : true;
$roles = M('user_play_info', 'tab_')
->field(['id', 'role_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, 'is_testing_account' => $isTestingAccount]]);
}
private function getGameCatResources($deviceType)
{
$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'],
];
}
}
return $resources;
}
}

@ -112,13 +112,13 @@
<?php endif;?>
<a href="{:U('Safe/promoteLogs')}" class="<if condition='CONTROLLER_NAME eq Safe and (ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs or ACTION_NAME eq promoteLogs ) '>active</if> ">操作日志</a>
</div>
<?php if($loginer['level'] <= 2):?>
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>测试资源</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">
<a href="{:U('TestResource/index')}" class="<if condition='CONTROLLER_NAME eq TestResource and (ACTION_NAME eq index or ACTION_NAME eq add or ACTION_NAME eq apply ) '>active</if> ">测试资源申请</a>
<a href="{:U('TestResource/lists')}" class="<if condition='CONTROLLER_NAME eq TestResource and ACTION_NAME eq lists '>active</if> ">测试资源申请记录</a>
<a href="{:U('TestResource/supportNumberList')}" class="<if condition='CONTROLLER_NAME eq TestResource and (ACTION_NAME eq supportNumberList or ACTION_NAME eq freezeSupport or ACTION_NAME eq unfreezeSupport or ACTION_NAME eq rechangePassward ) '>active</if> ">测试号管理</a>
<a href="{:U('TestResource/protectLogList')}" class="<if condition='CONTROLLER_NAME eq TestResource and ACTION_NAME eq protectLogList '>active</if> ">日志管理</a>
<a href="{:U('TestingResource/index')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq index '>active</if> ">测试资源申请</a>
<a href="{:U('TestingResource/batches')}" class="<if condition='CONTROLLER_NAME eq TestingResource and ACTION_NAME eq batches '>active</if> ">测试资源申请记录</a>
</div>
<?php endif;?>
<!--<eq name="parent_id" value="0">
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>扶持管理</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">

@ -0,0 +1,574 @@
<extend name="Public/basic"/>
<block name="body">
<style>
.trunk-search .form-group {
margin-left: 10px;
}
.normal_table input {
position: relative;
padding: 5px;
border: 1px solid #E5E5E5;
border-radius: 4px;
height: 25px;
}
.normal_table td {
padding: 5px;
}
.normal_table td select {
width: 100%;
}
.normal_table td button {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.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;
}
.info-row button.bind-btn {
background: #409eff;
color: #fff;
}
</style>
<div class="page-search normal_list promoteCoin-record-search" style="padding: 20px;">
<div class="trunk-content article">
<div class="trunk-search clearfix" style="margin-bottom: 10px;">
<form method="post" class="clearfix">
<div class="clearfix">
<div class="form-group fl">
<select id="game-select" name="" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择游戏</option>
<?php foreach($games as $game):?>
<option value="<?=$game['id']?>" <?php if($role && $role['game_id'] == $game['id']):?>selected<?php endif;?>>
<?=$game['game_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group fl">
<select id="server-select" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="0">请选择区服</option>
<?php foreach($servers as $server):?>
<option value="<?=$server['id']?>" <?php if($role && $server['server_id'] == $role['server_id']):?>selected<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group fl">
<input id="test_account" type="text" name="account" class="txt normal_txt" placeholder="请输入测试资源账号" value="{$role.user_account}" <?php if($role):?>disabled<?php endif;?>>
</div>
<div class="form-group fl">
<select id="role-select" name="role_id" class="select_gallery" style="width:150px" <?php if($role):?>disabled<?php endif;?>>
<option value="">请选择角色</option>
<?php if($role):?>
<option value="<?=$role['role_id']?>" selected><?=$role['role_name']?></option>
<?php endif;?>
</select>
</div>
</div>
<?php if($role):?>
<div class="info-row">
<?php if($bindingRole):?>
<button type="button">绑定角色: <?= $bindingRole['role_name']?></button>
<?php else:?>
<button id="bind-btn" class="bind-btn" type="button">绑定玩家角色</button>
<?php endif;?>
<div class="" style="display:inline-block; margin-left: 10px;">
当前可用额度:<span id="quota" data-quota="<?=$quota?>"><?=$quota?></span> 待审核额度:<span id="verify-quota">0</span>
</div>
</div>
<?php endif;?>
<div class="clearfix" style="margin-top: 10px;">
<div class="form-group fl">
<select id="resource-type-select" name="resource_type_id" style="width:150px" class="select_gallery">
<option value="">请选择资源类型</option>
</select>
</div>
<div class="form-group fl">
<select id="resource-select" name="resource_id" style="width:150px" class="select_gallery">
<option value="">请选择资源内容</option>
</select>
</div>
<div class="form-group fl">
<input id="remark-input" type="text" name="remark" class="txt normal_txt" id="uid" placeholder="请输入备注" value="">
</div>
<div class="form-group fl">
<p id="resource-amount" class="static-input">资源价值: --</p>
</div>
<div class="form-group fl">
<p class="static-input">资源数量: 1</p>
<!-- <input id="num-input" type="text" name="num" class="txt normal_txt" id="uid" placeholder="请输入资源数量" value=""> -->
</div>
<div class="form-group fl">
<button id="add-row" class="add-row" type="button">增加</button>
</div>
</div>
</form>
</div>
<div class="trunk-list list_normal">
<div class="table-wrapper" style="height: 280px;">
<table id="resource-table" class="table normal_table">
<thead>
<tr class="table-header">
<th width="150">资源类型</th>
<th width="150">资源内容</th>
<th>资源价值</th>
<th>资源数量</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="btn-row clearfix">
<button id="submit-btn" class="submit-btn" type="button">提交</button>
<button id="close-btn" class="close-btn" type="button">关闭</button>
</div>
</div>
</div>
</div>
<div id="bind-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label>玩家账号</label>
<div class="form-item" style="width: 250px">
<input id="bind_account" name="account" type="text" class="form-input" style="width: 100%;">
</div>
</div>
<div class="form-group">
<label>玩家角色</label>
<div class="form-item" style="width: 250px">
<select id="bind-role-select" name="role_id" style="width:270px" class="select_gallery">
<option value="">请选择</option>
</select>
</div>
</div>
<div class="form-group">
<label></label>
<a id="submit-bind" href="javascript:;" class="add-submit btn">确定</a>
</div>
</form>
</div>
</block>
<block name="script">
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script type="text/javascript">
$(".select_gallery").select2()
var globalGameId = $('#game-select').val()
if (globalGameId > 0) {
initTable(globalGameId)
}
$('#game-select').on({
change: function () {
var gameId = $(this).val()
globalGameId = gameId
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var servers = result.data.servers
var html = "<option value='0'>请选择区服</option>";
for (var i in servers){
html += "<option value='"+servers[i].id+"'>"+servers[i].server_name+"</option>"
}
$("#server-select").html(html);
$("#server-select").select2();
} else {
}
}
})
initTable(gameId)
}
})
var resourceTypes = new Array()
var rowCount = 0
function initTable(gameId) {
var table = $('#resource-table');
table.find('.normal-row').remove()
$.ajax({
url: "{:U('getResourceTypes')}",
type: "post",
data: { game_id: gameId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
rowCount = 0
resourceTypes = result.data.resourceTypes
var selector = $('#resource-type-select')
var html = getResourceTypesHtml()
selector.html(html)
selector.select2();
var resourceSelector = $('#resource-select')
resourceSelector.html(getResourcesHtml([]))
resourceSelector.select2();
$('#resource-amount').html('资源价值:--')
$('#resource-table tbody').html('')
} else {
}
}
})
}
function getResourceTypesHtml() {
var html = "<option value=''>请选择资源类型</option>";
for (var i in resourceTypes) {
html += "<option value='"+resourceTypes[i].id+"'>"+resourceTypes[i].name+"</option>"
}
return html
}
$('#resource-type-select').change(function () {
var that = this
var typeId = $(this).val()
$.ajax({
url: "{:U('getResources')}",
type: "post",
data: { type_id: typeId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var resources = result.data.resources
var html = getResourcesHtml(resources)
var rowSelect = $('#resource-select')
rowSelect.html(html);
rowSelect.select2();
} else {
}
}
})
})
function getResourcesHtml(resources) {
var html = "<option value=''>请选择资源内容</option>";
for (var i in resources){
html += "<option value='"+resources[i].ref_id+"' data-amount="+resources[i].amount+">"+resources[i].name+"</option>"
}
return html
}
$('#resource-select').change(function () {
var amount = $(this).find('option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
$('#resource-amount').html('资源价值:' + amount)
})
$('#add-row').click(function () {
if (rowCount >= 5) {
return layer.msg('最多同时只能添加5条')
}
var resourceTypeId = $('#resource-type-select').val()
var resourceId = $('#resource-select').val()
var resourceTypeName = $('#resource-type-select option:selected').html()
var resourceName = $('#resource-select option:selected').html()
var amount = $('#resource-select option:selected').attr('data-amount')
amount = amount == undefined ? '--' : amount
// var num = $('#num-input').val()
var num = 1
var remark = $('#remark-input').val()
if (resourceTypeId == '') {
return layer.msg('请选择资源类型')
}
if (resourceId == '') {
return layer.msg('请选择资源内容')
}
if (num == '') {
return layer.msg('请输入资源数量')
}
var html = '<tr class="normal-row" data-resource-id="' + resourceId + '" data-resource-type-id="' + resourceTypeId + '" >' +
'<td>' + resourceTypeName + '</td>' +
'<td>' + resourceName + '</td>' +
'<td class="amount">' + amount + '</td>' +
'<td class="num"><input name="num" type="text" value="' + num + '" readonly></td>' +
'<td class="remark"><input name="remark" type="text" value="' + remark + '"></td>' +
'<td><button class="delete-row" type="button" class="danger-btn">删除</button></td>' +
'</tr>';
$('#resource-table tbody').append(html)
rowCount ++
$(".select_gallery").select2()
statQuota()
})
$('#resource-table').on('click', '.delete-row', function () {
var tr = $(this).parents('tr').eq(0)
rowCount --
tr.remove()
statQuota()
})
$('#resource-table').on('blur', 'input[name=num]', function() {
if($(this).val() == '') {
return layer.msg('请输入资源数量')
} else {
statQuota()
}
})
function statQuota() {
var quota = $('#quota').attr('data-quota')
var verifyQuota = 0
$('#resource-table').find('.normal-row').each(function (index, ele) {
verifyQuota += $(ele).find('.amount').html() * $(ele).find('.num').children('input').val()
})
$('#verify-quota').html(verifyQuota)
$('#quota').html(quota-verifyQuota)
}
$('#test_account').on({
blur: function() {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var serverId = $('#server-select').val()
if (serverId == 0) {
return layer.msg('请选择区服')
}
var userAccount = $('#test_account').val()
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
}
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) {
if (roles.length == 0) {
return layer.msg('当前账号在该区服未创建角色')
}
if (!isTestingAccount) {
return layer.msg('此账号非测试账号')
}
var html = "<option value=''>请选择角色</option>";
for (var i in roles){
html += "<option value='"+roles[i].role_id+"'>"+roles[i].role_name+"</option>"
}
$("#role-select").html(html);
$("#role-select").select2();
})
}
})
function getUserRoles(userAccount, gameId, serverId, callback) {
$.ajax({
url: "{:U('getUserRoles')}",
type: "post",
data: { user_account: userAccount, game_id: gameId, server_id: serverId },
dataType: 'json',
success: function(result){
if (result.status == 1) {
var roles = result.data.roles
var isTestingAccount = result.data.is_testing_account
callback(roles, isTestingAccount)
} else {
layer.msg(result.message)
}
}
})
}
$('#bind_account').on({
blur: function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var serverId = $('#server-select').val()
if (serverId == 0) {
return layer.msg('请选择区服')
}
var userAccount = $('#bind_account').val()
if (userAccount == '') {
return layer.msg('请输入玩家账号')
}
getUserRoles(userAccount, gameId, serverId, function(roles, isTestingAccount) {
if (roles.length == 0) {
return layer.msg('玩家账号在该区服未创建角色')
}
if (isTestingAccount) {
return layer.msg('此账号为测试账号,无法绑定')
}
var html = "<option value=''>请选择角色</option>";
for (var i in roles){
html += "<option value='"+roles[i].role_id+"'>"+roles[i].role_name+"</option>"
}
$("#bind-role-select").html(html);
$("#bind-role-select").select2();
})
}
})
function getRecords() {
var records = []
$('#resource-table tbody tr').each(function (index, tr) {
var num = $(tr).find('input[name=num]').val()
var remark = $(tr).find('input[name=remark]').val()
var resourceId = $(tr).attr('data-resource-id')
var resourceTypeId = $(tr).attr('data-resource-type-id')
records.push({
resource_id: resourceId,
resource_type_id: resourceTypeId,
num: num,
remark: remark,
})
})
return records
}
$('#bind-btn').click(function () {
var box = $('#bind-box')
layer.open({
title: '绑定玩家角色',
type: 1,
content: box,
area: ['500px', '250px'],
zIndex: 250,
scrollbar: false
})
});
$('#submit-bind').click(function () {
var gameId = $('#game-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
var roleId = $('#role-select').val()
if (roleId == 0) {
return layer.msg('请选择测试账号角色')
}
var bindRoleId = $('#bind-role-select').val()
if (bindRoleId == 0) {
return layer.msg('请选择玩家角色')
}
$.ajax({
url: "{:U('bindRole')}",
type: "post",
data: { game_id: gameId, bind_role_id: bindRoleId, testing_role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
} else {
layer.msg(result.message)
}
}
})
})
$('#submit-btn').on({
click: function () {
var records = getRecords()
if (records.length == 0) {
return layer.msg('至少添加一项资源申请')
}
for (var i in records) {
if (records[i].num == '') {
return layer.msg('请输入资源数量')
}
}
var gameId = $('#game-select').val()
var serverId = $('#server-select').val()
var userAccount = $('#test_account').val()
var roleId = $('#role-select').val()
if (gameId == 0) {
return layer.msg('请选择游戏')
}
if (serverId == 0) {
return layer.msg('请选择区服')
}
if (userAccount == '') {
return layer.msg('请输入测试资源账号')
}
if (roleId == 0) {
return layer.msg('请选择角色')
}
$.ajax({
url: "{:U('doApply')}",
type: "post",
data: { records: records, game_id: gameId, server_id: serverId, user_account: userAccount, role_id: roleId},
dataType: 'json',
success: function(result){
if (result.status == 1) {
layer.msg(result.message, function(){
parent.window.location.href = "{:U('batches')}"
})
} else {
layer.msg(result.message)
}
}
})
}
})
$('#close-btn').on({
click: function () {
var index = parent.layer.getFrameIndex(window.name)
parent.layer.close(index)
}
})
</script>
</block>

@ -0,0 +1,306 @@
<extend name="Public/promote_base"/>
<block name="css">
<link href="__CSS__/20180207/data.css" rel="stylesheet">
<link href="__CSS__/20180207/manager.css" rel="stylesheet" >
<link href="__CSS__/20180207/finance.css" rel="stylesheet">
<style>
.page-list .trunk-search{
padding-top: 20px;
}
.view-detail {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.normal_table td .status-0 {
color: #e6a23c;
}
.normal_table td .status-1 {
color: #67c23a;
}
.normal_table td .status-2 {
color: #f56c6c;
}
.normal_table tr td {
padding: 10px 5px;
}
</style>
</block>
<block name="body">
<div class="page-list normal_list apply-app_apply-list">
<div class="trunk-title">
<div class="location">
<div class="location-container">当前位置:<span>测试资源></span><span>测试资源申请记录</span></div>
</div>
<img src="__IMG__/20180207/icon_normal_shenqing.png">
<span class="title_main">测试资源申请记录</span>
<span class="details">说明:测试资源申请记录</span>
</div>
<div class="trunk-content article">
<div class="trunk-search clearfix">
<div id="form1">
<div class="form-group normal_space fr">
<input type="submit" class="submit" id='submit' value="查询" url="{:U('batches')}" style="cursor:pointer;">
</div>
<div class="form-group normal_space fr">
<select name="provide_status" class="reselect select_gallery">
<option status-id="" value="">请选择发放状态</option>
<?php foreach($provideStatusList as $key => $name):?>
<option status-id="<?=key?>" value="<?=$key?>" <?php if(strval($key) === I('provide_status')):?>selected="selected"<?php endif;?>>
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group normal_space fr" style="margin-left: 9px;">
<label class="form-title select-title" style="margin-right: 9px;"></label>
<div class="select-time">
<input type="text" id="edate" class="txt" name="create_time_end" placeholder="结束时间" value="{:I('create_time_end')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<label class="form-title select-title">申请时间:</label>
<div class="select-time">
<input type="text" id="sdate" class="txt" name="create_time_start" placeholder="开始时间" value="{:I('create_time_start')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<input type="text" name="account" class="txt normal_txt" id="uid" style="width:110px;" placeholder="请输入玩家账号" value="{:I('account')}" onKeyDown="webchat_chkkeysend(event);">
</div>
<div class="form-group normal_space fr">
<span id="server_js">
<select id="server_id" name="server_id" class="reselect select_gallery" style="width:101px">
<option server-id="0" value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['server_id']?>" <?php if($server['server_id'] == I('server_id')):?>selected="selected"<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</span>
</div>
<div class="form-group normal_space fr">
<select id="game_id" name="game_id" class="reselect select_gallery" >
<option game-id="0" value="">请选择游戏</option>
<?php foreach($games as $game):?>
<option game-id="<?=$game['id']?>" value="<?=$game['id']?>" <?php if($game['id'] == I('game_id')):?>selected="selected"<?php endif;?>>
<?=$game['game_name']?>
</option>
<?php endforeach;?>
</select>
</div>
</div>
</div>
</div>
<div class="page-list apply-app_apply-list query-recharge-list">
<div class="trunk-content article">
<div class="tabcon trunk-list">
<table class="table normal_table zwm_tab" >
<tr class="odd zwm_tr">
<th width="125px">批次号</th>
<th>申请时间</th>
<th>游戏名称</th>
<th>区服名称</th>
<th>角色名称</th>
<th>测试账号</th>
<th>手机号</th>
<th>所属推广员</th>
<th>申请人</th>
<!-- <th>发放总金额</th> -->
<th>申请金额</th>
<th>发放金额</th>
<th>审核状态</th>
<th>审核时间</th>
<th>发放状态</th>
<th>发放时间</th>
<!-- <th>资源内容</th> -->
<th>操作</th>
</tr>
<empty name="records">
<tr><td colspan="16" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="records" id="record" mod="2">
<tr data-id="{$record.id}" class="<eq name='mod' value='1'>odd</eq>">
<td style="word-wrap:break-word;">{$record.batch_no}</td>
<td>
<?=substr($record['create_time'], 0, 10)?>
<br>
<?=substr($record['create_time'], 10)?>
</td>
<td>{$record.game_name}</td>
<td>{$record.server_name}</td>
<td>{$record.role_name}</td>
<td>{$record.user_account}</td>
<td>{$record.user_phone}</td>
<td>{$record.promote_account}</td>
<td>{$record.apply_promote_account}</td>
<!-- <td>{$record.history_provide_amount}</td> -->
<td>{$record.apply_amount}</td>
<td>{$record.provide_amount}</td>
<td>
<span class="status-{$record.verify_status}">{$record.verify_status_text}</span>
</td>
<td>
<?=substr($record['verify_time'], 0, 10)?>
<br>
<?=substr($record['verify_time'], 10)?>
</td>
<td>
<span class="status-{$record.provide_status}">{$record.provide_status_text}</span>
</td>
<td>
<?=substr($record['provide_time'], 0, 10)?>
<br>
<?=substr($record['provide_time'], 10)?>
</td>
<!-- <td>{$record.content}</td> -->
<td><button class="view-detail">操作</button></td>
</tr>
</volist>
</empty>
</table>
<div class="pagenation clearfix">
{$pagination}
</div>
</div>
</div>
</div>
</div>
</block>
<block name="script">
<link rel="stylesheet" type="text/css" href="__CSS__/p_jquery.datetimepicker.css">
<script type="text/javascript" src="__JS__/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript">
$().ready(function(){
setValue('row','{:I("get.row",10)}');
$("#pagehtml a").on("click",function(event){
event.preventDefault();//使a自带的方法失效即无法调整到href中的URL(http://www.baidu.com)
var geturl = $(this).attr('href');
$('#data_form').attr('action',geturl);
$('#data_form').submit();
});
$('#sdate').datetimepicker({
lang:'ch',
format:'Y-m-d',
formatDate:'Y-m-d',
timepicker:false
});
$(".select_gallery").select2();
$('#edate').datetimepicker({
lang:'ch',
format:'Y-m-d',
formatDate:'Y-m-d',
timepicker:false
});
$('.view-detail').on({
click:function () {
var url = "{:U('TestingResource/orders', '', '')}"
var id = $(this).parents('tr').eq(0).attr('data-id')
url += '/id/' + id
layer.open({
title: '查看申请订单',
type: 2,
content: [url , 'no'],
area: ['1200px', '400px'],
zIndex: 250,
scrollbar: false,
})
}
})
});
</script>
<script type="text/javascript">
$("#submit").click(function(){
var sdate =$('#sdate').val();
var edate =$('#edate').val();
if(Date.parse(sdate) > Date.parse(edate)){
layer.msg('开始时间必须小于等于结束时间');
return false;
}
var url = $(this).attr('url');
var query = $('#form1').find('input').serialize();
query += "&"+$('#form1').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
$("#game_id").change(function(){
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: {game_id:$("#game_id option:selected").attr('game-id')},
dataType: 'json',
success: function(result) {
if (result.status == 1) {
var servers = result.data.servers
var str = "<option value=''>请选择区服</option>"
for (var i in servers){
str += "<option value='"+servers[i].server_name+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
function webchat_chkkeysend(event)
{
if (event.keyCode==13) {
$('#submit').click();
}
}
</script>
</block>

@ -0,0 +1,499 @@
<extend name="Public/promote_base" />
<block name="css">
<link href="__CSS__/20180207/data.css" rel="stylesheet">
<link href="__CSS__/20180207/manager.css" rel="stylesheet">
<link href="__CSS__/20180207/finance.css" rel="stylesheet">
<style>
@media screen and (max-width: 1500px) {
.normal_form {
padding-top: 45px;
}
.trunk-search .normal_txt {
width: 100px
}
.select2-container--default .select2-selection--single {
width: 125px;
}
.trunk-search .select-time .txt {
width: 100px;
}
.form-group .submit {
width: 55px;
}
}
.open_edit {
color: #19ADED;
text-decoration: none;
line-height: 40px;
border-collapse: collapse;
border-spacing: 0;
}
.apply {
color: #19ADED;
text-decoration: none;
line-height: 40px;
border-collapse: collapse;
border-spacing: 0;
}
.my_text {
position: relative;
padding: 0 10px;
border: 1px solid #D5D5D5;
border-radius: 5px;
outline: none;
font-size: 14px;
font-family: inherit;
height: 38px;
line-height: 38px;
}
.my_save {
width: 95px;
height: 36px;
line-height: 38px;
display: block;
background: #26C7DB;
color: #fff;
border: none;
border-radius: 4px;
text-align: center;
float: left;
cursor: pointer;
text-decoration: none;
padding: 0;
margin: 14px;
font-family: "微软雅黑";
box-sizing: border-box;
}
.td_tit {
width: 112px;
text-align: right;
padding: 0 24px 0 6px;
border: none;
}
.normal_table tr td {
padding: 10px 5px;
}
</style>
</block>
<block name="body">
<div class="page-search normal_list query-recharge-search jssearch">
<div class="trunk-title">
<div class="location">
<div class="location-container">当前位置:<span>测试资源></span><span>测试资源申请</span></div>
</div>
<img src="__IMG__/20180207/icon_normal_shenqing.png">
<span class="title_main">申请测试资源</span>
<span class="details">说明:申请测试资源</span>
</div>
<div class="trunk-content article">
<div class="trunk-search clearfix">
<div id="form1">
<div class="form-group normal_space fr">
<input type="submit" class="submit" id='submit' value="查询" url="{:U('index')}"
style="cursor:pointer;">
</div>
<div class="form-group normal_space fr">
<label class="form-title select-title" style="margin-right: 9px;"></label>
<div class="select-time">
<input type="text" id="edate" class="txt" name="create_time_end" placeholder="结束时间" value="{:I('create_time_end')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<label class="form-title select-title">创建时间:</label>
<div class="select-time">
<input type="text" id="sdate" class="txt" name="create_time_start" placeholder="开始时间"
value="{:I('create_time_start')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<input type="text" name="role_name" class="txt normal_txt" style="width:128px;"
placeholder="角色名称" value="{:I('role_name')}" onKeyDown="webchat_chkkeysend(event);">
</div>
<div class="form-group normal_space fr">
<input type="text" name="account" class="txt normal_txt" id="uid" style="width:128px;"
placeholder="测试账号" value="{:I('account')}" onKeyDown="webchat_chkkeysend(event);">
</div>
<div class="form-group normal_space fr">
<span id="server_js">
<select id="server_id" name="server_id" class="reselect select_gallery" style="width:101px" data-default="<?=I('server_id', '')?>">
<option server-id="0" value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['server_id']?>" <?php if($server['server_id'] == I('server_id')):?>selected="selected"<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</span>
</div>
<div class="form-group normal_space fr">
<select id="game_id" name="game_id" class="reselect select_gallery">
<option game-id="0" value="">请选择游戏</option>
<?php foreach($games as $game):?>
<option game-id="<?=$game['id']?>" value="<?=$game['id']?>" <?php if($game['id'] == I('game_id')):?>selected="selected"<?php endif;?>>
<?=$game['game_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<br>
<br>
<br>
<div class="form-group normal_space fr">
<input type="button" class="submit" id='apply'
style="width: 100px;text-align: center;background:rgb(249,104,104);cursor:pointer;"
value="批量申请后续">
</div>
<div class="form-group normal_space fr">
<input type="button" class="submit" id='add'
style="width: 100px;text-align: center;background:rgb(249,104,104);cursor:pointer;"
value="新增测试号" url="{:U('add')}">
</div>
</div>
</div>
</div>
<div class="page-list apply-app_apply-list query-recharge-list">
<div class="trunk-content article">
<div class="tabcon trunk-list">
<table class="table normal_table">
<tr class="odd">
<th>
选择
</th>
<th>游戏名称</th>
<th>区服名称</th>
<th>测试账号</th>
<th>手机号</th>
<th>角色名称</th>
<th>绑定账号</th>
<th>绑定角色</th>
<th>初始额度</th>
<th>额外额度</th>
<th>累计额度</th>
<th>待审核金额</th>
<th>累计发放资源</th>
<th>今日发放金额</th>
<th>申请总金额</th>
<th>状态</th>
<th>创建时间</th>
</tr>
<empty name="records">
<tr>
<td colspan="15" style="text-align: center;height: 45vh;"><img
src="__IMG__/20180207/icon_wushujv2.png" />
<p style="line-height: 40px;color: #A5A5A5;">暂无数据</p>
</td>
</tr>
<else />
<volist name="records" id="record" mod="2">
<tr class="<eq name='mod' value='1'>odd</eq>">
<td>
<label class="checked">
<input class="ids" type="radio" value="{$record.id}" name="role_id">
<i class="check_icon"></i>
</label>
</td>
<td>{$record.game_name}</td>
<td>{$record.server_name}</td>
<td>{$record.user_account}</td>
<td>{$record.user_phone}</td>
<td>{$record.role_name}</td>
<td>{$record.bind_user_account}</td>
<td>{$record.bind_role_name}</td>
<td>{$record.base_quota}</td>
<td>{$record.other_quota}</td>
<td>{$record.quota}</td>
<td>{$record.verify_amount}</td>
<td>{$record.provide_amount}</td>
<td>{$record.today_amount}</td>
<td>{$record.apply_amount}</td>
<td>{$record.status}</td>
<td>
<?=substr($record['create_time'], 0, 10)?>
<br>
<?=substr($record['create_time'], 10)?>
</td>
</tr>
</volist>
</empty>
</table>
</div>
<div class="pagenation clearfix">
{$pagination}
</div>
</div>
</div>
</div>
<div id="add-box" class="layer-box" style="display: none;">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label>用户账号</label>
<div class="form-item" style="width: 400px;">
<textarea name="accounts" placeholder="用户账号以英文逗号(,)隔开" class="form-input" id="" cols="50" rows="10"></textarea>
</div>
</div>
<div class="form-group">
<label></label>
<a id="add-submit" href="javascript:;" class="add-submit btn">确定</a>
</div>
</form>
</div>
</block>
<block name="script">
<link rel="stylesheet" type="text/css" href="__CSS__/p_jquery.datetimepicker.css">
<script type="text/javascript" src="__JS__/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript">
$().ready(function () {
setValue('row', '{:I("get.row",10)}');
$("#pagehtml a").on("click", function (event) {
event.preventDefault();//使a自带的方法失效即无法调整到href中的URL(http://www.baidu.com)
var geturl = $(this).attr('href');
$('#data_form').attr('action', geturl);
$('#data_form').submit();
});
$('#sdate').datetimepicker({
lang: 'ch',
format: 'Y-m-d',
formatDate: 'Y-m-d',
scrollMonth: false,
scrollTime: false,
scrollInput: false,
timepicker: false
});
$('#apply').click(function () {
var title = '添加测试资源申请'
var url = "{:U('TestingResource/apply', '', '')}"
var id = $('input[name=role_id]:checked').val()
id = id == undefined ? 0 : id;
if (id > 0) {
url += '/id/' + id
} else {
return layer.msg('请选择测试账号角色')
}
layer.open({
title: title,
type: 2,
content: [url , 'no'],
area: ['1000px', '600px'],
zIndex: 250,
scrollbar: false,
})
})
$('#add').click(function () {
var box = $('#add-box')
layer.open({
title: '新增测试账号',
type: 1,
content: box,
area: ['700px', '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')}",
type: "POST",
dataType: "json",
data: { accounts: accounts },
success: function (result) {
if (result.status == 0) {
layer.msg(result.message);
} else {
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); */
}
},
error: function () {
}
});
}
})
$('#batch_add').click(function () {
var ids = $('.ids:checked');
if (ids.length > 0) {
var str = new Array();
ids.each(function () {
str.push($(this).val());
});
param = str.join(',');
} else {
layer.msg('请选择要操作的数据');
return false;
}
var url = "{:U('apply','','')}" + '/id/' + param;
window.location.href = url;
});
$('.apply').click(function () {
var id = $(this).attr('data-id');
var url = "{:U('apply','','')}" + '/id/' + id;
window.location.href = url;
});
$('.open_edit').click(function () {
var account = $(this).attr('data-account');
var password = $(this).attr('data-password');
var game_name = $(this).attr('data-game_name');
var server_name = $(this).attr('data-server_name');
var role_name = $(this).attr('data-role_name');
var support_id = $(this).attr('data-support_id');
$('#i_account').val(account);
$('#i_password').val(password);
$('#i_game_name').val(game_name);
$('#i_server_name').val(server_name);
$('#i_role_name').val(role_name);
$('#i_support_id').val(support_id);
var id_editor = '.div_editor';
//页面层
layer.open({
type: 1,
title: '新增扶持-修改',
closeBtn: 1,
area: ['600px', '429px'],
//skin: 'layui-layer-bgwhite', //白色背景色
shadeClose: true,
content: $(id_editor),
})
});
$('.i_cancel').click(function () {
location.reload();
});
$(".select_gallery").select2();
$('#edate').datetimepicker({
lang: 'ch',
format: 'Y-m-d',
formatDate: 'Y-m-d',
timepicker: false
});
});
</script>
<script type="text/javascript">
$("#submit").click(function () {
var sdate = $('#sdate').val();
var edate = $('#edate').val();
if (Date.parse(sdate) > Date.parse(edate)) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
var url = $(this).attr('url');
var query = $('#form1').find('input').serialize();
query += "&" + $('#form1').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
window.location.href = url;
});
$("#game_id").change(function () {
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: $("#game_id option:selected").attr('game-id') },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
var servers = result.data.servers
var str = "<option value=''>请选择区服</option>"
for (var i in servers){
str += "<option value='"+servers[i].server_id+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
$("#server_js").click(function (event) {
var game_id = $("#game_id").val();
if (game_id == 0) {
layer.msg('请先选择游戏');
}
});
function webchat_chkkeysend(event) {
if (event.keyCode == 13) {
$('#submit').click();
}
}
</script>
</block>

@ -0,0 +1,156 @@
<extend name="Public/basic"/>
<block name="body">
<style>
.trunk-search .form-group {
margin-left: 10px;
}
.normal_table input {
position: relative;
padding: 5px;
border: 1px solid #E5E5E5;
border-radius: 4px;
height: 25px;
}
.normal_table td {
padding: 5px;
}
.normal_table td select {
width: 100%;
}
.normal_table td button {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.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;
}
.normal_table td .status-0 {
color: #e6a23c;
}
.normal_table td .status-1 {
color: #67c23a;
}
.normal_table td .status-2 {
color: #f56c6c;
}
.normal_table tr td {
padding: 10px 5px;
}
</style>
<div class="page-search normal_list promoteCoin-record-search" style="padding: 20px;">
<div class="trunk-content article">
<div class="trunk-list list_normal">
<div class="table-wrapper" style="height: 200px;">
<table id="resource-table" class="table normal_table">
<tr class="odd zwm_tr">
<th>申请ID</th>
<th>申请时间</th>
<th>游戏名称</th>
<th>玩家账号</th>
<th>区服名称</th>
<th>角色名称</th>
<th>申请人</th>
<th>资源内容</th>
<th>资源价值</th>
<th>申请数量</th>
<th>申请金额</th>
<th>申请备注</th>
<th>发放状态</th>
</tr>
<empty name="records">
<tr><td colspan="14" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="records" id="record" mod="2">
<tr data-id="{$record.id}" class="<eq name='mod' value='1'>odd</eq>">
<td>{$record.id}</td>
<td>
<?=substr($record['create_time'], 0, 10)?>
<br>
<?=substr($record['create_time'], 10)?>
</td>
<td>{$record.game_name}</td>
<td>{$record.user_account}</td>
<td>{$record.server_name}</td>
<td>{$record.role_name}</td>
<td>{$record.apply_promote_account}</td>
<td>{$record.ref_name}</td>
<td>{$record.ref_amount}</td>
<td>{$record.num}</td>
<td>{$record.amount}</td>
<td>{$record.remark}</td>
<td><span class="status-{$record.provide_status}">{$record.provide_status_text}</span></td>
</tr>
</volist>
</empty>
</table>
</div>
<!-- <div class="pagenation clearfix">
{$pagination}
</div> -->
</div>
</div>
</div>
</block>
<block name="script">
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script type="text/javascript">
</script>
</block>

@ -2401,3 +2401,89 @@ 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,
`game_id` int(11) NOT NULL COMMENT '游戏ID',
`user_id` int(11) unsigned NOT NULL COMMENT '测试用户ID',
`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',
`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(32) NOT NULL COMMENT '订单号',
`ref_id` varchar(30) NOT NULL COMMENT '测试资源ID第三方',
`ref_name` varchar(150) NOT NULL COMMENT '测试资源名称(第三方)',
`ref_amount` decimal(12, 2) not null default '0.00' comment '测试资源价值(第三方)',
`num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量',
`provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝',
`provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发放时间',
`amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
`result` 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',
`server_id` int(11) NOT NULL DEFAULT '0' COMMENT '区服ID',
`role_id` varchar(50) NOT NULL DEFAULT '' COMMENT '角色ID',
`apply_amount` decimal(12, 2) not null default '0.00' comment '申请金额',
`provide_amount` decimal(12, 2) not null default '0.00' comment '发放金额',
`provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 异常',
`provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发放时间',
`apply_promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请推广员ID',
`verify_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未审核 1 审核通过 2 未审核通过',
`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;
alter table tab_user_play_info add column `game_role_id` varchar(80) not null DEFAULT '' COMMENT '游戏角色标识' after role_level;
alter table tab_user_play_info add column `testing_other_quota` decimal(12, 2) not null 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`);

@ -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;

Loading…
Cancel
Save