代码优化

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 Base\Service\GameSourceService;
use Base\Tool\PlistParser;
use Base\Tool\ApkParser;
/**
* 后台首页控制器
*
@ -23,42 +20,23 @@ class SourceEvent extends Controller
public function add_source()
{
$data = $_REQUEST;
$data['file_size'] = round($data['file_size'] / pow(1024, 2), 2) . "MB";
$data['file_url'] = $data['file_url'] . "/" . $data['file_name'];
$data['sdk_version'] = $data['file_type'];
$params = $_REQUEST;
$data = [];
$data['game_id'] = $params['game_id'];
$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_account'] = session("user_auth.username");
$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['source_version'] = 0;
$version = '';
$packageName = '';
if ($data['file_type'] == 1) {
$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'];
$data['bao_name'] = $params['bao_name'];
$data['version'] = $params['version'];
$data['file_type'] = $params['file_type'];
if (M('game_source', 'tab_')->add($data)) {
//原包打包
$this->update_game_size($data);

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

@ -223,7 +223,7 @@ class PromoteRepository {
if (isset($params['begin_time']) && isset($params['begin_time'])) {
$subMap['create_time'] = ['lt', $params['begin_time']];
}
$subQuery = M('user_play_info', 'tab_')->field('user_id')->group('user_id')->where($subMap)->buildSql();
if (isset($map['_string'])) {
$map['_string'] .= ' and user_id not in (' . $subQuery . ')';
@ -234,7 +234,6 @@ class PromoteRepository {
$resultMap = ['_string' => 'user_id in (' . $inQuery . ')'];
$items = M('user_play_info', 'tab_')->field(['count(*) count', 'promote_id'])->where($resultMap)->group('promote_id')->select();
$records = [];
foreach ($items as $item) {
$promoteId = $item['promote_id'];

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

Loading…
Cancel
Save