Jelajahi Sumber

[智价云] 阿里云组件&oss图片存储

tangyuanwang 2 bulan lalu
induk
melakukan
a5a2e26170

+ 54 - 0
app/Http/Controllers/Manager/Upload.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Http\Controllers\manager;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\Manager\Upload as Request;
+use App\Models\manager\Common\Attachment as AttachmentModel;
+
+/**
+ * 上传接口
+ * @author    唐远望
+ * @version   1.0
+ * @date      2025-12-23
+ */
+class Upload extends Controller
+{
+
+    /**
+     * 上传图片
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-23
+     * 
+     * */
+    public function uploadimg(Request $request, AttachmentModel $attachmentModel)
+    {
+        $request->scene('uploadimg')->validate();
+        $file   = request()->file('file');
+        $res_img_url = $attachmentModel->uploadMediaAsync($file);
+        // 上传失败
+        if (!$res_img_url)  return json_send(['code' => 'error', 'msg' => '上传失败']);
+        // 返回数据
+        return        json_send(['code' => 'success', 'msg' => '上传成功', 'data' => $res_img_url]);
+    }
+
+
+    /**
+     * 获取签名上传地址
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-23
+     * 
+     */
+    public function get_sign_url(Request $request, AttachmentModel $attachmentModel)
+    {
+        $request->scene('get_sign_url')->validate();
+        $all_data = request()->all();
+        $res_img_url = $attachmentModel->getSignUrl($all_data['file_name']);
+        // 上传失败
+        if (!$res_img_url)  return json_send(['code' => 'error', 'msg' => '获取失败']);
+        // 返回数据
+        return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $res_img_url]);
+    }
+}

+ 72 - 0
app/Http/Requests/Manager/Upload.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Http\Requests\Manager;
+
+use App\Http\Requests\BaseRequest;
+
+/**
+ * 上传管理-验证规则
+ * @author 唐远望
+ * @version 1.0
+ * @date 2025-12-22
+ * 
+ */
+class Upload extends BaseRequest
+{
+    /**
+     * 获取应用于请求的规则
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        // 返回结果
+        return      [
+            'name'                 => 'required',
+            'id'                => 'required|integer|gt:0',
+            'status'            => 'required|integer|in:0,1',
+            'page'              => 'integer|min:1',
+            'limit'             => 'integer|min:1',
+            'file'              => 'required|file',
+            'file_name'         => 'required',
+        ];
+    }
+
+
+    // 场景列表
+    protected   $scenes         = [
+        'detail'             => ['id'],
+        'list'               => ['page', 'limit'],
+        'add'                      => ['name', 'status'],
+        'edit'                  => ['id', 'name'],
+        'set_status'              => ['id', 'status'],
+        'delete'                  => ['id'],
+        'uploadimg'             => ['file'],
+        'get_sign_url'          => ['file_name'],
+    ];
+
+    /**
+     * 获取已定义验证规则的错误消息
+     *
+     * @return array
+     */
+    public function messages()
+    {
+        return [
+            'name.required'     => '名称必填',
+            'id.required'       => 'ID未知',
+            'id.integer'        => 'ID格式错误',
+            'id.gt'             => 'ID格式错误',
+            'status.required'   => '状态未知',
+            'status.integer'    => '状态格式错误',
+            'status.in'         => '状态格式错误',
+            'page.integer'      => '页码格式错误',
+            'page.min'          => '页码格式错误',
+            'limit.integer'     => '每页数量格式错误',
+            'limit.min'         => '每页数量格式错误',
+            'file.required'     => '文件未上传',
+            'file.file'         => '文件格式错误',
+            'file_name.required' => '文件名未知',
+        ];
+    }
+}

+ 300 - 0
app/Models/Manager/Common/Attachment.php

