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;