|
@@ -30,44 +30,30 @@ class SubNotice extends Controller
|
|
|
{
|
|
{
|
|
|
$todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
$todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
$todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
$todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
- //查询低价商品清洗清洗情况
|
|
|
|
|
- $action1 = $ExecuteLogModel->query()->where([['code', '=', 'LowPriceGoodsJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
- if ($action1 < 1) return 1;
|
|
|
|
|
- //查询违规产品清洗清洗情况
|
|
|
|
|
- $action2 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationProductJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
- if ($action2 < 1) return 1;
|
|
|
|
|
- //查询违规门店清洗清洗情况
|
|
|
|
|
- $action3 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationStoreJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
- if ($action3 < 1) return 3;
|
|
|
|
|
- // 检查队列是否全部执行完毕
|
|
|
|
|
- $jobClasses = [
|
|
|
|
|
- 'LowPriceGoodsDataJobs',
|
|
|
|
|
- 'LowPriceGoodsJobs',
|
|
|
|
|
- 'ViolationProductDataJobs',
|
|
|
|
|
- 'ViolationProductJobs',
|
|
|
|
|
- 'ViolationStoreDataJobs',
|
|
|
|
|
- 'ViolationStoreJobs',
|
|
|
|
|
- ];
|
|
|
|
|
- $pendingJobs = DB::table('jobs')->where(function ($query) use ($jobClasses) {
|
|
|
|
|
- foreach ($jobClasses as $class) {
|
|
|
|
|
- $query->orWhere('payload', 'like', '%' . $class . '%');
|
|
|
|
|
- }
|
|
|
|
|
- })->count();
|
|
|
|
|
- if ($pendingJobs > 0) return 4;
|
|
|
|
|
// 查询数据
|
|
// 查询数据
|
|
|
$result = $CompanyModel->query()->get()->toArray();
|
|
$result = $CompanyModel->query()->get()->toArray();
|
|
|
// 分配数据
|
|
// 分配数据
|
|
|
if (!$result) return 5;
|
|
if (!$result) return 5;
|
|
|
foreach ($result as $key => $item) {
|
|
foreach ($result as $key => $item) {
|
|
|
|
|
+
|
|
|
|
|
+ //查询低价商品清洗清洗情况
|
|
|
|
|
+ $action1 = $ExecuteLogModel->query()->where([['code', '=', 'LowPriceGoodsJobs'],['company_id', '=', $item['id']], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action1 < 1) continue;
|
|
|
|
|
+ //查询违规产品清洗清洗情况
|
|
|
|
|
+ $action2 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationProductJobs'],['company_id', '=', $item['id']], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action2 < 1) continue;
|
|
|
|
|
+ //查询违规门店清洗清洗情况
|
|
|
|
|
+ $action3 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationStoreJobs'],['company_id', '=', $item['id']], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
+ if ($action3 < 1) continue;
|
|
|
// 准备数据
|
|
// 准备数据
|
|
|
$message_data = ['company_id' => $item['id']];
|
|
$message_data = ['company_id' => $item['id']];
|
|
|
//执行发送通知任务
|
|
//执行发送通知任务
|
|
|
SendNoticeJobs::dispatch($message_data);
|
|
SendNoticeJobs::dispatch($message_data);
|
|
|
// SendNoticeJobs::dispatchSync($message_data);
|
|
// SendNoticeJobs::dispatchSync($message_data);
|
|
|
//如果今日存在通知推送记录,则跳过统计
|
|
//如果今日存在通知推送记录,则跳过统计
|
|
|
- $sub_notice_count = $SubNoticeLogModel->query()->where([['company_id', '=', $item['id']],['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
|
|
|
|
+ $sub_notice_count = $SubNoticeLogModel->query()->where([['company_id', '=', $item['id']], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
|
|
|
if ($sub_notice_count > 0) continue;
|
|
if ($sub_notice_count > 0) continue;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
SubNoticeJobs::dispatch($message_data);
|
|
SubNoticeJobs::dispatch($message_data);
|
|
|
// SubNoticeJobs::dispatchSync($message_data);
|
|
// SubNoticeJobs::dispatchSync($message_data);
|
|
|
}
|
|
}
|