LimitBuyEndJob.php 863 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\Jobs;
  3. use app\common\events\goods\GoodsLimitBuyCloseEvent;
  4. use app\common\models\Goods;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. class LimitBuyEndJob implements ShouldQueue
  10. {
  11. use InteractsWithQueue, Queueable, SerializesModels;
  12. protected $limitBuy;
  13. /**
  14. * LimitBuyEndJob constructor.
  15. * @param $data
  16. */
  17. public function __construct($data = [])
  18. {
  19. $this->limitBuy = $data;
  20. }
  21. /**
  22. * @return bool
  23. */
  24. public function handle()
  25. {
  26. $goods = Goods::find($this->limitBuy['goods_id']);
  27. if(!$goods){
  28. return true;
  29. }
  30. //执行限时购结束事件
  31. event(new GoodsLimitBuyCloseEvent($goods));
  32. return true;
  33. }
  34. }