Browse Source

[智价云] 统计推送更新

public 1 ngày trước cách đây
mục cha
commit
9592b84993

+ 4 - 4
app/Http/Controllers/Manager/Process/SubNotice.php

@@ -52,11 +52,11 @@ class SubNotice extends Controller
             $sub_notice_count = $SubNoticeLogModel->query()->where([['company_id', '=', $item['id']], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
             if ($sub_notice_count > 0) {
                 //执行发送通知任务
-                // SendNoticeJobs::dispatch($message_data);
-                SendNoticeJobs::dispatchSync($message_data);
+                SendNoticeJobs::dispatch($message_data);
+                // SendNoticeJobs::dispatchSync($message_data);
             } else {
-                // SubNoticeJobs::dispatch($message_data);
-                SubNoticeJobs::dispatchSync($message_data);
+                SubNoticeJobs::dispatch($message_data);
+                // SubNoticeJobs::dispatchSync($message_data);
             }
         }
         // 告知结果

+ 10 - 6
app/Jobs/Manager/Process/SendNoticeJobs.php

@@ -49,14 +49,18 @@ class SendNoticeJobs implements ShouldQueue
         try {
             $company_id = $this->message_data['company_id'];
             $SubNoticeLogModel = new SubNoticeLogModel();
-            //查询需要发送的通知,push_time等于当前时间,或者大于当前时间5分钟的通知
             $now_time = time();
+            $start_time = $now_time - 300; // 5分钟前
+            $delay_time = $now_time - 0;   // 0分钟前
+
             $sub_notice_list = $SubNoticeLogModel->where('company_id', $company_id)
-            ->where(function($query) use ($now_time) {
-                $query->where('push_time', '=', $now_time)
-                    ->orWhere('push_time', '>', $now_time - 300);
-            })
-            ->get()->toarray();
+                ->where('push_time', '=', $now_time)  // 正好当前时间
+                ->orWhere(function($query) use ($delay_time, $start_time) {
+                    $query->where('push_time', '<', $delay_time)
+                        ->where('push_time', '>=', $start_time);  // 只查询0-5分钟内的
+                })
+                ->get()
+                ->toarray();
             if (empty($sub_notice_list)) return true;
             //执行发送站内信
             $status1 = $this->send_internal_msg($sub_notice_list);