LuckyBagJobs.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php namespace App\Jobs\Company\LiveLuckyBag;
  2. use App\Facades\Servers\Logs\Log;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Foundation\Bus\Dispatchable;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Queue\SerializesModels;
  8. class LuckyBagJobs implements ShouldQueue
  9. {
  10. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  11. /** 奖项列表 **/
  12. protected $winList;
  13. /**
  14. * 任务可尝试的次数
  15. *
  16. * @var int
  17. */
  18. public $tries = 3;
  19. /**
  20. * Create a new job instance.
  21. *
  22. * @return void
  23. */
  24. public function __construct($list)
  25. {
  26. $this->winList = $list;
  27. }
  28. /**
  29. * Execute the job.
  30. *
  31. * @return void
  32. */
  33. public function handle()
  34. {
  35. // 获取数据
  36. $winList = $this->winList;
  37. try {
  38. // 循环分派任务
  39. foreach ($winList as $item) {
  40. // 上锁
  41. LuckyBagRewardJobs::dispatch($item);
  42. }
  43. } catch (Throwable $th) {
  44. Log::info('job_error/live_Lucky_bag_jobs', $th->getMessage(), $winList);
  45. }
  46. }
  47. }