Forráskód Böngészése

[智价云] 增加订阅去重信息校验

tangyuanwang 3 hete
szülő
commit
665ac938f8
1 módosított fájl, 7 hozzáadás és 0 törlés
  1. 7 0
      app/Jobs/Manager/Process/SubNoticeJobs.php

+ 7 - 0
app/Jobs/Manager/Process/SubNoticeJobs.php

@@ -68,6 +68,8 @@ class SubNoticeJobs implements ShouldQueue
             $action_two = $this->send_violation_product($company_id, $statistics_start_time, $statistics_end_time);
             $action_three = $this->send_violation_store($company_id, $statistics_start_time, $statistics_end_time);
             if (empty($this->user_data)) return true;
+            $start_time = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
+            $end_time = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
             $SubNoticeLogModel = new SubNoticeLogModel();
             if ($action_one && $action_two && $action_three) {
                 foreach ($this->user_data as $key => $value) {
@@ -113,6 +115,11 @@ class SubNoticeJobs implements ShouldQueue
                         'statistics_start_time' => $statistics_start_time,
                         'statistics_end_time' => $statistics_end_time,
                     ];
+                    // 校验今日是否已推送记录,防止重复添加
+                    $exists = $SubNoticeLogModel->where([['insert_time','>=',$start_time], ['insert_time','<=',$end_time],['company_id','=',$company_id],['employee_id','=',$user_id]])->exists();
+                    if ($exists) {
+                        continue;
+                    }
                     // 增加就订阅日志
                     $insert_data = [
                         'company_id' => $company_id,