From d69a1ca9bb466a9c48d07e24128f31c64e330892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Fri, 5 Sep 2025 11:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E4=B9=90=E4=BC=9A=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BA=A4.-=E8=81=94=E8=B0=83-?= =?UTF-8?q?=E7=9B=98-bug=E4=BF=AE=E6=94=B9=20=20=E7=9B=B2=E7=9B=92?= =?UTF-8?q?=E8=BD=AC=E7=9B=98=E7=A4=BC=E7=89=A9=E8=A1=A5=E5=8F=91=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=94=B9=E4=B8=BA30=E5=88=86=E9=92=9F=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminapi/controller/UploadFile.php | 21 ++++++++++++++++++- .../api/model/BlindBoxTurntableGift.php | 11 +++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/application/adminapi/controller/UploadFile.php b/application/adminapi/controller/UploadFile.php index ab64106..39e4aa8 100644 --- a/application/adminapi/controller/UploadFile.php +++ b/application/adminapi/controller/UploadFile.php @@ -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) { diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php index cda8823..b24b489 100644 --- a/application/api/model/BlindBoxTurntableGift.php +++ b/application/api/model/BlindBoxTurntableGift.php @@ -561,21 +561,22 @@ class BlindBoxTurntableGift extends Model if($gift_bag_detail['foreign_id'] == $ext['locking_condition']['selected_gift_id']){ //中奖 $pan_xlh_num = $pan_xlh_num+1; + $cache_key = 'selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id']; if($pan_xlh_num <= 1){ $add_end_time = $ext['locking_time']['tow_no_locking_time'] * 60; - Cache::set('selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id'],$add_end_time,$add_end_time); + Cache::set($cache_key,$add_end_time,$add_end_time); }else{ // $add_end_time = ($ext['locking_time']['tow_no_locking_time']-$ext['locking_time']['next_time']) * 60; - if(Cache::get('selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id'])){ - $erci_xlh_num = Cache::get('selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id']); + if(Cache::get($cache_key)){ + $erci_xlh_num = Cache::get($cache_key); $add_end_time = ($erci_xlh_num-$ext['locking_time']['next_time'] *60); - Cache::set('selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id'],$add_end_time,$add_end_time); + Cache::set($cache_key,$add_end_time,$add_end_time); }else{ $add_end_time = ($ext['locking_time']['tow_no_locking_time']-$ext['locking_time']['next_time']) * 60; } } if($add_end_time <= 30){ - Cache::set('selected_gift_id_'.$room_id.$gift_bag_detail['foreign_id'],30,30); + Cache::set($cache_key,30,30); $add_end_time = 30; } $end_time = time() + $add_end_time;