SettlementBillReportJob.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Jobs;
  3. use App\Services\OwnerFeeTotalService;
  4. use App\Services\OwnerLogisticFeeReportService;
  5. use App\Services\OwnerStoreFeeReportService;
  6. use App\Services\OwnerStoreOutFeeReportService;
  7. use Illuminate\Bus\Queueable;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. use Illuminate\Queue\SerializesModels;
  12. /**
  13. * 快递 出库 入库 总账单 统计报表生成任务
  14. * Class SettlementBillReportTask
  15. * @package App\Jobs
  16. */
  17. class SettlementBillReportJob implements ShouldQueue
  18. {
  19. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  20. public $timeout = 3600;
  21. public $maxExceptions = 3;
  22. public $tries = 2;
  23. //生成报告的日期 2021-08-01 生成8月份的报告
  24. public $init_date;
  25. /**
  26. * 初始化的货主,填[]为全部
  27. * @var $ownerIds array
  28. */
  29. public $ownerIds;
  30. /**
  31. * @param $init_date
  32. * @param $ownerIds
  33. */
  34. public function __construct($init_date, $ownerIds)
  35. {
  36. $this->init_date = $init_date;
  37. $this->ownerIds = $ownerIds;
  38. }
  39. /**
  40. * Execute the job.
  41. *
  42. * @return void
  43. */
  44. public function handle()
  45. {
  46. //快递
  47. /** @var OwnerLogisticFeeReportService $expressFeeReportService */
  48. $expressFeeReportService = app('OwnerLogisticFeeReportService');
  49. $expressFeeReportService->recordReport($this->init_date, $this->ownerIds);
  50. //入库
  51. /** @var OwnerStoreFeeReportService $storeFeeReportService */
  52. $storeFeeReportService = app('OwnerStoreFeeReportService');
  53. $storeFeeReportService->recordReport($this->init_date, $this->ownerIds);
  54. //出库
  55. /** @var OwnerStoreOutFeeReportService $storeOutFeeReportService */
  56. $storeOutFeeReportService = app('OwnerStoreOutFeeReportService');
  57. $storeOutFeeReportService->recordReport($this->init_date, $this->ownerIds);
  58. //总账单
  59. /** @var OwnerFeeTotalService $feeTotal */
  60. $feeTotal = app('OwnerFeeTotalService');
  61. $feeTotal->record($this->init_date, $this->ownerIds);
  62. }
  63. }