You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.9 KiB
57 lines
1.9 KiB
12 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
|
||
|
namespace app\common\middleware;
|
||
|
|
||
|
|
||
|
use app\Request;
|
||
|
use think\exception\ValidateException;
|
||
|
use think\facade\Cache;
|
||
|
use think\Response;
|
||
|
|
||
|
class MerchantCheckBaseInfoMiddleware extends BaseMiddleware
|
||
|
{
|
||
|
|
||
|
protected $rules = [
|
||
|
'merchantAttachmentCategoryCreate',
|
||
|
'merchantUpdate',
|
||
|
'merchantUploadImage',
|
||
|
'merchant.Common/uploadCertificate',
|
||
|
'merchantAttachmentCategoryUpdate',
|
||
|
'merchantAttachmentCategoryDelete',
|
||
|
'merchantAttachmentUpdate',
|
||
|
'merchantAttachmentDelete'
|
||
|
];
|
||
|
|
||
|
public function before(Request $request)
|
||
|
{
|
||
|
$name = $this->request->rule()->getName();
|
||
|
if ($this->request->method() == 'GET' || in_array($name, $this->rules)) return;
|
||
|
$cache = Cache::store('file');
|
||
|
$merchant = $request->merchant();
|
||
|
|
||
|
$key = 'mer_valid_' . $merchant->mer_id;
|
||
|
if ($cache->has($key)) return;
|
||
|
|
||
|
|
||
|
if (!$merchant->mer_avatar || !$merchant->mer_banner || !$merchant->mer_info || !$merchant->mer_address) {
|
||
|
throw new ValidateException('您好,请前往左侧菜单【设置】-【商户基本信息】完善商户基本信息。');
|
||
|
}
|
||
|
Cache::store('file')->set('mer_valid_' . $merchant->mer_id, 1, 3600 * 8);
|
||
|
}
|
||
|
|
||
|
public function after(Response $response)
|
||
|
{
|
||
|
// TODO: Implement after() method.
|
||
|
}
|
||
|
}
|