From 85ab8e79f8ec97f3d850aa4448fd611f337c5dc0 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 17 Jan 2026 16:24:02 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=87=AA=E5=8A=A8=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=202=E3=80=81=E9=93=BE=E6=8E=A5=E6=8A=93=E5=8F=96=E5=8E=BB?= =?UTF-8?q?=E9=87=8D=203=E3=80=81=E7=8A=B6=E6=80=81=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/UsedCarService.php | 17 ++++++++++++++++- app/process/Task.php | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/common/service/UsedCarService.php b/app/common/service/UsedCarService.php index 853b98a..89cc54d 100644 --- a/app/common/service/UsedCarService.php +++ b/app/common/service/UsedCarService.php @@ -53,13 +53,16 @@ class UsedCarService case 'index': $config['where']['role'] = 2; $config['where']['status'] = 1; - if (isset($p['status'])) { + if (isset($p['status']) && $p['status']=='archive') { + $config['where']['status'] = ['in', [2, 3]]; + }elseif (isset($p['status'])) { $config['where']['status'] = $p['status']; } if (isset($p['scene']) && $p['scene'] == 'self') { $config['where']['user_id'] = $request->user['id']; $config['where']['role'] = $request->user['role']; + unset( $config['where']['status']); } // 关键字 @@ -107,6 +110,18 @@ class UsedCarService $data['attachment'] = ''; } $data['user_id'] = $request->user['id']; + $user = User::where('id', $request->user['id'])->first(); + $data['role'] = $user['role']??1; + if(!empty($data['source_url'])){ + $used = UsedCar::where('source_url', $data['source_url']); + if ($data['role'] == 1) { + $used = $used->where('user_id', $data['user_id']); + } + $count = $used->count(); + if ($count) { + throw new BusinessException('该车源已收录'); + } + } $data['code'] = $this->getcode($request->user['id']); $data['mileage'] = str_replace(['K','M','k','m'], '', $data['mileage']); return $data; diff --git a/app/process/Task.php b/app/process/Task.php index 7a88f05..31f2e8d 100644 --- a/app/process/Task.php +++ b/app/process/Task.php @@ -26,6 +26,16 @@ class Task Log::info('send follow end',[time()]); }); + // 每三个小时自动归档 + new Crontab('0 0 */3 * * *', function(){ + + Db::table('used_car') + ->where('status', 1) + ->where('created_at', '<', time() - (86400*15)) + ->update(['status' => 3]); + + }); + } } \ No newline at end of file