|
|
@@ -5,12 +5,11 @@ 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;
|
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
use App\Jobs\Manager\Process\SendNoticeJobs;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
+use App\Models\Manager\Personnel\NoticeConfig as NoticeConfigModel;
|
|
|
|
|
|
/**
|
|
|
* 违规处理订阅推送
|
|
|
@@ -27,26 +26,25 @@ class SubNotice extends Controller
|
|
|
* @date 2025-12-11
|
|
|
*
|
|
|
*/
|
|
|
- public function push_notice(CompanyModel $CompanyModel, ExecuteLogModel $ExecuteLogModel, SubNoticeLogModel $SubNoticeLogModel)
|
|
|
+ public function push_notice(CompanyModel $CompanyModel, SubNoticeLogModel $SubNoticeLogModel, NoticeConfigModel $NoticeConfigModel)
|
|
|
{
|
|
|
$todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
$todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
// 查询数据
|
|
|
$result = $CompanyModel->query()->get()->toArray();
|
|
|
// 分配数据
|
|
|
- if (!$result) return 5;
|
|
|
+ if (!$result) return 1;
|
|
|
$key_index = 0;
|
|
|
foreach ($result as $key => $item) {
|
|
|
+ //获取公司配置
|
|
|
+ $company_push_time = $NoticeConfigModel->query()->where('company_id', $item['id'])->value('push_time');
|
|
|
+ if (empty($company_push_time)) continue;
|
|
|
+ $company_push_time_string = date('Y-m-d', time()) . ' ' . $company_push_time . ':00';
|
|
|
+ //如果当前时间在公司配置时间前5个小时,则开始继续执行
|
|
|
+ $company_push_time_timestamp = strtotime($company_push_time_string);
|
|
|
+ if (time() < $company_push_time_timestamp - 3600*5) continue;
|
|
|
+
|
|
|
$second = 60 * $key_index; // 每个商户延迟 60 秒
|
|
|
- //查询低价商品清洗清洗情况
|
|
|
- $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']];
|
|
|
|
|
|
@@ -61,7 +59,7 @@ class SubNotice extends Controller
|
|
|
$sub_noticeJobs_data_info = Cache::get($key_name);
|
|
|
if ($sub_noticeJobs_data_info) continue;
|
|
|
//创建缓存
|
|
|
- Cache::put($key_name,'1', 86400); // 每个商户每天只统计执行一次
|
|
|
+ Cache::put($key_name, '1', 86400); // 每个商户每天只统计执行一次
|
|
|
//执行统计任务
|
|
|
SubNoticeJobs::dispatch($message_data)->delay($second);
|
|
|
// SubNoticeJobs::dispatchSync($message_data)->delay($second);;
|
|
|
@@ -69,6 +67,6 @@ class SubNotice extends Controller
|
|
|
$key_index++;
|
|
|
}
|
|
|
// 告知结果
|
|
|
- return 6;
|
|
|
+ return 2;
|
|
|
}
|
|
|
}
|