1、自动归档
2、链接抓取去重 3、状态筛选
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user