|
...
|
...
|
@@ -350,16 +350,26 @@ class GeoQuestionRes extends Command |
|
|
|
$lock_key = 'geo_task_generation_lock';
|
|
|
|
$lock_ttl = 60; // 锁时间大于当前 锁功能执行时间
|
|
|
|
// 尝试获取锁,非阻塞方式
|
|
|
|
$lock = Redis::set($lock_key, 1, 'EX', $lock_ttl, 'NX');
|
|
|
|
if (empty($lock)){
|
|
|
|
// $lock = Redis::set($lock_key, 1, 'EX', $lock_ttl, 'NX');
|
|
|
|
$lock = Redis::get($lock_key);
|
|
|
|
if ($lock)
|
|
|
|
return $task_id;
|
|
|
|
}
|
|
|
|
$project_ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)->where('next_time', '<=', date('Y-m-d'))->pluck('project_id')->unique()->values()->toArray();
|
|
|
|
Redis::setex($lock_key, $lock_ttl, 1);
|
|
|
|
|
|
|
|
$project_ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)
|
|
|
|
->where(function ($query){
|
|
|
|
$query->where('next_time', '<=', date('Y-m-d'))
|
|
|
|
->orWhereNull('next_time');
|
|
|
|
})
|
|
|
|
->pluck('project_id')
|
|
|
|
->unique()
|
|
|
|
->values()
|
|
|
|
->toArray();
|
|
|
|
if(FALSE == empty($project_ids)){
|
|
|
|
$ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)
|
|
|
|
->whereIn('project_id', $project_ids)
|
|
|
|
->where(function ($query){
|
|
|
|
$query->where('next_time', '<=', date('Y-m-d'))
|
|
|
|
$query->where('current_time', '<>', date('Y-m-d'))
|
|
|
|
->orWhereNull('next_time');
|
|
|
|
})
|
|
|
|
->orderBy('next_time', 'asc')
|
...
|
...
|
|