巡乐会抽奖接口提交.-联调-盘-bug修改 盲盒转盘礼物补发时间改为30分钟内

This commit is contained in:
2025-09-05 11:13:19 +08:00
parent 612f48402d
commit d69a1ca9bb
2 changed files with 26 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
use app\admin\model\AdminLog;
use app\common\controller\Upload;
use Overtrue\Pinyin\Pinyin;
use think\Request;
/**
@@ -32,7 +33,25 @@ class UploadFile extends Upload
try {
// 获取临时路径和原始文件名
$filePath = $file->getRealPath();
$objectName = $file->getInfo('name');
$originalName = $file->getInfo('name');
// 提取文件扩展名
$extension = pathinfo($originalName, PATHINFO_EXTENSION);
// 处理文件名(中文转拼音)
$fileName = $originalName;
if (preg_match('/[\x{4e00}-\x{9fa5}]+/u', $fileName)) {
$pinyin = new Pinyin();
$fileName = $pinyin->permalink($fileName, ''); // 转换为无分隔符的拼音
}
// 移除扩展名(如果有的话)
$fileName = pathinfo($fileName, PATHINFO_FILENAME);
// 添加唯一标识符(时间戳+随机数)
$uniqueId = time() . mt_rand(1000, 9999);
$objectName = $fileName . '_' . $uniqueId . '.' . $extension;
// 调用父类方法上传到 OSS
$result = $this->uploadFile($objectName, $filePath);
if (!$result) {