提交 bbe88f00 编写于 作者: D devil_gong

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

上级 5297be8e
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\admin\controller; namespace app\admin\controller;
use think\facade\Hook;
/** /**
* 百度编辑器控制器入口 * 百度编辑器控制器入口
* @author Devil * @author Devil
...@@ -130,6 +132,14 @@ class Ueditor extends Common ...@@ -130,6 +132,14 @@ class Ueditor extends Common
$path = input('path'); $path = input('path');
if(!empty($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); $path = (__MY_ROOT_PUBLIC__ == '/') ? substr(ROOT_PATH, 0, -1).$path : str_replace(__MY_ROOT_PUBLIC__, ROOT_PATH, $path);
if(file_exists($path)) if(file_exists($path))
{ {
...@@ -137,6 +147,14 @@ class Ueditor extends Common ...@@ -137,6 +147,14 @@ class Ueditor extends Common
{ {
if(unlink($path)) 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( $this->current_result = json_encode(array(
'state'=> 'SUCCESS' 'state'=> 'SUCCESS'
)); ));
...@@ -171,7 +189,7 @@ class Ueditor extends Common ...@@ -171,7 +189,7 @@ class Ueditor extends Common
*/ */
private function ActionUpload() private function ActionUpload()
{ {
$type = "file"; $attachment_type = "file";
switch(htmlspecialchars($this->current_action)) switch(htmlspecialchars($this->current_action))
{ {
case 'uploadimage': case 'uploadimage':
...@@ -181,7 +199,7 @@ class Ueditor extends Common ...@@ -181,7 +199,7 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['imageAllowFiles'] "allowFiles" => $this->current_config['imageAllowFiles']
); );
$field_name = $this->current_config['imageFieldName']; $field_name = $this->current_config['imageFieldName'];
$type = "image"; $attachment_type = "image";
break; break;
case 'uploadscrawl': case 'uploadscrawl':
...@@ -192,7 +210,7 @@ class Ueditor extends Common ...@@ -192,7 +210,7 @@ class Ueditor extends Common
"oriName" => "scrawl.png" "oriName" => "scrawl.png"
); );
$field_name = $this->current_config['scrawlFieldName']; $field_name = $this->current_config['scrawlFieldName'];
$type = "base64"; $attachment_type = "base64";
break; break;
case 'uploadvideo': case 'uploadvideo':
...@@ -202,7 +220,7 @@ class Ueditor extends Common ...@@ -202,7 +220,7 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['videoAllowFiles'] "allowFiles" => $this->current_config['videoAllowFiles']
); );
$field_name = $this->current_config['videoFieldName']; $field_name = $this->current_config['videoFieldName'];
$type = "video"; $attachment_type = "video";
break; break;
case 'uploadfile': case 'uploadfile':
...@@ -213,11 +231,21 @@ class Ueditor extends Common ...@@ -213,11 +231,21 @@ class Ueditor extends Common
"allowFiles" => $this->current_config['fileAllowFiles'] "allowFiles" => $this->current_config['fileAllowFiles']
); );
$field_name = $this->current_config['fileFieldName']; $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 ...@@ -230,9 +258,21 @@ class Ueditor extends Common
* "size" => "", //文件大小 * "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,36 +315,115 @@ class Ueditor extends Common ...@@ -275,36 +315,115 @@ class Ueditor extends Common
$end = $start + $size; $end = $start + $size;
/* 获取文件列表 */ /* 获取文件列表 */
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path; $data = array(
$files = $this->GetFilesList($path, $allow_files); "state" => "no match file",
"list" => array(),
"start" => $start,
"total" => 0,
);
// 是否从磁盘获取数据 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)
{
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
$this->GetFilesList($path, $allow_files, $size, $start, $end, $data);
}
/* 返回数据 */
$this->current_result = json_encode($data);
}
/**
* [GetFilesList 获取目录下的指定类型的文件]
* @author Devil
* @blog http://gong.gg/
* @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 GetFilesList($path, $allow_files, $size, $start, $end, &$data)
{
// 从磁盘获取文件
$files = $this->GetDirFilesList($path, $allow_files, $files);
// 倒序 // 倒序
//$files = $this->ArrayQuickSort($files); //$files = $this->ArrayQuickSort($files);
if (!count($files)) { if(count($files) > 0)
$this->current_result = json_encode(array( {
"state" => "no match file", /* 获取指定范围的列表 */
"list" => array(), $len = count($files);
$list = [];
for ($i = min($end, $len) - 1; $i < $len && $i >= 0 && $i >= $start; $i--)
{
$list[] = $files[$i];
}
/* 返回数据 */
$data = array(
"state" => "SUCCESS",
"list" => $list,
"start" => $start, "start" => $start,
"total" => count($files) "total" => count($files)
)); );
} }
}
/* 获取指定范围的列表 */ /**
$len = count($files); * 遍历获取目录下的指定类型的文件
$list = []; * @author Devil
for ($i = min($end, $len) - 1; $i < $len && $i >= 0 && $i >= $start; $i--) * @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-01-17T23:24:59+0800
* @param [string] $path [路径地址]
* @param [string] $allow_files [允许的文件]
* @param [array] &$files [数据]
* @return [array] [数据]
*/
private function GetDirFilesList($path, $allow_files, &$files = array())
{
if(!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
$handle = opendir($path);
$document_root = GetDocumentRoot();
while(false !== ($file = readdir($handle)))
{ {
$list[] = $files[$i]; if($file != '.' && $file != '..')
{
$path2 = $path . $file;
if(is_dir($path2))
{
$this->GetDirFilesList($path2, $allow_files, $files);
} else {
if(preg_match("/\.(".$allow_files.")$/i", $file))
{
$files[] = array(
'url'=> substr($path2, strlen($document_root)),
'mtime'=> filemtime($path2)
);
}
}
}
} }
return $files;
/* 返回数据 */
$this->current_result = json_encode(array(
"state" => "SUCCESS",
"list" => $list,
"start" => $start,
"total" => count($files)
));
} }
/** /**
...@@ -343,45 +462,6 @@ class Ueditor extends Common ...@@ -343,45 +462,6 @@ class Ueditor extends Common
} }
} }
/**
* [GetFilesList 遍历获取目录下的指定类型的文件]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-01-17T23:24:59+0800
* @param [string] $path [路径地址]
* @param [string] $allow_files [允许的文件]
* @param [array] &$files [数据]
* @return [array] [数据]
*/
private function GetFilesList($path, $allow_files, &$files = array())
{
if(!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
$handle = opendir($path);
$document_root = GetDocumentRoot();
while(false !== ($file = readdir($handle)))
{
if($file != '.' && $file != '..')
{
$path2 = $path . $file;
if(is_dir($path2))
{
$this->GetFilesList($path2, $allow_files, $files);
} else {
if(preg_match("/\.(".$allow_files.")$/i", $file))
{
$files[] = array(
'url'=> substr($path2, strlen($document_root)),
'mtime'=> filemtime($path2)
);
}
}
}
}
return $files;
}
/** /**
* [ActionCrawler 抓取远程文件] * [ActionCrawler 抓取远程文件]
* @author Devil * @author Devil
...@@ -416,6 +496,14 @@ class Ueditor extends Common ...@@ -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( $this->current_result = json_encode(array(
'state'=> count($list) ? 'SUCCESS':'ERROR', 'state'=> count($list) ? 'SUCCESS':'ERROR',
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<li>3. 如果您的手机已失效,可以 <a href="{{:MyUrl('index/safety/index')}}">绑定邮箱</a> 后通过接收邮件完成验证。</li> <li>3. 如果您的手机已失效,可以 <a href="{{:MyUrl('index/safety/index')}}">绑定邮箱</a> 后通过接收邮件完成验证。</li>
<li>4. 请正确输入下方图形验证码,如看不清可点击图片进行更换,输入完成后进行下一步操作。</li> <li>4. 请正确输入下方图形验证码,如看不清可点击图片进行更换,输入完成后进行下一步操作。</li>
<li>5. 收到安全验证码后,请在{{:Myc('common_verify_expire_time', 600, true)/60}}分钟内完成验证。</li> <li>5. 收到安全验证码后,请在{{:Myc('common_verify_expire_time', 600, true)/60}}分钟内完成验证。</li>
<li>6. 安全验证成功后,请在30分钟内完成提现申请。</li>
</ul> </ul>
</div> </div>
<!-- tips end --> <!-- tips end -->
......
...@@ -26,50 +26,54 @@ ...@@ -26,50 +26,54 @@
{{include file="../../../plugins/view/wallet/index/public/nav" /}} {{include file="../../../plugins/view/wallet/index/public/nav" /}}
<!-- user menu end --> <!-- user menu end -->
<!-- form start --> {{if isset($check_status) and $check_status eq 1}}
<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')}}"> <!-- form start -->
<div class="am-form-group"> <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')}}">
<label>提现金额<span class="am-form-group-label-tips-must">必填</span></label> <div class="am-form-group">
<div class="am-input-group am-input-group-sm"> <label>提现金额<span class="am-form-group-label-tips-must">必填</span></label>
<input type="number" autocomplete="off" name="money" step="0.01" min="0.00" max="{{$user_wallet.normal_money}}" class="am-radius" placeholder="提现金额" data-validation-message="请输入提现金额" required /> <div class="am-input-group am-input-group-sm">
<span class="am-input-group-btn"> <input type="number" autocomplete="off" name="money" step="0.01" min="0.00" max="{{$user_wallet.normal_money}}" class="am-radius" placeholder="提现金额" data-validation-message="请输入提现金额" required />
<button type="button" class="am-btn am-btn-default am-radius"></button> <span class="am-input-group-btn">
</span> <button type="button" class="am-btn am-btn-default am-radius"></button>
</span>
</div>
<div class="am-alert" data-am-alert>
当前可用金额 <span class="cash-normal-mony">{{$user_wallet.normal_money}}</span>
</div>
</div> </div>
<div class="am-alert" data-am-alert>
当前可用金额 <span class="cash-normal-mony">{{$user_wallet.normal_money}}</span>
</div>
</div>
<div class="am-form-group"> <div class="am-form-group">
<label>收款银行<span class="am-form-group-label-tips-must">必填</span></label> <label>收款银行<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_name" placeholder="收款银行" minlength="1" maxlength="60" data-validation-message="收款银行格式 1~60 个字符之间" class="am-radius" required /> <input type="text" name="bank_name" placeholder="收款银行" minlength="1" maxlength="60" data-validation-message="收款银行格式 1~60 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert> <div class="am-alert" data-am-alert>
强烈建议优先填写国有4大银行(中国银行、中国建设银行、中国工商银行和中国农业银行) 请填写详细的开户银行分行名称,虚拟账户如支付宝、财付通、微信 直接填写 支付宝 即可。 强烈建议优先填写国有4大银行(中国银行、中国建设银行、中国工商银行和中国农业银行) 请填写详细的开户银行分行名称,虚拟账户如支付宝、财付通、微信 直接填写 支付宝 即可。
</div>
</div> </div>
</div>
<div class="am-form-group"> <div class="am-form-group">
<label>收款账号<span class="am-form-group-label-tips-must">必填</span></label> <label>收款账号<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_accounts" placeholder="收款账号" minlength="1" maxlength="60" data-validation-message="收款账号格式 1~60 个字符之间" class="am-radius" required /> <input type="text" name="bank_accounts" placeholder="收款账号" minlength="1" maxlength="60" data-validation-message="收款账号格式 1~60 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert> <div class="am-alert" data-am-alert>
银行账号或虚拟账号(支付宝、财付通等账号) 银行账号或虚拟账号(支付宝、财付通等账号)
</div>
</div> </div>
</div>
<div class="am-form-group"> <div class="am-form-group">
<label>开户人姓名<span class="am-form-group-label-tips-must">必填</span></label> <label>开户人姓名<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_username" placeholder="开户人姓名" minlength="1" maxlength="30" data-validation-message="开户人姓名格式 1~30 个字符之间" class="am-radius" required /> <input type="text" name="bank_username" placeholder="开户人姓名" minlength="1" maxlength="30" data-validation-message="开户人姓名格式 1~30 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert> <div class="am-alert" data-am-alert>
收款账号的开户人姓名 收款账号的开户人姓名
</div>
</div> </div>
</div>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">确认提现</button> <button type="submit" class="am-btn am-btn-primary am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">确认提现</button>
</div> </div>
</form> </form>
<!-- form end --> <!-- 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>
</div> </div>
<!-- content end --> <!-- content end -->
......
...@@ -70,13 +70,9 @@ ...@@ -70,13 +70,9 @@
<tr> <tr>
<th>提现单号</th> <th>提现单号</th>
<th>提现金额(元)</th> <th>提现金额(元)</th>
<th class="am-hide-sm-only">打款金额(元)</th> <th>收款信息</th>
<th>状态</th> <th class="am-hide-sm-only">打款信息</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>
<th class="am-hide-sm-only">创建时间</th> <th class="am-hide-sm-only">创建时间</th>
</tr> </tr>
</thead> </thead>
...@@ -86,13 +82,21 @@ ...@@ -86,13 +82,21 @@
<tr> <tr>
<td>{{$v.cash_no}}</td> <td>{{$v.cash_no}}</td>
<td class="money-bold">{{$v.money}}</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>
<td>{{$v.status_text}}</td> 银行:{{$v.bank_name}}<br />
<td class="am-hide-sm-only">{{$v.bank_name}}</td> 账号:{{$v.bank_accounts}}<br />
<td>{{$v.bank_accounts}}</td> 姓名:{{$v.bank_username}}<br />
<td class="am-hide-sm-only">{{$v.bank_username}}</td> </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 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> <td class="am-hide-sm-only">{{$v.add_time_text}}</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
......
...@@ -118,6 +118,11 @@ class Cash extends Common ...@@ -118,6 +118,11 @@ class Cash extends Common
*/ */
public function createinfo($params = []) 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); $this->assign('params', $params);
return $this->fetch('../../../plugins/view/wallet/index/cash/createinfo'); return $this->fetch('../../../plugins/view/wallet/index/cash/createinfo');
...@@ -207,7 +212,7 @@ class Cash extends Common ...@@ -207,7 +212,7 @@ class Cash extends Common
// 开始处理 // 开始处理
$params['user'] = $this->user; $params['user'] = $this->user;
return CashService::Create($params); return CashService::CashCreate($params);
} }
} }
?> ?>
\ No newline at end of file
...@@ -213,7 +213,7 @@ class CashService ...@@ -213,7 +213,7 @@ class CashService
if($obj->CheckCorrect($params['verify'])) if($obj->CheckCorrect($params['verify']))
{ {
// 校验成功标记 // 校验成功标记
session('wallet_cash_'.$params['account_type'], true); session('plugins_wallet_cash_check_success', time());
// 清除验证码 // 清除验证码
$obj->Remove(); $obj->Remove();
...@@ -232,7 +232,7 @@ class CashService ...@@ -232,7 +232,7 @@ class CashService
* @desc description * @desc description
* @param [array] $params [输入参数] * @param [array] $params [输入参数]
*/ */
public static function Create($params = []) public static function CashCreate($params = [])
{ {
// 数据验证 // 数据验证
$p = [ $p = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册