作者 zhl

GEO按照项目频率获取结果

@@ -43,6 +43,12 @@ class GeoQuestionRes extends Command @@ -43,6 +43,12 @@ class GeoQuestionRes extends Command
43 */ 43 */
44 public function handle() 44 public function handle()
45 { 45 {
  46 + $project_id = GeoQuestion::where(['status' => GeoQuestion::STATUS_OPEN])->where('next_time', '<=', date('Y-m-d', strtotime('+2 day')))->value('project_id');
  47 + $ids = GeoQuestion::where(['project_id' => $project_id, 'status' => GeoQuestion::STATUS_OPEN])->where('current_time', '<>', date('Y-m-d', strtotime('-1 day')))->pluck('id');
  48 + foreach ($ids as $id) {
  49 + dd($id);
  50 + }
  51 + dd(1);
46 while (true) { 52 while (true) {
47 $task_id = $this->getTaskId(); 53 $task_id = $this->getTaskId();
48 if (empty($task_id)) { 54 if (empty($task_id)) {
@@ -337,12 +343,13 @@ class GeoQuestionRes extends Command @@ -337,12 +343,13 @@ class GeoQuestionRes extends Command
337 $key = 'geo_task_list'; 343 $key = 'geo_task_list';
338 $task_id = Redis::rpop($key); 344 $task_id = Redis::rpop($key);
339 if(empty($task_id)){ 345 if(empty($task_id)){
340 - $questionModel = new GeoQuestion();  
341 - $ids = $questionModel->selectField(['status'=>$questionModel::STATUS_OPEN,'next_time'=>['<=',date('Y-m-d')]],'id');  
342 - if(!empty($ids)){  
343 - foreach ($ids as $id) {  
344 - Redis::lpush($key, $id);  
345 - } 346 + # TODO 按照项目进行获取, 一个项目当天需要将所有跑完
  347 + $project_id = GeoQuestion::where('status', GeoQuestion::STATUS_OPEN)->where('next_time', '<=', date('Y-m-d'))->value('project_id');
  348 + if (empty($project_id))
  349 + return $task_id;
  350 + $ids = GeoQuestion::where(['project_id' => $project_id, 'status' => GeoQuestion::STATUS_OPEN])->where('current_time', '<>', date('Y-m-d'))->pluck('id');
  351 + foreach ($ids as $id) {
  352 + Redis::lpush($key, $id);
346 } 353 }
347 $task_id = Redis::rpop($key); 354 $task_id = Redis::rpop($key);
348 } 355 }