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