| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- use App\Jobs\Manager\Process\LowPriceGoodsJobs;
- use App\Jobs\Manager\Process\ViolationProductJobs;
- use App\Jobs\Manager\Process\ViolationCompanyJobs;
- use App\Models\Manager\External\Company as CompanyModel;
- use App\Jobs\Manager\Process\ScrapeDataProductJobs;
- /**
- * 定时清洗采集的商品数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- */
- class DailyTask extends Command
- {
- /**
- * 命令名称和签名
- *
- * @var string
- */
- protected $signature = 'task:daily';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '每天12点执行的定时任务';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- $this->info('开始执行每日任务...');
- try {
- Log::info('每日数据清洗任务执行中 - ' . now());
- $start_time = time() - 60 * 5; // 开始时间 5分钟之前
- $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'], 'page' => '1', 'limit' => '10000', 'start_time' => $start_time, 'end_time' => $end_time];
- //执行低价挂网商品数据清洗任务
- ScrapeDataProductJobs::dispatch($message_data);
- }
- $this->info('每日任务执行完成!');
- return Command::SUCCESS;
- } catch (\Exception $e) {
- Log::error('每日定时任务执行失败: ' . $e->getMessage());
- $this->error('任务执行失败: ' . $e->getMessage());
- return Command::FAILURE;
- }
- }
- }
|