@@ -0,0 +1,300 @@
+<?php
+
+namespace App\Models\manager\Common;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Intervention\Image\Facades\Image;
+use App\Servers\Aliyun\Oss;
+
+/**
+ * 附件模型
+ * @author 唐远望
+ * @version 1.0
+ * @date 2025-12-23
+ */
+
+class Attachment extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'attachment';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+
+
+    /**
+     * 上传图片到阿里云oss
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-23
+     * @param $request_data 请求数据
+     * @return array
+     */
+    public function uploadMediaAsync($file)
+    {
+        $file_info = $this->getFileInfo($file);
+        $fileName           = $file_info ? $file_info['hash_name'] : '';
+        $filePath           = $file_info ? $file_info['path_name'] : '';
+        $Oss                = new Oss();
+        $res_img_url                = $Oss->uploadFile($fileName, $filePath, "zhijiayun-jiansuo", "uploads/process");
+        if ($res_img_url) {
+            $this->addUploadimage($file, $res_img_url);
+        }
+        return $res_img_url;
+    }
+
+
+
+    /**
+     * 获取签名上传地址
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-05-29
+     * @return array
+     */
+    public function getSignUrl($file_name)
+    {
+        $Oss                = new Oss();
+        $path_dir = "uploads/process/" . date('ymd') . '/' . uniqid() . $file_name;
+        $res_img_url                = $Oss->signUrl("zhijiayun-jiansuo", $path_dir);
+        return $res_img_url;
+    }
+
+
+
+    /**
+     * 添加图片上传记录
+     * @author    唐远望
+     * @version   1.0
+     * @date      2025-12-23
+     * @param $file 文件对象
+     * @param $url 素材url
+     * @return int
+     */
+    public function addUploadimage($file, $url)
+    {
+        $image = Image::make($file->getPathname());
+        $fileInfo = $this->getFileInfo($file);
+        $attachment_data = [
+            'category' => 'image',
+            'url' => $url,
+            'imagewidth' => $image->width(),
+            'imageheight' => $image->height(),
+            'imagetype' => $fileInfo['real_extension'],
+            'filename' => $fileInfo['original_name'],
+            'filesize' => $fileInfo['file_size'],
+            'mimetype' => $fileInfo['mime_type'],
+            'createtime' => time(),
+            'storage' => 'tencent',
+            'sha1' => $fileInfo['hash_name'],
+        ];
+        $result = $this->insertGetId($attachment_data);
+        return $result;
+    }
+
+    /**
+     * 校验文件格式
+     * @param $file
+     * @return string
+     */
+    public function checkUploadFile($file)
+    {
+        $media_type = '';
+        $allowed_image_extensions = ['jpg', 'jpeg', 'png', 'gif'];
+        $extension = $file->getClientOriginalExtension();
+        if (in_array(strtolower($extension), $allowed_image_extensions)) {
+            $media_type = 'image';
+        }
+        $allowed_video_extensions = ['mp4', 'avi', 'wmv', 'mov', 'rmvb', 'flv'];
+        if (in_array(strtolower($extension), $allowed_video_extensions)) {
+            $media_type = 'video';
+        }
+        $allowed_voice_extensions = ['amr', 'wav', 'wma', 'aac', 'flac', 'mp3'];
+        if (in_array(strtolower($extension), $allowed_voice_extensions)) {
+            $media_type = 'voice';
+        }
+        $allowed_txt_extensions = ['txt'];
+        if (in_array(strtolower($extension), $allowed_txt_extensions)) {
+            $media_type = 'file';
+        }
+        return $media_type;
+    }
+
+
+    /**
+     * 校验素材信息
+     * @param $media_type
+     * @param $media_file
+     * @return bool|array
+     */
+    public function checkuploadmedia($media_file)
+    {
+        $media_type = $this->checkUploadFile($media_file);
+        switch ($media_type) {
+            case 'image':
+                if (!$this->checkImgSize($media_file)) {
+                    return ['errcode' => 'error', 'message' => '图片大小超出限制'];
+                }
+                break;
+            case 'voice':
+                if (!$this->checkVoiceSize($media_file)) {
+                    return ['errcode' => 'error', 'message' => '语音大小超出限制'];
+                }
+                break;
+            case 'video':
+                if (!$this->checkVideoSize($media_file)) {
+                    return ['errcode' => 'error', 'message' => '视频大小超出限制'];
+                }
+                break;
+            case 'file':
+                if (!$this->checkTxtSize($media_file)) {
+                    return ['errcode' => 'error', 'message' => '文件大小超出限制'];
+                }
+                break;
+            default:
+                return ['errcode' => 'error', 'message' => '素材类型错误'];
+        }
+    }
+
+
+    /**
+     * 获取文件信息
+     * @param $file
+     * @return bool|array
+     */
+    public function getFileInfo($file)
+    {
+        if (!$file) {
+            return false;
+        }
+        $fileInfo = [
+            'original_name' => $file->getClientOriginalName(), //获取文件原始名称(客户端上传时的文件名)
+            'extension' => $file->getClientOriginalExtension(), //获取文件扩展名
+            'mime_type' => $file->getClientMimeType(), //获取文件mime类型
+            'file_size' => $file->getSize(), //获取文件大小
+            'real_extension' => $file->extension(), //获取文件真实扩展名
+            'hash_name' => $file->hashName(), //获取文件哈希名(唯一标识)
+            'path_name' => $file->getPathname() //获取文件绝对路径
+        ];
+        // 使用 $fileInfo 中的信息
+        return $fileInfo;
+    }
+
+    /**
+     * 校验图片格式
+     * @param $file
+     * @return bool
+     */
+    public function checkImgFormat($file)
+    {
+        $allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
+        $extension = $file->getClientOriginalExtension();
+        if (!in_array(strtolower($extension), $allowed_extensions)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验图片大小
+     * @param $file
+     * @param int $size
+     */
+    public function checkImgSize($file, $size = 2)
+    {
+        $max_size = $size * 1024 * 1024; // 2M
+        if ($file->getSize() > $max_size) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验语音格式
+     * @param $file
+     */
+    public function checkVoiceFormat($file)
+    {
+        $allowed_extensions = ['amr', 'wav', 'wma', 'aac', 'flac'];
+        $extension = $file->getClientOriginalExtension();
+        if (!in_array(strtolower($extension), $allowed_extensions)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验语音大小
+     * @param $file
+     * @param int $size
+     */
+    public function checkVoiceSize($file, $size = 5)
+    {
+        $max_size = $size * 1024 * 1024; // 5M
+        if ($file->getSize() > $max_size) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验视频格式
+     * @param $file
+     */
+    public function checkVideoFormat($file)
+    {
+        $allowed_extensions = ['mp4', 'avi', 'wmv', 'mov', 'rmvb', 'flv'];
+        $extension = $file->getClientOriginalExtension();
+        if (!in_array(strtolower($extension), $allowed_extensions)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验视频大小
+     * @param $file
+     * @param int $size
+     */
+    public function checkVideoSize($file, $size = 10)
+    {
+        $max_size = $size * 1024 * 1024; // 10M
+        if ($file->getSize() > $max_size) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验txt格式
+     */
+    public function checkTxtFormat($file)
+    {
+        $allowed_extensions = ['txt'];
+        $extension = $file->getClientOriginalExtension();
+        if (!in_array(strtolower($extension), $allowed_extensions)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 校验txt大小
+     * @param $file
+     * @param int $size
+     */
+    public function checkTxtSize($file, $size = 10)
+    {
+        $max_size = $size * 1024 * 1024; // 10M
+        if ($file->getSize() > $max_size) {
+            return false;
+        }
+        return true;
+    }
+}

+ 37 - 0
app/Servers/Aliyun/Client.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+
+use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
+use Darabonba\OpenApi\Models\Config;
+
+/**
+ * 阿里
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+class Client
+{
+
+    /**
+     * 使用AK&SK初始化账号Client
+     * @return Dysmsapi Client
+     */
+    public static function createClient()
+    {
+        // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
+        // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/311677.html。
+        $config = new Config([
+            // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
+            "accessKeyId" => config('aliyun.sms.accessKeyId', ''),
+            // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
+            "accessKeySecret" => config('aliyun.sms.accessKeySecret', ''),
+        ]);
+        // Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
+        $config->endpoint = "dysmsapi.aliyuncs.com";
+        // 返回结果
+        return              new Dysmsapi($config);
+    }
+}

+ 76 - 0
app/Servers/Aliyun/ContentGreen.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+use AlibabaCloud\SDK\Green\V20220302\Green;
+use \Exception;
+use AlibabaCloud\Tea\Exception\TeaError;
+use AlibabaCloud\Tea\Utils\Utils;
+
+use Darabonba\OpenApi\Models\Config;
+use AlibabaCloud\SDK\Green\V20220302\Models\TextModerationRequest;
+use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
+use App\Facades\Servers\Logs\Log;
+
+/**
+ * 阿里内容安全
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+class ContentGreen
+{
+    function __construct() {}
+    /**
+     * 使用AK&SK初始化账号Client
+     * @return Green Client
+     */
+    public static function createClient()
+    {
+        // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
+        // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/311677.html。
+        $config = new Config([
+            // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
+            "accessKeyId" => config('aliyun.accessKeyId', ''),
+            // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
+            "accessKeySecret" => config('aliyun.accessKeySecret', '')
+        ]);
+        // Endpoint 请参考 https://api.aliyun.com/product/Green
+        $config->endpoint = "green-cip.cn-shenzhen.aliyuncs.com";
+        return new Green($config);
+    }
+
+    /**
+     * @param string[] $args
+     * @return void
+     */
+    public function main($content, $service = 'nickname_detection')
+    {
+        $client = self::createClient();
+        $serviceParameters  = [
+            'content' => $content
+        ];
+        $textModerationRequest = new TextModerationRequest([
+            "service" => $service,
+            "serviceParameters" => json_encode($serviceParameters),
+        ]);
+        try {
+            // 复制代码运行请自行打印 API 的返回值
+            $response       = $client->textModerationWithOptions($textModerationRequest, new RuntimeOptions([]));
+            if ($response->body->code    ==   200) {
+                return $response->body->data->descriptions;
+            }
+            return  false;
+        } catch (Exception $error) {
+            if (!($error instanceof TeaError)) {
+                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
+            }
+            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
+            // 错误 message
+            var_dump($error->message);
+            // 诊断地址
+            var_dump($error->data["Recommend"]);
+            Utils::assertAsString($error->message);
+        }
+    }
+}

+ 56 - 0
app/Servers/Aliyun/IpLocation.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+use Ixudra\Curl\Facades\Curl;
+
+/**
+ * ip归属地
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+class IpLocation
+{
+
+	/**
+	 * 获取IP归属地
+	 * @param		string    $ip		    IP地址
+	 * @param		string		$field      获取字段,可以选字段
+	 * 
+	 * @return		string|array
+	 * 
+	 * */
+	public function getCityByIp($ip = '', $field = '')
+	{
+		// 获取IP
+		$ip                                     = $ip ? $ip : request()->ip();
+		// 从缓存读取数据
+		$result									= cache('aliyunMarketGetCityByIp:' . ip2long($ip), []);
+		// 如果有数据
+		if ($result)							return $field ? (isset($result[$field]) ? $result[$field] : '') : $result;
+		// 读取AppCode
+		$appcode	                            = config('aliyun_appcode', '3e494a5f38c44e0c97424fd122e348c3');
+		// 提示未配置
+		if (empty($appcode))                   ['error' => '请联系管理员设置接口 appcode'];
+		// 拼接路径
+		$path		                            = 'https://bf1c.api.huachen.cn/ip'; //'https://hcapi20.market.alicloudapi.com/ip';
+		// 头部信息
+		$headers 	                            = ['Authorization:APPCODE ' . $appcode];
+		// 拼接参数
+		$url 		                            = $path . '?ip=' . $ip;
+		// 接收返回值json格式并转数组
+		$result		                            = Curl::to($url)->withHeaders($headers)->asJsonResponse(true)->get();
+		// 如果错误
+		if (empty($result['data']))            return $field ? '' : [];
+		if (empty($result['ret']))             return $field ? '' : [];
+		// 如果错误$result['ret'].='=>'.$result['msg']
+		if ($result['ret'] != 200)             return $field ? '' : [];
+		// 存储到缓存,有效期6小时
+		cache(['aliyunMarketGetCityByIp:' . ip2long($ip) => $result['data']], 3600 * 6);
+		// 如果存在返回国家/地区
+		if ($field)							return isset($result['data'][$field]) ? $result['data'][$field] : '';
+		// 否则返回整个数组数据
+		return 									$result['data'];
+	}
+}

+ 115 - 0
app/Servers/Aliyun/Oss.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+use OSS\OssClient;
+use OSS\Core\OssException;
+use OSS\Credentials\StaticCredentialsProvider;
+use App\Facades\Servers\Logs\Log;
+
+/**
+ * 阿里oss
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+
+class Oss
+{
+    private $ossClient;
+    function __construct()
+    {
+        $accessKeyId        =   config('aliyun.oss.accessKeyId', '');
+        $accessKeySecret    =   config('aliyun.oss.accessKeySecret', '');
+        $provider           =   new StaticCredentialsProvider($accessKeyId, $accessKeySecret);
+        $endpoint           =   'https://' . config('aliyun.oss.endpoint', 'oss-cn-shenzhen') . '.aliyuncs.com';
+        $config = array(
+            "provider" => $provider,
+            "endpoint" => $endpoint,
+            "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
+            "region" => "cn-shenzhen"
+        );
+        $this->ossClient = new OssClient($config);
+    }
+    /**
+     *  使用签名URL上传
+     * @param string 	bucket	存储空间名称
+     * @param string 	object	不包含Bucket名称在内的Object完整路径
+     *
+     * */
+    function signUrl($bucket, $object, $options = ['Content-Type' => 'multipart/form-data'])
+    {
+        // 指定签名URL的过期时间为600s(最长可达32400s)。
+        $timeout = 600;
+        try {
+            // 生成签名URL。
+            $signedUrl = $this->ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
+            return $signedUrl;
+        } catch (OssException $e) {
+            Log::error('oss/signUrl', '获取签名URL上传失败,错误:' . json_encode($e->getMessage()));
+            return false;
+        }
+    }
+    /**
+     *  上传文件
+     * @param string 	file_name	文件名称
+     * @param string 	bucket	    存储空间名称
+     * @param string 	object	    填写Object完整目录路径,例如exampledir/。Object路径中不能包含Bucket名称。
+     * @param string 	filePath	填写本地文件的完整路径,例如D:\\localpath\\examplefile.txt。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
+     *
+     * */
+    public function uploadFile($file_name, $filePath, $bucket = "", $object = "uploads/shop")
+    {
+
+        $bucket                   = $bucket ? $bucket : config('aliyun.oss.bucket', 'zhijiayun-jiansuo');
+        try {
+            $object               = $object . '/' . date('Y') . '/' . date('m') . '/' . $file_name;
+            $result               = $this->ossClient->uploadFile($bucket, $object, $filePath);
+            $httpCode             = $result['info']['http_code'] ?? 0;
+            if ($httpCode == 200) {
+                return $result['info']['url'];
+            }
+            return false;
+        } catch (OssException $e) {
+            Log::error('oss/uploadFile', 'oss上传文件失败,错误:' . json_encode($e->getMessage()));
+            return false;
+        }
+    }
+
+    public function uploadDiyFile($filePath, $bucket = "", $object = "uploads/shop")
+    {
+        $bucket                   = $bucket ? $bucket : config('aliyun.oss.bucket', 'zhijiayun-jiansuo');
+        try {
+            //$object               = $object.'/'.date('Y').'/'.date('m').'/'.'123';
+            $result               = $this->ossClient->uploadFile($bucket, $object, $filePath);
+            $httpCode             = isset($result['info']['http_code'])  ? $result['info']['http_code'] : 0;
+            if ($httpCode == 200) {
+                return $result['info']['url'];
+            }
+            return false;
+        } catch (OssException $e) {
+            Log::error('oss/uploadFile', 'oss上传文件失败,错误:' . json_encode($e->getMessage()));
+            return false;
+        }
+    }
+
+    // 上传对象
+    public function putObject($object, $content, $bucket = "", $options = NULL)
+    {
+
+        $bucket                   = $bucket ? $bucket : config('aliyun.oss.bucket', 'zhijiayun-jiansuo');
+        try {
+            //$object               = $object.'/'.date('Y').'/'.date('m').'/'.'123';
+            $result               = $this->ossClient->putObject($bucket, $object, $content, $options);
+
+            $httpCode             = isset($result['info']['http_code'])  ? $result['info']['http_code'] : 0;
+            if ($httpCode == 200) {
+                return $result['info']['url'];
+            }
+            return false;
+        } catch (OssException $e) {
+            Log::error('oss/putObject', 'oss上传文件失败,错误:' . json_encode($e->getMessage()));
+            return false;
+        }
+    }
+}

+ 62 - 0
app/Servers/Aliyun/Sms.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+
+use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;
+use AlibabaCloud\Tea\Exception\TeaError;
+use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
+use AlibabaCloud\Tea\Utils\Utils;
+use App\Facades\Servers\Logs\Log;
+
+/**
+ * 验证码模型
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+class Sms extends Client
+{
+
+
+    /**
+     * 发送短信
+     * @param string $phone 手机号。国际/港澳台消息需加国际区号。支持向不同的手机号码发送短信,手机号码之间以半角逗号(,)分隔。上限为 1000 个手机号码。批量发送相对于单条发送,及时性稍有延迟。验证码类型的短信,建议单条发送。
+     * @param string $signName 签名名称。
+     * @param string $templateCode 模板ID。
+     * @param array  $param 模板参数。短信模板变量对应的实际值。支持传入多个参数, json格式,如 {"name":"张三","number":"1390000****"}
+     * 
+     */
+    public function sendSms(string $phone, string $signName, string $templateCode, array $param = [])
+    {
+        try {
+            // 变量参数转成json字符串
+            $param          = $param ? json_encode($param, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : '';
+            $request        = ['phoneNumbers' => $phone, 'signName' => $signName, 'templateCode' => $templateCode];
+            if ($param)    $request['templateParam'] = $param;
+            // 创建请求
+            $sendSmsRequest = new SendSmsRequest($request);
+            // 创建终端
+            $client         = $this->createClient();
+            // 复制代码运行请自行打印 API 的返回值
+            $response       = $client->sendSmsWithOptions($sendSmsRequest, new RuntimeOptions([]))->toMap();
+            // 获取参数 
+            $result         = $response['body'];
+            // 如果失败的话
+            if ($result['Code'] != 'OK')   return ['code' => $result['Code'], 'error' => $result['Message'], 'request_id' => $result['RequestId']];
+            // 返回成功信息
+            return          ['code' => $result['Code'], 'message' => $result['Message'], 'requestId' => $result['RequestId'], 'bizId' => $result['BizId']];
+        } catch (\Exception $error) {
+            // 返回错误信息
+            if (!($error instanceof TeaError)) {
+                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
+            }
+            // 错误信息
+            $errorMsg          = Utils::assertAsString($error->message);
+            // 日志记录
+            Log::error('aliyun_sms', $errorMsg);
+            // 返回错误信息
+            return          ['error' => $errorMsg];
+        }
+    }
+}

+ 223 - 0
app/Servers/Aliyun/TongyiQianwen.php

@@ -0,0 +1,223 @@
+<?php
+
+namespace App\Servers\Aliyun;
+
+use \Exception;
+
+/**
+ * 通义千问大模型API
+ * 提供简单易用的接口调用阿里云百炼大模型平台
+ * @author  唐远望
+ * @version 1.0
+ * @date    2025-12-22
+ */
+class TongyiQianwen
+{
+    private $apiKey;
+    private $baseUrl = 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions';
+    private $model = 'qwen-flash';
+    private $timeout = 30;
+
+    /**
+     * 构造函数
+     * 
+     * @param string $apiKey API密钥,如果不传则尝试从环境变量获取
+     * @throws Exception 当API密钥未设置时抛出异常
+     */
+    public function __construct($apiKey = null)
+    {
+        if ($apiKey) {
+            $this->apiKey = $apiKey;
+        } else {
+            $this->apiKey = config('aliyun.bailian_access_key', '');
+        }
+
+        if (empty($this->apiKey)) {
+            throw new Exception('API密钥未设置,请通过构造函数传入或设置DASHSCOPE_API_KEY环境变量');
+        }
+    }
+
+    /**
+     * 设置模型
+     * 
+     * @param string $model 模型名称
+     * @return $this
+     */
+    public function setModel($model)
+    {
+        $this->model = $model;
+        return $this;
+    }
+
+    /**
+     * 设置请求超时时间
+     * 
+     * @param int $timeout 超时时间(秒)
+     * @return $this
+     */
+    public function setTimeout($timeout)
+    {
+        $this->timeout = $timeout;
+        return $this;
+    }
+
+    /**
+     * 发送消息并获取回复
+     * 
+     * @param string|array $messages 消息内容,可以是字符串或消息数组
+     * @param string $systemPrompt 系统提示词
+     * @return array 包含响应数据和错误信息的数组
+     */
+    public function sendMessage($messages, $systemPrompt = "")
+    {
+        // 格式化消息
+        $formattedMessages = $this->formatMessages($messages, $systemPrompt);
+        // 准备请求数据
+        $data = [
+            "model" => $this->model,
+            "messages" => $formattedMessages
+        ];
+
+        // 设置请求头
+        $headers = [
+            'Authorization: Bearer ' . $this->apiKey,
+            'Content-Type: application/json'
+        ];
+
+        // 初始化cURL
+        $ch = curl_init();
+        curl_setopt_array($ch, [
+            CURLOPT_URL => $this->baseUrl,
+            CURLOPT_POST => true,
+            CURLOPT_POSTFIELDS => json_encode($data),
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_HTTPHEADER => $headers,
+            CURLOPT_TIMEOUT => $this->timeout,
+            CURLOPT_SSL_VERIFYPEER => true,
+        ]);
+
+        // 执行请求
+        $response = curl_exec($ch);
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        $error = curl_error($ch);
+        curl_close($ch);
+
+        // 处理响应
+        if ($error) {
+            return [
+                'success' => false,
+                'error' => 'CURL错误: ' . $error,
+                'data' => null
+            ];
+        }
+
+        $decodedResponse = json_decode($response, true);
+
+        if ($httpCode !== 200) {
+            return [
+                'success' => false,
+                'error' => 'API请求失败,HTTP状态码: ' . $httpCode,
+                'data' => $decodedResponse
+            ];
+        }
+
+        return [
+            'success' => true,
+            'error' => null,
+            'data' => $decodedResponse
+        ];
+    }
+
+    /**
+     * 格式化消息为API所需的格式
+     * 
+     * @param string|array $messages 消息内容
+     * @param string $systemPrompt 系统提示词
+     * @return array 格式化后的消息数组
+     */
+    private function formatMessages($messages, $systemPrompt)
+    {
+        $formattedMessages = [];
+
+        // 添加系统提示
+        if (!empty($systemPrompt)) {
+            $formattedMessages[] = [
+                "role" => "system",
+                "content" => $systemPrompt
+            ];
+        }
+
+        // 处理不同类型的消息输入
+        if (is_string($messages)) {
+            // 单条用户消息
+            $formattedMessages[] = [
+                "role" => "user",
+                "content" => $messages
+            ];
+        } elseif (is_array($messages)) {
+            // 多条消息
+            foreach ($messages as $message) {
+                if (is_string($message)) {
+                    $formattedMessages[] = [
+                        "role" => "user",
+                        "content" => $message
+                    ];
+                } elseif (is_array($message) && isset($message['role']) && isset($message['content'])) {
+                    $formattedMessages[] = $message;
+                }
+            }
+        }
+
+        return $formattedMessages;
+    }
+
+    /**
+     * 从响应中提取助手的回复内容
+     * 
+     * @param array $responseData sendMessage返回的数据
+     * @return string|null 助手的回复内容,如果不存在则返回null
+     */
+    public function getAssistantReply($responseData)
+    {
+        if (!$responseData['success'] || !isset($responseData['data']['choices'][0]['message']['content'])) {
+            return null;
+        }
+
+        return $responseData['data']['choices'][0]['message']['content'];
+    }
+
+    /**
+     * 从响应中提取助手的回复消息ID
+     * 
+     * @param array $responseData sendMessage返回的数据
+     * @return string|null 助手的回复内容,如果不存在则返回null
+     */
+    public function getAssistantReplyId($responseData)
+    {;
+        if (!$responseData['success'] || !isset($responseData['data']['id'])) {
+            return null;
+        }
+
+        return $responseData['data']['id'];
+    }
+
+    /**
+     * 简化调用 - 发送消息并直接获取回复文本
+     * 
+     * @param string $message 用户消息
+     * @param string $systemPrompt 系统提示词
+     * @return string 助手的回复内容,如果出错则返回错误信息
+     */
+    public function ask($message, $systemPrompt = "You are a helpful assistant.")
+    {
+        $response = $this->sendMessage($message, $systemPrompt);
+
+        if (!$response['success']) {
+            return "错误: " . $response['error'];
+        }
+
+        $reply = $this->getAssistantReply($response);
+
+        return $reply ?: "未能获取到有效回复";
+    }
+}

+ 4 - 0
composer.json

@@ -9,10 +9,14 @@
     "license": "MIT",
     "require": {
         "php": "^7.3|^8.0",
+        "alibabacloud/dysmsapi-20170525": "^3.1",
+        "alibabacloud/green-20220302": "^2.22",
+        "aliyuncs/oss-sdk-php": "^2.7",
         "firebase/php-jwt": "^6.10",
         "fruitcake/laravel-cors": "^2.0",
         "guzzlehttp/guzzle": "^7.0.1",
         "intervention/image": "^2.7",
+        "ixudra/curl": "^6.22",
         "laravel/framework": "^8.75",
         "laravel/sanctum": "^2.11",
         "laravel/tinker": "^2.5",

+ 783 - 1
composer.lock

@@ -4,8 +4,666 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "7546cf1ca341ac4a15fd76a2bcbcfd43",
+    "content-hash": "d22a6a344fa00e895d75354937539e54",
     "packages": [
+        {
+            "name": "adbario/php-dot-notation",
+            "version": "2.5.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/adbario/php-dot-notation.git",
+                "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae",
+                "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-json": "*",
+                "php": "^5.5 || ^7.0 || ^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5",
+                "squizlabs/php_codesniffer": "^3.6"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/helpers.php"
+                ],
+                "psr-4": {
+                    "Adbar\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Riku Särkinen",
+                    "email": "riku@adbar.io"
+                }
+            ],
+            "description": "PHP dot notation access to arrays",
+            "homepage": "https://github.com/adbario/php-dot-notation",
+            "keywords": [
+                "ArrayAccess",
+                "dotnotation"
+            ],
+            "support": {
+                "issues": "https://github.com/adbario/php-dot-notation/issues",
+                "source": "https://github.com/adbario/php-dot-notation/tree/2.5.0"
+            },
+            "time": "2022-10-14T20:31:46+00:00"
+        },
+        {
+            "name": "alibabacloud/credentials",
+            "version": "1.2.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/credentials-php.git",
+                "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/credentials-php/zipball/f6d1986e7b7be8da781d0b99f24c92d9860ba0c1",
+                "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "adbario/php-dot-notation": "^2.2",
+                "alibabacloud/tea": "^3.0",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-openssl": "*",
+                "ext-simplexml": "*",
+                "ext-xmlwriter": "*",
+                "guzzlehttp/guzzle": "^6.3|^7.0",
+                "php": ">=5.6"
+            },
+            "require-dev": {
+                "composer/composer": "^1.8",
+                "drupal/coder": "^8.3",
+                "ext-dom": "*",
+                "ext-pcre": "*",
+                "ext-sockets": "*",
+                "ext-spl": "*",
+                "mikey179/vfsstream": "^1.6",
+                "monolog/monolog": "^1.24",
+                "phpunit/phpunit": "^5.7|^6.6|^9.3",
+                "psr/cache": "^1.0",
+                "symfony/dotenv": "^3.4",
+                "symfony/var-dumper": "^3.4"
+            },
+            "suggest": {
+                "ext-sockets": "To use client-side monitoring"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Credentials\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com",
+                    "homepage": "http://www.alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Credentials for PHP",
+            "homepage": "https://www.alibabacloud.com/",
+            "keywords": [
+                "alibaba",
+                "alibabacloud",
+                "aliyun",
+                "client",
+                "cloud",
+                "credentials",
+                "library",
+                "sdk",
+                "tool"
+            ],
+            "support": {
+                "issues": "https://github.com/aliyun/credentials-php/issues",
+                "source": "https://github.com/aliyun/credentials-php"
+            },
+            "time": "2025-04-18T09:09:46+00:00"
+        },
+        {
+            "name": "alibabacloud/darabonba-openapi",
+            "version": "0.2.17",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/darabonba-openapi.git",
+                "reference": "051cd22db3da16ab7d0110feb3fc45dd0f999f92"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/darabonba-openapi/zipball/051cd22db3da16ab7d0110feb3fc45dd0f999f92",
+                "reference": "051cd22db3da16ab7d0110feb3fc45dd0f999f92",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/credentials": "^1.2.2",
+                "alibabacloud/gateway-spi": "^1",
+                "alibabacloud/openapi-util": "^0.1.10|^0.2.1",
+                "alibabacloud/tea-utils": "^0.2.21",
+                "alibabacloud/tea-xml": "^0.2",
+                "php": ">5.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Darabonba\\OpenApi\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud OpenApi Client",
+            "support": {
+                "issues": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/issues",
+                "source": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/tree/0.2.17"
+            },
+            "time": "2025-07-04T09:26:04+00:00"
+        },
+        {
+            "name": "alibabacloud/dysmsapi-20170525",
+            "version": "3.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/Dysmsapi-20170525.git",
+                "reference": "5a301a076b29449a488607cbfbb7f12b8cc50c1f"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/Dysmsapi-20170525/zipball/5a301a076b29449a488607cbfbb7f12b8cc50c1f",
+                "reference": "5a301a076b29449a488607cbfbb7f12b8cc50c1f",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/darabonba-openapi": "^0.2.13",
+                "alibabacloud/endpoint-util": "^0.1.0",
+                "alibabacloud/openapi-util": "^0.1.10|^0.2.1",
+                "alibabacloud/tea-utils": "^0.2.21",
+                "php": ">5.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\SDK\\Dysmsapi\\V20170525\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Dysmsapi (20170525) SDK Library for PHP",
+            "support": {
+                "source": "https://github.com/alibabacloud-sdk-php/Dysmsapi-20170525/tree/3.1.1"
+            },
+            "time": "2025-01-03T17:14:56+00:00"
+        },
+        {
+            "name": "alibabacloud/endpoint-util",
+            "version": "0.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/endpoint-util.git",
+                "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/endpoint-util/zipball/f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5",
+                "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.8.35|^5.4.3"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Endpoint\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Endpoint Library for PHP",
+            "support": {
+                "source": "https://github.com/alibabacloud-sdk-php/endpoint-util/tree/0.1.1"
+            },
+            "time": "2020-06-04T10:57:15+00:00"
+        },
+        {
+            "name": "alibabacloud/gateway-spi",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi.git",
+                "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/alibabacloud-gateway-spi/zipball/7440f77750c329d8ab252db1d1d967314ccd1fcb",
+                "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/credentials": "^1.1",
+                "php": ">5.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Darabonba\\GatewaySpi\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Gateway SPI Client",
+            "support": {
+                "source": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi/tree/1.0.0"
+            },
+            "time": "2022-07-14T05:31:35+00:00"
+        },
+        {
+            "name": "alibabacloud/green-20220302",
+            "version": "2.22.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/green-20220302.git",
+                "reference": "a17463007e8734ae92eb24be83f7d48248c71449"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/green-20220302/zipball/a17463007e8734ae92eb24be83f7d48248c71449",
+                "reference": "a17463007e8734ae92eb24be83f7d48248c71449",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/darabonba-openapi": "^0.2.15",
+                "alibabacloud/endpoint-util": "^0.1.0",
+                "alibabacloud/openapi-util": "^0.1.10|^0.2.1",
+                "alibabacloud/tea-utils": "^0.2.21",
+                "php": ">5.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\SDK\\Green\\V20220302\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Green (20220302) SDK Library for PHP",
+            "support": {
+                "source": "https://github.com/alibabacloud-sdk-php/green-20220302/tree/2.22.0"
+            },
+            "time": "2025-07-17T12:51:29+00:00"
+        },
+        {
+            "name": "alibabacloud/openapi-util",
+            "version": "0.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/openapi-util.git",
+                "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/openapi-util/zipball/f31f7bcd835e08ca24b6b8ba33637eb4eceb093a",
+                "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/tea": "^3.1",
+                "alibabacloud/tea-utils": "^0.2",
+                "lizhichao/one-sm": "^1.5",
+                "php": ">5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\OpenApiUtil\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud OpenApi Util",
+            "support": {
+                "issues": "https://github.com/alibabacloud-sdk-php/openapi-util/issues",
+                "source": "https://github.com/alibabacloud-sdk-php/openapi-util/tree/0.2.1"
+            },
+            "time": "2023-01-10T09:10:10+00:00"
+        },
+        {
+            "name": "alibabacloud/tea",
+            "version": "3.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/tea-php.git",
+                "reference": "1619cb96c158384f72b873e1f85de8b299c9c367"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/tea-php/zipball/1619cb96c158384f72b873e1f85de8b299c9c367",
+                "reference": "1619cb96c158384f72b873e1f85de8b299c9c367",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "adbario/php-dot-notation": "^2.4",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-openssl": "*",
+                "ext-simplexml": "*",
+                "ext-xmlwriter": "*",
+                "guzzlehttp/guzzle": "^6.3|^7.0",
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "*",
+                "symfony/dotenv": "^3.4",
+                "symfony/var-dumper": "^3.4"
+            },
+            "suggest": {
+                "ext-sockets": "To use client-side monitoring"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Tea\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com",
+                    "homepage": "http://www.alibabacloud.com"
+                }
+            ],
+            "description": "Client of Tea for PHP",
+            "homepage": "https://www.alibabacloud.com/",
+            "keywords": [
+                "alibabacloud",
+                "client",
+                "cloud",
+                "tea"
+            ],
+            "support": {
+                "issues": "https://github.com/aliyun/tea-php/issues",
+                "source": "https://github.com/aliyun/tea-php"
+            },
+            "time": "2023-05-16T06:43:41+00:00"
+        },
+        {
+            "name": "alibabacloud/tea-utils",
+            "version": "0.2.22",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/tea-utils.git",
+                "reference": "d885eadc9d185661ff9bd1d037333f62ba5daa99"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-utils/zipball/d885eadc9d185661ff9bd1d037333f62ba5daa99",
+                "reference": "d885eadc9d185661ff9bd1d037333f62ba5daa99",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/tea": "^3.1",
+                "php": ">5.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Tea\\Utils\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Tea Utils for PHP",
+            "support": {
+                "issues": "https://github.com/aliyun/tea-util/issues",
+                "source": "https://github.com/aliyun/tea-util"
+            },
+            "time": "2025-11-19T04:38:07+00:00"
+        },
+        {
+            "name": "alibabacloud/tea-xml",
+            "version": "0.2.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/alibabacloud-sdk-php/tea-xml.git",
+                "reference": "3e0c000bf536224eebbac913c371bef174c0a16a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-xml/zipball/3e0c000bf536224eebbac913c371bef174c0a16a",
+                "reference": "3e0c000bf536224eebbac913c371bef174c0a16a",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "*",
+                "symfony/var-dumper": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Tea\\XML\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Tea XML Library for PHP",
+            "support": {
+                "source": "https://github.com/alibabacloud-sdk-php/tea-xml/tree/0.2.4"
+            },
+            "time": "2022-08-02T04:12:58+00:00"
+        },
+        {
+            "name": "aliyuncs/oss-sdk-php",
+            "version": "v2.7.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
+                "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
+                "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.3"
+            },
+            "require-dev": {
+                "php-coveralls/php-coveralls": "*",
+                "phpunit/phpunit": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "OSS\\": "src/OSS"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Aliyuncs",
+                    "homepage": "http://www.aliyun.com"
+                }
+            ],
+            "description": "Aliyun OSS SDK for PHP",
+            "homepage": "http://www.aliyun.com/product/oss/",
+            "support": {
+                "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
+                "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.7.2"
+            },
+            "time": "2024-10-28T10:41:12+00:00"
+        },
         {
             "name": "asm89/stack-cors",
             "version": "v2.3.0",
@@ -1422,6 +2080,70 @@
             ],
             "time": "2022-05-21T17:30:32+00:00"
         },
+        {
+            "name": "ixudra/curl",
+            "version": "6.22.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/ixudra/curl.git",
+                "reference": "0b2cc89ed5eb91d617295e7e745f3acd3ab47180"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/ixudra/curl/zipball/0b2cc89ed5eb91d617295e7e745f3acd3ab47180",
+                "reference": "0b2cc89ed5eb91d617295e7e745f3acd3ab47180",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-curl": "*",
+                "illuminate/support": ">=4.0",
+                "php": ">=5.4.0"
+            },
+            "type": "library",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Ixudra\\Curl\\CurlServiceProvider"
+                    ],
+                    "aliases": {
+                        "Curl": "Ixudra\\Curl\\Facades\\Curl"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Ixudra\\Curl\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jan Oris",
+                    "email": "jan.oris@ixudra.be"
+                }
+            ],
+            "description": "Custom PHP Curl library for the Laravel framework - developed by Ixudra",
+            "homepage": "http://ixudra.be",
+            "keywords": [
+                "Ixudra",
+                "curl",
+                "laravel"
+            ],
+            "support": {
+                "issues": "https://github.com/ixudra/curl/issues",
+                "source": "https://github.com/ixudra/curl/tree/6.22.1"
+            },
+            "time": "2022-07-31T09:58:52+00:00"
+        },
         {
             "name": "laravel/framework",
             "version": "v8.83.29",
@@ -2174,6 +2896,66 @@
             ],
             "time": "2024-01-28T23:22:08+00:00"
         },
