代码优化

master
ELF 5 years ago
parent c75d1bf3ad
commit 1fd7023c5f

@ -88,4 +88,11 @@ class ConsoleController extends Think {
} }
} }
} }
/* public function generatePromoteUserLoginCount()
{
$promotes = M('user_login_record')->where('1=1')->limit(10, 20)->select();
M('user_login_record', 'tab_')->field(['count(DISTINCT user_id) as count', 'promote_id', 'FROM_UNIXTIME(login_time,"%Y-%m-%d") day'])
->where(['promote_id' => ['in', $ids]])->group('promote_id, day')->select();
} */
} }

@ -10,9 +10,6 @@ namespace Admin\Event;
use Think\Controller; use Think\Controller;
use Base\Service\GameSourceService; use Base\Service\GameSourceService;
use Base\Tool\PlistParser;
use Base\Tool\ApkParser;
/** /**
* 后台首页控制器 * 后台首页控制器
* *
@ -23,42 +20,23 @@ class SourceEvent extends Controller
public function add_source() public function add_source()
{ {
$data = $_REQUEST; $params = $_REQUEST;
$data['file_size'] = round($data['file_size'] / pow(1024, 2), 2) . "MB"; $data = [];
$data['file_url'] = $data['file_url'] . "/" . $data['file_name']; $data['game_id'] = $params['game_id'];
$data['sdk_version'] = $data['file_type']; $data['game_name'] = $params['game_name'];
$data['file_name'] = $params['file_name'];
$data['file_size'] = round($params['file_size'] / pow(1024, 2), 2) . "MB";
$data['file_url'] = '';
$data['sdk_version'] = $params['file_type'];
$data['op_id'] = UID; $data['op_id'] = UID;
$data['op_account'] = session("user_auth.username"); $data['op_account'] = session("user_auth.username");
$data['create_time'] = NOW_TIME; $data['create_time'] = NOW_TIME;
$remark = str_replace(array("\r\n", "\r", "\n"), "@@@", $_POST['remark']); $remark = str_replace(array("\r\n", "\r", "\n"), "@@@", $params['remark']);
$data['remark'] = json_encode(explode('@@@', $remark)); $data['remark'] = json_encode(explode('@@@', $remark));
$data['source_version'] = 0; $data['source_version'] = 0;
$version = ''; $data['bao_name'] = $params['bao_name'];
$packageName = ''; $data['version'] = $params['version'];
if ($data['file_type'] == 1) { $data['file_type'] = $params['file_type'];
$parser = new ApkParser();
$parser->open($data['file_url']);
$version = $parser->getVersionName();
$packageName = $parser->getPackage();
} elseif($data['file_type'] == 2) {
$parser = new PlistParser();
$parser->openFromIpa($data['file_url'], PlistParser::PREG_INFO_PLIST);
$result = $parser->getResult();
$version = $result['CFBundleShortVersionString'];
$packageName = $result['CFBundleIdentifier'];
}
$data['version'] = $version;
$data['bao_name'] = $packageName;
$game = M('game', 'tab_')->where(['id' => $data['game_id']])->find();
$gameSourceService = new GameSourceService();
$result = $gameSourceService->sourcePack($data, $game);
if (!$result['status']) {
$this->error('添加失败' , U('GameSource/lists', ['type' => $data['type']]));
}
$data['plist_url'] = $result['data']['plistUrl'];
$data['org_plist_url'] = $result['data']['orgPlistUrl'];
$data['file_url'] = $result['data']['fileUrl'];
$data['original_url'] = $result['data']['originalUrl'];
if (M('game_source', 'tab_')->add($data)) { if (M('game_source', 'tab_')->add($data)) {
//原包打包 //原包打包
$this->update_game_size($data); $this->update_game_size($data);

@ -95,7 +95,7 @@
<tr class="picbox"> <tr class="picbox">
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>上传原包</td> <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>上传原包</td>
<td class="r"> <td class="r">
<span class=" table_btn table_uploads"> <span class=" table_btn table_uploads">
<div id="uploader" class="wu-example"> <div id="uploader" class="wu-example">
<div class="btns"> <div class="btns">
<div id="picker">上传原包</div> <div id="picker">上传原包</div>
@ -104,15 +104,14 @@
<div id="thelist" class="uploader-list"> <div id="thelist" class="uploader-list">
</div> </div>
</div> </div>
<input type="hidden" id="data" name="data" value="000"/> <input type="hidden" id="data" name="data" value=""/>
<input type="hidden" id="file_id" name="file_id" value="{$data['file_id']}"/> <input type="hidden" id="file_name" name="file_name" value=""/>
<input type="hidden" id="file_name" name="file_name" value="{$data['file_name']}"/> <input type="hidden" id="file_url" name="file_url" value=""/>
<input type="hidden" id="file_url" name="file_url" value="{$data['file_url']}"/> <input type="hidden" id="file_size" name="file_size" value=""/>
<input type="hidden" id="file_size" name="file_size" value="{$data['file_size']}"/> <input type="hidden" id="package_name" name="bao_name" value=""/>
<input type="hidden" id="file_name2" name="file_name2" value="{$data['file_name2']}"/> <input type="hidden" id="package_version" name="version" value=""/>
<input type="hidden" id="file_url2" name="file_url2" value="{$data['file_url2']}"/> </span>
</span> <span class="notice-text">更新原包后会自动进行推广员游戏包更新,打包完成后,对应推广员下的游戏包无需更新,渠道玩家即可下载最新版游戏包(前提:服务器开启定时任务)</span>
<span class="notice-text">更新原包后会自动进行推广员游戏包更新,打包完成后,对应推广员下的游戏包无需更新,渠道玩家即可下载最新版游戏包(前提:服务器开启定时任务)</span>
</td> </td>
<!-- <td class="l pack_name_class">原包名称:</td> <!-- <td class="l pack_name_class">原包名称:</td>
<td class="r pack_name_class" colspan='1'> <td class="r pack_name_class" colspan='1'>
@ -123,20 +122,20 @@
<tr> <tr>
<td class="l"><i class="mustmark" style="margin-left:-7px;display:none" id="apply_bz">*</i>包名:</td> <td class="l"><i class="mustmark" style="margin-left:-7px;display:none" id="apply_bz">*</i>包名:</td>
<td class="r"> <td class="r">
<input type="text" class="txt" name="bao_name" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled"> <input type="text" class="txt" id="show_package_name" name="bao_name" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled">
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="l">原包版本:</td> <td class="l">原包版本:</td>
<td class="r"> <td class="r">
<input type="text" class="txt" name="version" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled"> <input type="text" class="txt" id="show_package_version" name="version" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled">
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="l">原包大小:</td> <td class="l">原包大小:</td>
<td class="r"> <td class="r">
<input type="text" class="txt" name="gsize" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled"> <input type="text" class="txt" id="show_package_size" name="gsize" style="background:#E7E7E7" value="无需填写,自动生成" disabled="disabled">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -176,7 +175,7 @@
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
//导航高亮 //导航高亮
highlight_subnav('{:U('GameSource/lists')}'); highlight_subnav("{:U('GameSource/lists')}");
$('#submit').click(function(){ $('#submit').click(function(){
$('#form').submit(); $('#form').submit();
}); });
@ -201,7 +200,7 @@ $(function(){
}); });
var userInfo = {userId:"kazaff", md5:""}; //用户会话信息 var userInfo = {userId:"kazaff", md5:""}; //用户会话信息
var chunkSize = 5000 * 1024; //分块大小 var chunkSize = 2 * 1000 * 1024; //分块大小
var uniqueFileName = null; //文件唯一标识符 var uniqueFileName = null; //文件唯一标识符
var md5Mark = null; var md5Mark = null;
var backEndUrl = "{:U('File/shard_upload',array('session_id'=>session_id()))}"; var backEndUrl = "{:U('File/shard_upload',array('session_id'=>session_id()))}";
@ -222,32 +221,24 @@ WebUploader.Uploader.register({
userInfo.md5 = val; userInfo.md5 = val;
$.ajax({ $.ajax({
type: "POST" type: "POST"
, url: backEndUrl , url: 'http://47.111.118.107:9501/upload/check-md5'
, data: {status: "md5Check", md5: val} , data: {fileMd5: val, fileName: file.name}
, cache: false , cache: false
, timeout: 1000 //todo 超时的话,只能认为该文件不曾上传过 , timeout: 1000 //todo 超时的话,只能认为该文件不曾上传过
, dataType: "json" , dataType: "json"
}).then(function(data, textStatus, jqXHR){ }).then(function(response, textStatus, jqXHR) {
alert(data.chunk); task.resolve();
//console.log(data); uniqueFileName = response.data.chunkFileName
if(data.ifExist){ //若存在这返回失败给WebUploader表明该文件不需要上传 userInfo.chunkFileName = response.data.chunkFileName
task.reject();
uploader.skipFile(file);
file.path = data.path;
}else{
task.resolve();
//拿到上传文件的唯一名称,用于断点续传
uniqueFileName = md5(''+userInfo.userId+file.name+file.type+file.lastModifiedDate+file.size);
}
}, function(jqXHR, textStatus, errorThrown){ //任何形式的验证失败,都触发重新上传 }, function(jqXHR, textStatus, errorThrown){ //任何形式的验证失败,都触发重新上传
task.resolve(); task.resolve();
//拿到上传文件的唯一名称,用于断点续传 //拿到上传文件的唯一名称,用于断点续传
uniqueFileName = md5(''+userInfo.userId+file.name+file.type+file.lastModifiedDate+file.size); // uniqueFileName = md5(''+userInfo.userId+file.name+file.type+file.lastModifiedDate+file.size);
}); });
}); });
return $.when(task); return $.when(task);
} }
, beforeSend: function(block){ /* , beforeSend: function(block){
//分片验证是否已传过,用于断点续传 //分片验证是否已传过,用于断点续传
var task = new $.Deferred(); var task = new $.Deferred();
$.ajax({ $.ajax({
@ -273,7 +264,7 @@ WebUploader.Uploader.register({
}); });
return $.when(task); return $.when(task);
} } */
, afterSendFile: function(file){ , afterSendFile: function(file){
var chunksTotal = 0; var chunksTotal = 0;
if((chunksTotal = Math.ceil(file.size/chunkSize)) > 1){ if((chunksTotal = Math.ceil(file.size/chunkSize)) > 1){
@ -281,23 +272,28 @@ WebUploader.Uploader.register({
var task = new $.Deferred(); var task = new $.Deferred();
$.ajax({ $.ajax({
type: "POST" type: "POST"
, url: backEndUrl , url: 'http://47.111.118.107:9501/upload/merge-chunks'
, data: { , data: {
status: "chunksMerge" chunkFileName: uniqueFileName
, name: uniqueFileName
, chunks: chunksTotal , chunks: chunksTotal
, ext: file.ext , extension: file.ext
, md5: md5Mark , md5: md5Mark
} }
, cache: false , cache: false
, dataType: "json" , dataType: "json"
}).then(function(data, textStatus, jqXHR){ }).then(function(response, textStatus, jqXHR){
console.log(response)
//todo 检查响应是否正常 //todo 检查响应是否正常
task.resolve(); task.resolve();
file.path = data.path; file.path = data.path;
$("#file_name").val(data.name); $("#file_name").val(response.data.fileName);
$("#file_url").val(data.path); $("#file_url").val(response.data.filePath);
$("#file_size").val(file.size); $("#file_size").val(file.size);
$("#package_name").val(response.data.packageName);
$("#package_version").val(response.data.packageVersion);
$("#show_package_name").val(response.data.packageName);
$("#show_package_size").val(parseFloat(file.size/(1024*1024)).toFixed(2) + 'M');
$("#show_package_version").val(response.data.packageVersion);
}, function(jqXHR, textStatus, errorThrown){ }, function(jqXHR, textStatus, errorThrown){
task.reject(); task.reject();
}); });
@ -313,7 +309,7 @@ var uploader = new WebUploader.Uploader({
// swf文件路径 // swf文件路径
swf: '__STATIC__/webuploader/Uploader.swf', swf: '__STATIC__/webuploader/Uploader.swf',
// 文件接收服务端。 // 文件接收服务端。
server: "{:U('File/shard_upload',array('session_id'=>session_id()))}", server: 'http://47.111.118.107:9501/upload/index',
// 选择文件的按钮。可选。 // 选择文件的按钮。可选。
// 内部根据当前运行是创建可能是input元素也可能是flash. // 内部根据当前运行是创建可能是input元素也可能是flash.
pick: {id:'#picker'}, pick: {id:'#picker'},
@ -334,7 +330,7 @@ var uploader = new WebUploader.Uploader({
formData: function(){return $.extend(true, {}, userInfo);}, formData: function(){return $.extend(true, {}, userInfo);},
duplicate:true, duplicate:true,
chunked:true, chunked:true,
chunkSize: 5*1000*1024, chunkSize: chunkSize,
duplicate: true duplicate: true
}); });
@ -367,11 +363,11 @@ uploader.on( 'uploadSuccess', function( file , response) {
$( '#'+file.id ).find('p.state').text('已上传'); $( '#'+file.id ).find('p.state').text('已上传');
// alert(JSON.stringify(response)); // alert(JSON.stringify(response));
if(!response.chunk){ /* if(!response.chunk){
$("#file_name").val(response.name); $("#file_name").val(response.name);
$("#file_url").val(response.path); $("#file_url").val(response.path);
$("#file_size").val(response.size); $("#file_size").val(response.size);
} } */
//alert($("#file_name").val()+";"+$("#file_url").val()+";"+$("#file_size").val()) //alert($("#file_name").val()+";"+$("#file_url").val()+";"+$("#file_size").val())
}); });

@ -234,7 +234,6 @@ class PromoteRepository {
$resultMap = ['_string' => 'user_id in (' . $inQuery . ')']; $resultMap = ['_string' => 'user_id in (' . $inQuery . ')'];
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select(); $items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select();
$records = []; $records = [];
foreach ($items as $item) { foreach ($items as $item) {
$promoteId = $item['promote_id']; $promoteId = $item['promote_id'];

@ -2004,33 +2004,33 @@ class QueryController extends BaseController
if (I('p', 1) == 1) { if (I('p', 1) == 1) {
$selfParams = $params; $selfParams = $params;
$selfParams['isContainSubs'] = false; $selfParams['isContainSubs'] = false;
$selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$promote['id']], $selfParams); $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
$selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$promote['id']], $selfParams); $selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$parent['id']], $selfParams);
$selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$promote['id']], $selfParams); $selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$parent['id']], $selfParams);
// $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$promote['id']], $selfParams); // $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams);
$selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$promote['id']], $selfParams); $selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams);
$selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$promote['id']], $selfParams); $selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams);
$selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$promote['id']], $selfParams); $selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams);
$selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$promote['id']], $selfParams); $selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
$selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$promote['id']], $selfParams); $selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
$records[] = [ $records[] = [
'id' => $parent['id'], 'id' => $parent['id'],
'account' => $parent['account'], 'account' => $parent['account'],
'real_name' => $parent['real_name'], 'real_name' => $parent['real_name'],
'level' => $parent['level'], 'level' => $parent['level'],
'create_role_count' => $selfCreateRoleCountList[$promote['id']], 'create_role_count' => $selfCreateRoleCountList[$parent['id']],
'create_role_user_count' => $selfCreateRoleUserCountList[$promote['id']], 'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$promote['id']], 'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$parent['id']],
// 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$promote['id']], // 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']],
'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$promote['id']], 'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']],
'login_user_count' => $selfLoginUserCountList[$promote['id']], 'login_user_count' => $selfLoginUserCountList[$parent['id']],
'recharge_count' => $selfRechargeCountList[$promote['id']], 'recharge_count' => $selfRechargeCountList[$parent['id']],
'recharge_user_count' => $selfRechargeUserCountList[$promote['id']], 'recharge_user_count' => $selfRechargeUserCountList[$parent['id']],
'recharge_amount' => $selfRechargeAmountList[$promote['id']]['ban_coin'] + $rechargeAmountList[$promote['id']]['coin'] + $rechargeAmountList[$promote['id']]['cash'], 'recharge_amount' => $selfRechargeAmountList[$parent['id']]['ban_coin'] + $rechargeAmountList[$parent['id']]['coin'] + $rechargeAmountList[$parent['id']]['cash'],
'recharge_by_ban_coin' => $selfRechargeAmountList[$promote['id']]['ban_coin'], 'recharge_by_ban_coin' => $selfRechargeAmountList[$parent['id']]['ban_coin'],
'recharge_by_coin' => $selfRechargeAmountList[$promote['id']]['coin'], 'recharge_by_coin' => $selfRechargeAmountList[$parent['id']]['coin'],
'recharge_by_cash' => $selfRechargeAmountList[$promote['id']]['cash'], 'recharge_by_cash' => $selfRechargeAmountList[$parent['id']]['cash'],
'current_display' => $currentDisplay, 'current_display' => $currentDisplay,
]; ];
} }

Loading…
Cancel
Save