diff --git a/app/Admin/Controllers/WangEditoController.php b/app/Admin/Controllers/WangEditoController.php index 07aa2f47..2eeea105 100644 --- a/app/Admin/Controllers/WangEditoController.php +++ b/app/Admin/Controllers/WangEditoController.php @@ -17,23 +17,16 @@ class WangEditoController extends Controller $dir = $request->get('dir', 'wang-editor'); $disk = $this->disk(); - $newName = $this->generateNewName($file); - - $disk->putFileAs($dir, $file, $newName); + $path = $disk->putFile($dir, $file); return [ 'errno' => 0, 'data' => [ - 'url' => $disk->url("{$dir}/$newName") + 'url' => $disk->url($path) ] ]; } - protected function generateNewName(UploadedFile $file): string - { - return uniqid(md5($file->getClientOriginalName())).'.'.$file->getClientOriginalExtension(); - } - /** * @return Filesystem|FilesystemAdapter */ diff --git a/app/Services/DistributeService.php b/app/Services/DistributeService.php index 923c6311..a0fe4228 100644 --- a/app/Services/DistributeService.php +++ b/app/Services/DistributeService.php @@ -49,7 +49,8 @@ class DistributeService $level_up = $item; } } - if ($level_up && $level_up->sort < $user_agent->sort) { + // 如果当前等级, 比升级之后的要高, 则不升级 + if ($level_up && (!$user_agent || $level_up->sort < $user_agent->sort)) { $user->update([ 'agent_id' => $level_up->id, ]);