+        {
+            "name": "lizhichao/one-sm",
+            "version": "1.10",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/lizhichao/sm.git",
+                "reference": "687a012a44a5bfd4d9143a0234e1060543be455a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/lizhichao/sm/zipball/687a012a44a5bfd4d9143a0234e1060543be455a",
+                "reference": "687a012a44a5bfd4d9143a0234e1060543be455a",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.6"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "OneSm\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "tanszhe",
+                    "email": "1018595261@qq.com"
+                }
+            ],
+            "description": "国密sm3",
+            "keywords": [
+                "php",
+                "sm3"
+            ],
+            "support": {
+                "issues": "https://github.com/lizhichao/sm/issues",
+                "source": "https://github.com/lizhichao/sm/tree/1.10"
+            },
+            "funding": [
+                {
+                    "url": "https://www.vicsdf.com/img/w.jpg",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://www.vicsdf.com/img/z.jpg",
+                    "type": "custom"
+                }
+            ],
+            "time": "2021-05-26T06:19:22+00:00"
+        },
         {
             "name": "markbaker/complex",
             "version": "1.5.0",

+ 17 - 0
config/aliyun.php

@@ -0,0 +1,17 @@
+<?php
+
+return [
+    'bailian_access_key' => env('BAILIAN_ACCESS_KEY', 'sk-b313a29b033d46da9aff0a9b678c1e4e'), //阿里百炼秘钥
+    'accessKeyId'       => env('ALIYUN_ACCESS_KEY_ID', 'LTAI5tDwjfteBvivYN41r8sJ'),
+    'accessKeySecret'   => env('ALIYUN_ACCESS_KEY_SECRET', 'yowuOGi2nYYnrqGpO3qcz94C4brcPp'),
+    'oss'               => [
+        'accessKeyId'       => env('ALIYUN_OSS_ACCESS_KEY_ID', 'LTAI5tDwjfteBvivYN41r8sJ'),
+        'accessKeySecret'   => env('ALIYUN_OSS_ACCESS_KEY_SECRET', 'yowuOGi2nYYnrqGpO3qcz94C4brcPp'),
+        'endpoint'          => env('ALIYUN_OSS_ENDPOINT', 'oss-cn-shenzhen'), // 存储空间节点
+        'bucket'            => env('ALIYUN_OSS_BUCKET', 'zhijiayun-jiansuo'),       // 存储桶
+    ],
+    'sms'               => [
+        'accessKeyId'       => env('ALIYUN_SMS_ACCESS_KEY_ID', 'LTAI5tDwjfteBvivYN41r8sJ'),
+        'accessKeySecret'   => env('ALIYUN_SMS_ACCESS_KEY_SECRET', 'yowuOGi2nYYnrqGpO3qcz94C4brcPp'),
+    ],
+];

+ 6 - 1
routes/manager.php

@@ -227,4 +227,9 @@ Route::any('process/violation_store/delete', [App\Http\Controllers\Manager\Proce
 // 违规店铺违规处理-执行数据清洗
 Route::any('process/violation_store/data_cleaning', [App\Http\Controllers\Manager\Process\ViolationStore::class, 'data_cleaning']);
 // 违规店铺违规处理-导出Excel
-Route::any('process/violation_store/export_excel', [App\Http\Controllers\Manager\Process\ViolationStore::class, 'export_excel']);
+Route::any('process/violation_store/export_excel', [App\Http\Controllers\Manager\Process\ViolationStore::class, 'export_excel']);
+
+// 获取签名上传地址
+Route::any('upload/get_sign_url',[App\Http\Controllers\Manager\Upload::class,'get_sign_url']);
+// 普通图片上传
+Route::any('upload/uploadimg',[App\Http\Controllers\Manager\Upload::class,'uploadimg']);