OwnerFeeTotalController.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Owner;
  4. use App\OwnerBillReport;
  5. use App\OwnerBillReportArchive;
  6. use App\Services\OwnerBillReportArchiveService;
  7. use App\Services\OwnerDischargeTaskSettlementBillService;
  8. use App\Services\OwnerFeeTotalService;
  9. use App\Services\OwnerLogisticFeeReportService;
  10. use App\Services\OwnerProcessSettlementBillService;
  11. use App\Services\OwnerProcurementSettlementBillService;
  12. use App\Services\OwnerStoreFeeReportService;
  13. use App\Services\OwnerStoreOutFeeReportService;
  14. use App\Services\OwnerSundryFeeDetailService;
  15. use App\Services\OwnerWaybillSettlementBillService;
  16. use App\Services\SettlementBillsAreaFeeService;
  17. use App\Services\SettlementIndemnityFeeService;
  18. use Illuminate\Http\Request;
  19. class OwnerFeeTotalController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
  20. {
  21. use \App\Traits\SettlementBillTrait;
  22. /** @var OwnerFeeTotalService $service */
  23. private $service;
  24. /** @var OwnerBillReportArchiveService $archiveService */
  25. private $archiveService;
  26. /**
  27. * OwnerDischargeTaskSettlementBillController constructor.
  28. */
  29. public function __construct()
  30. {
  31. $this->service = app('OwnerFeeTotalService');
  32. $this->archiveService = app('OwnerBillReportArchiveService');
  33. }
  34. public function index(Request $request)
  35. {
  36. $paginateParams = $request->input();
  37. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  38. $feeTotal = $this->service->get([
  39. 'counting_month' => $counting_month,
  40. 'owner_id' => $owner_id,
  41. 'paginateParams' => $paginateParams,
  42. ]);
  43. $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
  44. $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
  45. $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
  46. $request = $this->buildRequest($request, $counting_month,$owner_id);
  47. $isArchivedItems = collect([
  48. 'expressFee' => $this->archiveService->isArchived($counting_month, $owner_id, '快递费-合计'),
  49. 'logisticFee' => $this->archiveService->isArchived($counting_month, $owner_id, '物流费'),
  50. 'packingMaterialFee' => $this->archiveService->isArchived($counting_month, $owner_id, '包材费'),
  51. 'processFee' => $this->archiveService->isArchived($counting_month, $owner_id, '加工费'),
  52. 'storageFee' => $this->archiveService->isArchived($counting_month, $owner_id, '仓储费'),
  53. 'storeFee' => $this->archiveService->isArchived($counting_month, $owner_id, '入库费-合计'),
  54. 'storeOutFee' => $this->archiveService->isArchived($counting_month, $owner_id, '出库费-合计'),
  55. 'sundryFee' => $this->archiveService->isArchived($counting_month, $owner_id, '杂项费'),
  56. 'unloadFee' => $this->archiveService->isArchived($counting_month, $owner_id, '卸货费'),
  57. 'indemnityFee' => $this->archiveService->isArchived($counting_month, $owner_id, '理赔费'),
  58. ]);
  59. return view('finance.settlementBills.totalFee.index', compact('feeTotal', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'isArchivedItems'));
  60. }
  61. public function export(Request $request)
  62. {
  63. }
  64. public function confirmBill(Request $request): \Illuminate\Http\RedirectResponse
  65. {
  66. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  67. $billReport = OwnerBillReport::query()
  68. ->select('id')
  69. ->where('owner_id', $owner_id)
  70. ->where('counting_month', $counting_month)
  71. ->firstOr(function () {
  72. return new OwnerBillReport();
  73. });
  74. OwnerBillReportArchive::query()->create([
  75. 'owner_bill_report_id' => $billReport->id ?? null,
  76. 'owner_id' => $owner_id,
  77. 'counting_month' => $counting_month,
  78. 'type' => $this->service::TYPE,
  79. 'archiver_id' => auth()->id(),
  80. 'archived_at' => now(),
  81. 'information' => [],
  82. ]);
  83. $unArchived = $this->archiveService->getUnAchieved($counting_month, $owner_id);
  84. foreach ($unArchived as $type) {
  85. switch ($type) {
  86. case '仓储费':
  87. /**@var $storageFeeService SettlementBillsAreaFeeService */
  88. $storageFeeService = app('SettlementBillsAreaFeeService');
  89. $storageFeeService->confirmBill($counting_month, $owner_id);
  90. break;
  91. case '快递费-合计':
  92. /**@var $expressFeeService OwnerLogisticFeeReportService */
  93. $expressFeeService = app('OwnerLogisticFeeReportService');
  94. $expressFeeService->confirmBill($counting_month, $owner_id);
  95. break;
  96. case '入库费-合计':
  97. /**@var $storeFeeService OwnerStoreFeeReportService */
  98. $storeFeeService = app('OwnerStoreFeeReportService');
  99. $storeFeeService->confirmBill($counting_month, $owner_id);
  100. break;
  101. case '出库费-合计':
  102. /**@var $storeOutFeeService OwnerStoreOutFeeReportService */
  103. $storeOutFeeService = app('OwnerStoreOutFeeReportService');
  104. $storeOutFeeService->confirmBill($counting_month, $owner_id);
  105. break;
  106. case '物流费':
  107. /**@var $logisticFeeService OwnerWaybillSettlementBillService */
  108. $logisticFeeService = app('OwnerWaybillSettlementBillService');
  109. $logisticFeeService->confirmBill($counting_month, $owner_id);
  110. break;
  111. case '包材费':
  112. /**@var $packingMaterialFeeService OwnerProcurementSettlementBillService */
  113. $packingMaterialFeeService = app('OwnerProcurementSettlementBillService');
  114. $packingMaterialFeeService->confirmBill($counting_month, $owner_id);
  115. break;
  116. case '加工费':
  117. /**@var $processFeeService OwnerProcessSettlementBillService */
  118. $processFeeService = app('OwnerProcessSettlementBillService');
  119. $processFeeService->confirmBill($counting_month, $owner_id);
  120. break;
  121. case '杂项费':
  122. /**@var $sundryFeeService OwnerSundryFeeDetailService */
  123. $sundryFeeService = app('OwnerSundryFeeDetailService');
  124. $sundryFeeService->confirmBill($counting_month, $owner_id);
  125. break;
  126. case '卸货费':
  127. /**@var $unloadFeeService OwnerDischargeTaskSettlementBillService */
  128. $unloadFeeService = app('OwnerDischargeTaskSettlementBillService');
  129. $unloadFeeService->confirmBill($counting_month, $owner_id);
  130. break;
  131. case '理赔费':
  132. /**@var $indemnityFeeService SettlementIndemnityFeeService */
  133. $indemnityFeeService = app('SettlementIndemnityFeeService');
  134. $indemnityFeeService->confirmBill($counting_month, $owner_id);
  135. break;
  136. }
  137. }
  138. return back()->with('success', '确认成功');
  139. }
  140. }