Pārlūkot izejas kodu

[智价云] 统计更新

public 10 stundas atpakaļ
vecāks
revīzija
8cff8675de

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

@@ -62,14 +62,14 @@ class SubNotice extends Controller
             // 准备数据
             $message_data = ['company_id' => $item['id']];
             //执行发送通知任务
-            SendNoticeJobs::dispatch($message_data);
+            // SendNoticeJobs::dispatch($message_data);
             // SendNoticeJobs::dispatchSync($message_data);
             //如果今日存在通知推送记录,则跳过统计
             $sub_notice_count = $SubNoticeLogModel->query()->where([['company_id', '=', $item['id']],['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
             if ($sub_notice_count > 0) continue;
             
-            SubNoticeJobs::dispatch($message_data);
-            // SubNoticeJobs::dispatchSync($message_data);
+            // SubNoticeJobs::dispatch($message_data);
+            SubNoticeJobs::dispatchSync($message_data);
         }
         // 告知结果
         return 6;

+ 9 - 1
app/Jobs/Manager/Process/SubNoticeJobs.php

@@ -51,7 +51,7 @@ class SubNoticeJobs implements ShouldQueue
     public function handle()
     {
         try {
-            $notice_config_data = $this->get_statistics_time_rule($this->message_data['company_id']);
+            $notice_config_data = $this->get_statistics_time_rule(1);
             if ($notice_config_data['statistics_start_time'] == '' || $notice_config_data['statistics_end_time'] == '' || $notice_config_data['statistics_day'] == 0) {
                 //记录日志
                 // Log::info('job_info', '订阅未设置,不进行推送', ['data' => $this->message_data, 'notice_config_data' => $notice_config_data]);
@@ -80,6 +80,8 @@ class SubNoticeJobs implements ShouldQueue
                     $number1 = isset($this->user_data[$key]['lowprice_product_logids']) ? count($this->user_data[$key]['lowprice_product_logids']) : 0;
                     $number2 = isset($this->user_data[$key]['violation_product_logids']) ? count($this->user_data[$key]['violation_product_logids']) : 0;
                     $number3 = isset($this->user_data[$key]['violation_store_logids']) ? count($this->user_data[$key]['violation_store_logids']) : 0;
+
+                    dd($number1);
                     //统计总条数
                     $totle_number = $number1 + $number2 + $number3;
                     $sms_config_data =[];
@@ -130,6 +132,7 @@ class SubNoticeJobs implements ShouldQueue
                 }
             }
         } catch (\Exception $e) {
+            print_r($e->getMessage());exit;
             Log::info('job_error', '订阅短信通知推送队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }
     }
@@ -249,6 +252,7 @@ class SubNoticeJobs implements ShouldQueue
         $todayStart = strtotime($statistics_start_time); // 统计开始时间
         $todayEnd = strtotime($statistics_end_time); // 统计结束时间
         $lowprice_ids = $LowPriceGoodsModel->where([['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd], ['company_id', '=', $company_id]])->pluck('id')->toArray();
+        dd(count($lowprice_ids));
         if (empty($lowprice_ids)) return true;
         //获取开启了通知服务的用户
         $usert_list = $LowPriceGoodsMemberModel
@@ -256,6 +260,7 @@ class SubNoticeJobs implements ShouldQueue
             ->join('personnel_employee', 'process_lowprice_product_member.employee_id', '=', 'personnel_employee.id')
             ->where('personnel_employee.open_notice', 0)
             ->where('personnel_employee.company_id', $company_id)
+            ->group(['lowprice_product_logid'])
             ->select(['process_lowprice_product_member.*', 'personnel_employee.mobile', 'personnel_employee.email'])
             ->get()->toArray();
         if (empty($usert_list)) return true;
@@ -271,6 +276,7 @@ class SubNoticeJobs implements ShouldQueue
                 $this->user_data[$user_id]['lowprice_product_logids'][] = $value['lowprice_product_logid'];
             }
         }
+        
         return true;
     }
 
@@ -295,6 +301,7 @@ class SubNoticeJobs implements ShouldQueue
             ->join('personnel_employee', 'process_violation_product_member.employee_id', '=', 'personnel_employee.id')
             ->where('personnel_employee.open_notice', 0)
             ->where('personnel_employee.company_id', $company_id)
+            ->group(['violation_product_logid'])
             ->select(['process_violation_product_member.*', 'personnel_employee.mobile', 'personnel_employee.email'])
             ->get()->toArray();
         if (empty($usert_list)) return true;
@@ -334,6 +341,7 @@ class SubNoticeJobs implements ShouldQueue
             ->join('personnel_employee', 'process_violation_store_member.employee_id', '=', 'personnel_employee.id')
             ->where('personnel_employee.open_notice', 0)
             ->where('personnel_employee.company_id', $company_id)
+            ->group(['violation_store_logid'])
             ->select(['process_lowprice_product_member.*', 'personnel_employee.mobile', 'personnel_employee.email'])
             ->get()->toArray();
         if (empty($usert_list)) return true;