| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- use App\Jobs\Manager\CollectData\Statistics\ProductSurveillanceJobs;
- use App\Models\Manager\External\Company as CompanyModel;
- class ProductSurveillance extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'task:product_surveillance_notice';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '每小时执行一次商品数据-监控采集清洗情况通知任务';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- try {
- Log::info('开始执行商品数据-监控采集清洗情况通知任务 - ' . now());
- $start_time = time() - 60 * 60; // 1小时前开始时间
- $end_time = time(); // 当前时间
- $CompanyModel = new CompanyModel();
- $company_list = $CompanyModel->select(['id', 'status'])->where('status', 0)->orderByDesc('cleaning_priority')->get()->toarray();
- foreach ($company_list as $company) {
- $message_data = ['company_id' => $company['id'], 'start_time' => $start_time, 'end_time' => $end_time];
- //执行低价挂网商品数据清洗任务
- ProductSurveillanceJobs::dispatch($message_data);
- }
- Log::info('商品数据-监控采集清洗情况通知执行完成!' . now());
- return Command::SUCCESS;
- } catch (\Exception $e) {
- Log::error('商品数据-监控采集清洗情况通知任务执行失败: ' . $e->getMessage());
- return Command::FAILURE;
- }
- }
- }
|