ExecutePostBillHandler.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Jobs;
  3. use App\Feature;
  4. use App\Order;
  5. use App\Store;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Database\Eloquent\Collection;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. /**
  12. * @Deprecated 结算账单计费
  13. */
  14. class ExecutePostBillHandler implements ShouldQueue
  15. {
  16. use Dispatchable, InteractsWithQueue, Queueable;
  17. /**
  18. * @var \Closure $closure
  19. */
  20. protected $closure;
  21. /**
  22. * @var Collection $collection
  23. */
  24. protected $collection;
  25. /**
  26. * @var string $modelClass
  27. */
  28. protected $modelClass;
  29. /**
  30. * Create a new job instance.
  31. *
  32. * @return void
  33. */
  34. public function __construct(\Closure $closure, Collection $collection, string $modelClass)
  35. {
  36. $this->closure = $closure;
  37. $this->connection = $collection;
  38. $this->modelClass = $modelClass;
  39. }
  40. /**
  41. * Execute the job.
  42. *
  43. * @return void
  44. */
  45. public function handle()
  46. {
  47. $closure = $this->closure;
  48. switch ($this->modelClass){
  49. case Store::class:
  50. foreach ($this->collection as $detail){
  51. $closure(Feature::MAPPING["store"],$detail->store,$detail);
  52. }
  53. break;
  54. case Order::class:
  55. foreach ($this->collection as $detail){
  56. $closure(Feature::MAPPING["order"],$detail->order,$detail);
  57. }
  58. }
  59. }
  60. }