提交 bbe88f00 编写于 作者: D devil_gong

钱包优化,新增上传附件钩子

上级 5297be8e
......@@ -10,6 +10,8 @@
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\facade\Hook;
/**
* 百度编辑器控制器入口
* @author Devil
......@@ -130,6 +132,14 @@ class Ueditor extends Common
$path = input('path');
if(!empty($path))
{
// 附件删除前处理钩子
$hook_name = 'plugins_controller_attachment_delete_handle_begin';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'path' => &$path,
]);
$path = (__MY_ROOT_PUBLIC__ == '/') ? substr(ROOT_PATH, 0, -1).$path : str_replace(__MY_ROOT_PUBLIC__, ROOT_PATH, $path);
if(file_exists($path))
{
......@@ -137,6 +147,14 @@ class Ueditor extends Common
{
if(unlink($path))
{
// 附件删除成功后处理钩子
$hook_name = 'plugins_controller_attachment_delete_handle_end';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'path' => $path,
]);
$this->current_result = json_encode(array(
'state'=> 'SUCCESS'
));
......@@ -171,7 +189,7 @@ class Ueditor extends Common
*/
private function ActionUpload()
{
$type = "file";
$attachment_type = "file";
switch(htmlspecialchars($this->current_action))
{
case 'uploadimage':
......@@ -181,7 +199,7 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['imageAllowFiles']
);
$field_name = $this->current_config['imageFieldName'];
$type = "image";
$attachment_type = "image";
break;
case 'uploadscrawl':
......@@ -192,7 +210,7 @@ class Ueditor extends Common
"oriName" => "scrawl.png"
);
$field_name = $this->current_config['scrawlFieldName'];
$type = "base64";
$attachment_type = "base64";
break;
case 'uploadvideo':
......@@ -202,7 +220,7 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['videoAllowFiles']
);
$field_name = $this->current_config['videoFieldName'];
$type = "video";
$attachment_type = "video";
break;
case 'uploadfile':
......@@ -213,11 +231,21 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['fileAllowFiles']
);
$field_name = $this->current_config['fileFieldName'];
$type = "file";
$attachment_type = "file";
}
// 附件上传前处理钩子
$hook_name = 'plugins_controller_attachment_upload_handle_begin';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'attachment_type' => $attachment_type,
'field_name' => $field_name,
'temp_config' => &$temp_config,
]);
/* 生成上传实例对象并完成上传 */
$up = new \base\Uploader($field_name, $temp_config, $type);
$up = new \base\Uploader($field_name, $temp_config, $attachment_type);
/**
* 得到上传文件所对应的各个参数,数组结构
......@@ -230,9 +258,21 @@ class Ueditor extends Common
* "size" => "", //文件大小
* )
*/
$data = $up->getFileInfo();
// 附件上传成功后处理钩子
$hook_name = 'plugins_controller_attachment_upload_handle_end';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'attachment_type' => $attachment_type,
'field_name' => $field_name,
'temp_config' => $temp_config,
'data' => &$data,
]);
// 返回数据
$this->current_result = json_encode($up->getFileInfo());
$this->current_result = json_encode($data);
}
/**
......@@ -275,76 +315,80 @@ class Ueditor extends Common
$end = $start + $size;
/* 获取文件列表 */
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
$files = $this->GetFilesList($path, $allow_files);
// 倒序
//$files = $this->ArrayQuickSort($files);
if (!count($files)) {
$this->current_result = json_encode(array(
$data = array(
"state" => "no match file",
"list" => array(),
"start" => $start,
"total" => count($files)
));
}
"total" => 0,
);
/* 获取指定范围的列表 */
$len = count($files);
$list = [];
for ($i = min($end, $len) - 1; $i < $len && $i >= 0 && $i >= $start; $i--)
// 是否从磁盘获取数据 0否, 1是
$is_disk_get = 1;
// 附件列表获取处理钩子
$hook_name = 'plugins_controller_attachment_get_list_handle';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'is_disk_get' => &$is_disk_get,
'data' => &$data,
]);
// 是否从磁盘获取数据
if($is_disk_get == 1)
{
$list[] = $files[$i];
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
$this->GetFilesList($path, $allow_files, $size, $start, $end, $data);
}
/* 返回数据 */
$this->current_result = json_encode(array(
"state" => "SUCCESS",
"list" => $list,
"start" => $start,
"total" => count($files)
));
$this->current_result = json_encode($data);
}
/**
* 文件快速排序
* [GetFilesList 获取目录下的指定类型的文件]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-25
* @desc description
* @param [array] $data [需要排序的数据(选择一个基准元素,将待排序分成小和打两罐部分,以此类推递归的排序划分两罐部分)]
* @return [array] [排序好的数据]
* @version 0.0.1
* @datetime 2017-01-17T23:24:59+0800
* @param [string] $path [路径地址]
* @param [string] $allow_files [允许的文件]
* @param [int] $size [条数]
* @param [int] $start [起始]
* @param [int] $end [结束标记]
* @param [array] $data [返回数据]
* @return [array] [数据]
*/
private function ArrayQuickSort($data)
private function GetFilesList($path, $allow_files, $size, $start, $end, &$data)
{
if(!empty($data) && is_array($data))
{
$len = count($data);
if($len <= 1) return $data;
// 从磁盘获取文件
$files = $this->GetDirFilesList($path, $allow_files, $files);
$base = $data[0];
$left_array = array();
$right_array = array();
for($i=1; $i<$len; $i++)
// 倒序
//$files = $this->ArrayQuickSort($files);
if(count($files) > 0)
{
if($base['mtime'] < $data[$i]['mtime'])
/* 获取指定范围的列表 */
$len = count($files);
$list = [];
for ($i = min($end, $len) - 1; $i < $len && $i >= 0 && $i >= $start; $i--)
{
$left_array[] = $data[$i];
} else {
$right_array[] = $data[$i];
}
$list[] = $files[$i];
}
if(!empty($left_array)) $left_array = $this->ArrayQuickSort($left_array);
if(!empty($right_array)) $right_array = $this->ArrayQuickSort($right_array);
return array_merge($left_array, array($base), $right_array);
/* 返回数据 */
$data = array(
"state" => "SUCCESS",
"list" => $list,
"start" => $start,
"total" => count($files)
);
}
}
/**
* [GetFilesList 遍历获取目录下的指定类型的文件]
* 遍历获取目录下的指定类型的文件
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
......@@ -354,7 +398,7 @@ class Ueditor extends Common
* @param [array] &$files [数据]
* @return [array] [数据]
*/
private function GetFilesList($path, $allow_files, &$files = array())
private function GetDirFilesList($path, $allow_files, &$files = array())
{
if(!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
......@@ -367,7 +411,7 @@ class Ueditor extends Common
$path2 = $path . $file;
if(is_dir($path2))
{
$this->GetFilesList($path2, $allow_files, $files);
$this->GetDirFilesList($path2, $allow_files, $files);
} else {
if(preg_match("/\.(".$allow_files.")$/i", $file))
{
......@@ -382,6 +426,42 @@ class Ueditor extends Common
return $files;
}
/**
* 文件快速排序
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-25
* @desc description
* @param [array] $data [需要排序的数据(选择一个基准元素,将待排序分成小和打两罐部分,以此类推递归的排序划分两罐部分)]
* @return [array] [排序好的数据]
*/
private function ArrayQuickSort($data)
{
if(!empty($data) && is_array($data))
{
$len = count($data);
if($len <= 1) return $data;
$base = $data[0];
$left_array = array();
$right_array = array();
for($i=1; $i<$len; $i++)
{
if($base['mtime'] < $data[$i]['mtime'])
{
$left_array[] = $data[$i];
} else {
$right_array[] = $data[$i];
}
}
if(!empty($left_array)) $left_array = $this->ArrayQuickSort($left_array);
if(!empty($right_array)) $right_array = $this->ArrayQuickSort($right_array);
return array_merge($left_array, array($base), $right_array);
}
}
/**
* [ActionCrawler 抓取远程文件]
* @author Devil
......@@ -416,6 +496,14 @@ class Ueditor extends Common
));
}
// 附件抓取远程文件取结束处理钩子
$hook_name = 'plugins_controller_attachment_crawler_handle_end';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'list' => &$list,
]);
/* 返回抓取数据 */
$this->current_result = json_encode(array(
'state'=> count($list) ? 'SUCCESS':'ERROR',
......
......@@ -35,6 +35,7 @@
<li>3. 如果您的手机已失效,可以 <a href="{{:MyUrl('index/safety/index')}}">绑定邮箱</a> 后通过接收邮件完成验证。</li>
<li>4. 请正确输入下方图形验证码,如看不清可点击图片进行更换,输入完成后进行下一步操作。</li>
<li>5. 收到安全验证码后,请在{{:Myc('common_verify_expire_time', 600, true)/60}}分钟内完成验证。</li>
<li>6. 安全验证成功后,请在30分钟内完成提现申请。</li>
</ul>
</div>
<!-- tips end -->
......
......@@ -26,6 +26,7 @@
{{include file="../../../plugins/view/wallet/index/public/nav" /}}
<!-- user menu end -->
{{if isset($check_status) and $check_status eq 1}}
<!-- form start -->
<form class="am-form form-validation create-info" method="post" action="{{:PluginsHomeUrl('wallet', 'cash', 'create')}}" request-type="ajax-url" request-value="{{:PluginsHomeUrl('wallet', 'cash', 'index')}}">
<div class="am-form-group">
......@@ -70,6 +71,9 @@
</div>
</form>
<!-- form end -->
{{else /}}
<div class="table-no"><i class="am-icon-warning"></i> 安全验证已超时,请重新验证再操作 <a class="am-btn am-btn-link" href="{{:PluginsHomeUrl('wallet', 'cash', 'authinfo')}}">申请提现</a></div>
{{/if}}
</div>
</div>
<!-- content end -->
......
......@@ -70,13 +70,9 @@
<tr>
<th>提现单号</th>
<th>提现金额(元)</th>
<th class="am-hide-sm-only">打款金额(元)</th>
<th>状态</th>
<th class="am-hide-sm-only">收款银行</th>
<th>收款账号</th>
<th class="am-hide-sm-only">开户人姓名</th>
<th>收款信息</th>
<th class="am-hide-sm-only">打款信息</th>
<th class="am-hide-sm-only">描述</th>
<th class="am-hide-sm-only">打款时间</th>
<th class="am-hide-sm-only">创建时间</th>
</tr>
</thead>
......@@ -86,13 +82,21 @@
<tr>
<td>{{$v.cash_no}}</td>
<td class="money-bold">{{$v.money}}</td>
<td class="am-hide-sm-only money-bold money">{{if $v['pay_money'] gt 0}}{{$v.pay_money}}{{/if}}</td>
<td>{{$v.status_text}}</td>
<td class="am-hide-sm-only">{{$v.bank_name}}</td>
<td>{{$v.bank_accounts}}</td>
<td class="am-hide-sm-only">{{$v.bank_username}}</td>
<td>
银行:{{$v.bank_name}}<br />
账号:{{$v.bank_accounts}}<br />
姓名:{{$v.bank_username}}<br />
</td>
<td class="am-hide-sm-only">
{{$v.status_text}}<br />
{{if $v['pay_money'] gt 0}}
金额:<span class="money-bold money">{{$v.pay_money}}</span><br />
{{/if}}
{{if !empty($v['pay_time_text'])}}
时间:{{$v.pay_time_text}}
{{/if}}
</td>
<td class="am-hide-sm-only operation-msg">{{$v.msg}}</td>
<td class="am-hide-sm-only">{{$v.pay_time_text}}</td>
<td class="am-hide-sm-only">{{$v.add_time_text}}</td>
</tr>
{{/foreach}}
......
......@@ -118,6 +118,11 @@ class Cash extends Common
*/
public function createinfo($params = [])
{
// 是否验证成功
$check_time = session('plugins_wallet_cash_check_success');
$check_status = (!empty($check_time) && $check_time+1800 >= time()) ? 1 : 0;
$this->assign('check_status', $check_status);
// 参数
$this->assign('params', $params);
return $this->fetch('../../../plugins/view/wallet/index/cash/createinfo');
......@@ -207,7 +212,7 @@ class Cash extends Common
// 开始处理
$params['user'] = $this->user;
return CashService::Create($params);
return CashService::CashCreate($params);
}
}
?>
\ No newline at end of file
......@@ -213,7 +213,7 @@ class CashService
if($obj->CheckCorrect($params['verify']))
{
// 校验成功标记
session('wallet_cash_'.$params['account_type'], true);
session('plugins_wallet_cash_check_success', time());
// 清除验证码
$obj->Remove();
......@@ -232,7 +232,7 @@ class CashService
* @desc description
* @param [array] $params [输入参数]
*/
public static function Create($params = [])
public static function CashCreate($params = [])
{
// 数据验证
$p = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册