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 1; //查询低价商品清洗清洗情况 $action1 = $ExecuteLogModel->query()->where([['code', '=', 'LowPriceGoodsJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count(); if ($action1 < 1) return 2; //查询违规产品清洗清洗情况 $action2 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationProductJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count(); if ($action2 < 1) return 3; //查询违规门店清洗清洗情况 $action3 = $ExecuteLogModel->query()->where([['code', '=', 'ViolationStoreJobs'], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count(); if ($action3 < 1) return 4; // 查询数据 $result = $CompanyModel->query()->get()->toArray(); // 分配数据 if (!$result) return 5; 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 6; } }