SettlementBillsAreaFeeService.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Services;
  3. use App\OwnerAreaReport;
  4. use App\OwnerBillReport;
  5. use App\Traits\ServiceAppAop;
  6. use App\Traits\SettlementBillTrait;
  7. class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDetailInterface
  8. {
  9. /** @var $archiveService OwnerBillReportArchiveService */
  10. private $archiveService;
  11. const TYPE = '仓储费';
  12. use ServiceAppAop;
  13. /**
  14. * @param array $kvPairs
  15. * @return array
  16. */
  17. public function get(array $kvPairs): array
  18. {
  19. $this->archiveService = app('OwnerBillReportArchiveService');
  20. $counting_month = $kvPairs['counting_month'];
  21. $owner_id = $kvPairs['owner_id'];
  22. if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) {
  23. $archived = $this->archiveService->get($kvPairs);
  24. $areaReports = collect($archived->information['areaReports']);
  25. $billReport = collect($archived->information['billReport']);
  26. } else {
  27. $areaReports = OwnerAreaReport::query()
  28. ->with(['ownerStoragePriceModel' => function ($query) {
  29. $query->selectRaw("id,using_type,price,unit_id,unit_id,time_unit_id,name,minimum_area")
  30. ->with(['unit:id,name', 'timeUnit:id,name']);
  31. }])
  32. ->where('owner_id', $owner_id)
  33. ->where('counting_month', $counting_month)
  34. ->get();
  35. $billReport = OwnerBillReport::query()
  36. ->select(['storage_fee', 'id'])
  37. ->where('owner_id', $owner_id)
  38. ->where('counting_month', $counting_month)
  39. ->firstOr(function () {
  40. return new OwnerBillReport();
  41. });
  42. }
  43. return array($areaReports, $billReport);
  44. }
  45. public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
  46. {
  47. // TODO: Implement getSql() method.
  48. }
  49. public function getTotalFee($owner_id, $counting_month)
  50. {
  51. return OwnerBillReport::query()
  52. ->where('owner_id', $owner_id)
  53. ->where('counting_month', $counting_month)
  54. ->first();
  55. }
  56. public function switchType($type)
  57. {
  58. // TODO: Implement switchType() method.
  59. }
  60. public function buildExport($details): array
  61. {
  62. // TODO: Implement buildExport() method.
  63. }
  64. public function add(array $model)
  65. {
  66. // TODO: Implement add() method.
  67. }
  68. }