|
@@ -0,0 +1,57 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+namespace App\Http\Controllers\Manager\Process;
|
|
|
|
|
+
|
|
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
|
|
+use App\Models\Manager\External\Company as CompanyModel;
|
|
|
|
|
+use App\Jobs\Manager\Process\SubNoticeJobs;
|
|
|
|
|
+use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
|
|
|
|
|
+use App\Models\Manager\Process\SubNoticeLog as SubNoticeLogModel;
|
|
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 违规处理订阅推送
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2026-03-30
|
|
|
|
|
+ */
|
|
|
|
|
+class SubNotice extends Controller
|
|
|
|
|
+{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 执行通知推送任务
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2025-12-11
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ public function push_notice(CompanyModel $CompanyModel, ExecuteLogModel $ExecuteLogModel, SubNoticeLogModel $SubNoticeLogModel)
|
|
|
|
|
+ {
|
|
|
|
|
+ $todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
|
|
+ $todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
|
|
+ //查询今日是否存在通知推送记录
|
|
|
|
|
+ $sub_notice_count = $SubNoticeLogModel->query()->where([['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($sub_notice_count > 0) return true;
|
|
|
|
|
+ //查询低价商品清洗清洗情况
|
|
|
|
|
+ $action1 = $ExecuteLogModel->query()->where([['code', '=', 'LowPriceGoodsJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action1 < 1) return true;
|
|
|
|
|
+ //查询违规产品清洗清洗情况
|
|
|
|
|
+ $action2 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationProductJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action2 < 1) return true;
|
|
|
|
|
+ //查询违规门店清洗清洗情况
|
|
|
|
|
+ $action3 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationStoreJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action3 < 1) return true;
|
|
|
|
|
+ // 查询数据
|
|
|
|
|
+ $result = $CompanyModel->query()->toarray();
|
|
|
|
|
+ // 分配数据
|
|
|
|
|
+ if (!$result) return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
|
|
|
|
|
+ foreach ($result as $key => $item) {
|
|
|
|
|
+ $message_data = ['company_id' => $item['id']];
|
|
|
|
|
+ SubNoticeJobs::dispatch($message_data);
|
|
|
|
|
+ // SubNoticeJobs::dispatchSync($message_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 增加通知推送记录
|
|
|
|
|
+ $SubNoticeLogModel->query()->insert(['insert_time' => time()]);
|
|
|
|
|
+ // 告知结果
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '执行成功']);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|