123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /*
- * This file is part of the ZhMead/laravel-logger.
- *
- * (c) Mead <751066209@qql.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Jobs\Manage;
- use App\Repositories\Enums\Manage\AnalysisStatusEnum;
- use App\Repositories\Enums\Manage\DealStatusEnum;
- use App\Repositories\Models\Manage\Message;
- use App\Repositories\Models\Manage\PreMessage;
- use App\Repositories\Models\Manage\Task;
- use Carbon\Carbon;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class CancelMergeMessageJob implements ShouldQueue
- {
- use InteractsWithQueue;
- use Queueable;
- private $ID;
- /**
- * Create a new job instance.
- */
- public function __construct($ID)
- {
- $this->ID = $ID;
- }
- /**
- * 确定任务应该超时的时间
- *
- * @return \DateTime
- */
- public function retryUntil()
- {
- return Carbon::now()->addHours(8);
- }
- /**
- * Execute the job.
- */
- public function handle()
- {
- $this->merge();
- }
- /**
- * 导入数据
- * @return false|void
- */
- public function merge()
- {
- $model = Task::query()->find($this->ID);
- $model->status = AnalysisStatusEnum::CANCEL_MERGE_IN;
- $model->save();
- DB::beginTransaction();
- try {
- Log::error('*************合并数据中*****************');
- Message::query()->where('task_id', $this->ID)->where('similar_pid', '>', 0)->update([
- 'similar_pid' => 0,
- 'deal_admin_id' => 0,
- 'deal_status' => DealStatusEnum::WAIT,
- 'deal_idea' => NULL,
- 'deal_time' => NULL,
- 'task_id' => 0,
- ]);
- Message::query()->where('task_id', $this->ID)->where('similar_pid', '=', 0)->update([
- 'similar_pid' => 0,
- 'similar_nums' => 0,
- 'task_id' => 0,
- ]);
- DB::commit();
- $model->status = AnalysisStatusEnum::CHECK_DATA;
- } catch (\Exception $exception) {
- DB::rollBack();
- Log::error($exception);
- $model->status = AnalysisStatusEnum::MERGE_ERROR;
- $model->message = $exception;
- }
- $model->save();
- Log::error("-----------完成---------------");
- }
- }
|