作者 zhl

修改GEO查询任务条件

@@ -350,11 +350,21 @@ class GeoQuestionRes extends Command @@ -350,11 +350,21 @@ class GeoQuestionRes extends Command
350 $lock_key = 'geo_task_generation_lock'; 350 $lock_key = 'geo_task_generation_lock';
351 $lock_ttl = 60; // 锁时间大于当前 锁功能执行时间 351 $lock_ttl = 60; // 锁时间大于当前 锁功能执行时间
352 // 尝试获取锁,非阻塞方式 352 // 尝试获取锁,非阻塞方式
353 - $lock = Redis::set($lock_key, 1, 'EX', $lock_ttl, 'NX');  
354 - if (empty($lock)){ 353 +// $lock = Redis::set($lock_key, 1, 'EX', $lock_ttl, 'NX');
  354 + $lock = Redis::get($lock_key);
  355 + if ($lock)
355 return $task_id; 356 return $task_id;
356 - }  
357 - $project_ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)->where('next_time', '<=', date('Y-m-d'))->pluck('project_id')->unique()->values()->toArray(); 357 + Redis::setex($lock_key, $lock_ttl, 1);
  358 +
  359 + $project_ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)
  360 + ->where(function ($query){
  361 + $query->where('next_time', '<=', date('Y-m-d'))
  362 + ->orWhereNull('next_time');
  363 + })
  364 + ->pluck('project_id')
  365 + ->unique()
  366 + ->values()
  367 + ->toArray();
358 if(FALSE == empty($project_ids)){ 368 if(FALSE == empty($project_ids)){
359 $ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN) 369 $ids = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)
360 ->whereIn('project_id', $project_ids) 370 ->whereIn('project_id', $project_ids)