1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Jobs\Info;
- use App\Repositories\Models\Info\Complaint;
- use App\Repositories\Models\Info\ComplaintMessage;
- 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 ComplaintMessageJob implements ShouldQueue
- {
- use InteractsWithQueue;
- use Queueable;
- public $tries = 1;
- public $timeout = 1440;
- private $complaintId;
- /**
- * Create a new job instance.
- */
- public function __construct($complaintId)
- {
- $this->$complaintId = $complaintId;
- }
- /**
- * 确定任务应该超时的时间
- *
- * @return \DateTime
- */
- public function retryUntil()
- {
- return Carbon::now()->addHours(24);
- }
- /**
- * Execute the job.
- */
- public function handle()
- {
- $this->analysis();
- }
- /**
- *
- * @return false|void
- */
- public function analysis()
- {
- $model = Complaint::query()->where('id', $this->complaintId)->first();
- DB::beginTransaction();
- try {
- Log::error('*************创建数据*****************');
- ComplaintMessage::query()->create([
- 'complaint_id' => $model->id,
- 'complaint_status' => $model->deal_status,
- 'deal_admin_id' => $model->deal_admin_id,
- ]);
- DB::commit();
- } catch (\Exception $exception) {
- DB::rollBack();
- Log::error("
- **********消息创建失效*****************
- exception: {$exception->getMessage()}
- ");
- }
- Log::error("-----------完成---------------");
- }
- }
|