PointQueueJob.php 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Author: 芸众商城 www.yunzshop.com
  4. * Date: 2018/10/4
  5. * Time: 下午5:48
  6. */
  7. namespace app\Jobs;
  8. use app\common\models\finance\PointQueue;
  9. use Illuminate\Contracts\Queue\ShouldQueue;
  10. use Illuminate\Bus\Queueable;
  11. use Illuminate\Queue\SerializesModels;
  12. use Illuminate\Queue\InteractsWithQueue;
  13. class PointQueueJob implements ShouldQueue
  14. {
  15. use InteractsWithQueue, Queueable, SerializesModels;
  16. private $uniacid;
  17. public function __construct($uniacid)
  18. {
  19. \YunShop::app()->uniacid = $uniacid;
  20. $this->uniacid = $uniacid;
  21. }
  22. public function handle()
  23. {
  24. \YunShop::app()->uniacid = $this->uniacid;
  25. $queues = $this->getQueues();
  26. if ($queues->isEmpty()) {
  27. return;
  28. }
  29. foreach ($queues as $queue) {
  30. PointQueue::returnRun($queue);
  31. }
  32. }
  33. private function getQueues()
  34. {
  35. return PointQueue::select()
  36. ->where('status', PointQueue::STATUS_RUNING)
  37. ->get();
  38. }
  39. }