feat: 新增账号安全模块及资质校验功能
- 新增账号安全页面及支付密码验证组件 - 新增用户类型选择流程及商家资质管理 - 新增订单资质校验逻辑,师傅需满足订单证书要求 - 新增企业资质认证相关数据库表及接口 - 优化用户列表展示,区分个人与商家用户类型
这个提交包含在:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace app\common\library;
|
||||
|
||||
use think\Loader;
|
||||
|
||||
/** Reads an already-authorized attachment without accepting a caller-supplied remote URL. */
|
||||
class EnterpriseLicenseImage
|
||||
{
|
||||
public static function read(array $attachment)
|
||||
{
|
||||
$url = (string)($attachment['url'] ?? '');
|
||||
$size = (int)($attachment['filesize'] ?? 0);
|
||||
if ($url === '' || $url[0] !== '/' || $size <= 0 || $size > 10 * 1024 * 1024) {
|
||||
throw new \RuntimeException('营业执照图片无效');
|
||||
}
|
||||
if (($attachment['storage'] ?? '') === 'cos') {
|
||||
$config = get_addon_config('cos');
|
||||
if (!$config || empty($config['bucket']) || empty($config['region']) || empty($config['secretId']) || empty($config['secretKey'])) {
|
||||
throw new \RuntimeException('云存储未配置');
|
||||
}
|
||||
Loader::addNamespace('Qcloud\\Cos', ROOT_PATH . 'addons/cos/library/Qcloud/Cos/');
|
||||
$client = new \Qcloud\Cos\Client([
|
||||
'region' => $config['region'], 'schema' => 'https',
|
||||
'credentials' => ['secretId' => $config['secretId'], 'secretKey' => $config['secretKey']],
|
||||
]);
|
||||
$result = $client->getObject(['Bucket' => $config['bucket'], 'Key' => ltrim($url, '/'), 'Range' => 'bytes=0-10485760']);
|
||||
$bytes = (string)$result['Body'];
|
||||
} elseif (($attachment['storage'] ?? '') === 'local') {
|
||||
$root = realpath(ROOT_PATH . 'public');
|
||||
$file = realpath(ROOT_PATH . 'public' . $url);
|
||||
if (!$root || !$file || strpos($file, $root . DIRECTORY_SEPARATOR) !== 0 || !is_file($file) || !is_readable($file)) {
|
||||
throw new \RuntimeException('营业执照图片不存在');
|
||||
}
|
||||
if (filesize($file) > 10 * 1024 * 1024) throw new \RuntimeException('营业执照图片过大');
|
||||
$bytes = file_get_contents($file);
|
||||
} else {
|
||||
throw new \RuntimeException('不支持的图片存储类型');
|
||||
}
|
||||
if (!is_string($bytes) || $bytes === '' || strlen($bytes) > 10 * 1024 * 1024) {
|
||||
throw new \RuntimeException('营业执照图片读取失败');
|
||||
}
|
||||
return $bytes;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户