| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace App\Services;
- use App\OwnerAreaReport;
- use App\OwnerBillReport;
- use App\OwnerBillReportArchive;
- use App\Traits\ServiceAppAop;
- class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillReportInterface
- {
- /** @var $archiveService OwnerBillReportArchiveService */
- private $archiveService;
- const TYPE = '仓储费';
- use ServiceAppAop;
- use \App\Traits\SettlementBillServiceTrait;
- /**
- * @param array $kvPairs
- * @return array
- */
- public function get(array $kvPairs): array
- {
- $this->archiveService = app('OwnerBillReportArchiveService');
- $counting_month = $kvPairs['counting_month'];
- $owner_id = $kvPairs['owner_id'];
- if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) {
- $archived = $this->archiveService->get($kvPairs);
- $areaReports = collect($archived->information['areaReports']);
- $billReport = collect($archived->information['billReport']);
- } else {
- $areaReports = OwnerAreaReport::query()
- ->with(['ownerStoragePriceModel' => function ($query) {
- $query->selectRaw("id,using_type,price,unit_id,unit_id,time_unit_id,name,minimum_area")
- ->with(['unit:id,name', 'timeUnit:id,name']);
- }])
- ->where('owner_id', $owner_id)
- ->where('counting_month', $counting_month)
- ->get();
- $billReport = OwnerBillReport::query()
- ->select(['storage_fee', 'id'])
- ->where('owner_id', $owner_id)
- ->where('counting_month', $counting_month)
- ->firstOr(function () {
- return new OwnerBillReport();
- });
- }
- return array($areaReports, $billReport);
- }
- public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
- {
- // TODO: Implement getSql() method.
- }
- public function getTotalFee($owner_id, $counting_month)
- {
- return OwnerBillReport::query()
- ->where('owner_id', $owner_id)
- ->where('counting_month', $counting_month)
- ->first();
- }
- public function switchType($type)
- {
- // TODO: Implement switchType() method.
- }
- public function buildExport($details): array
- {
- // TODO: Implement buildExport() method.
- }
- public function add(array $model)
- {
- // TODO: Implement add() method.
- }
- public function recordReport($counting_month = null,array $ownerIds = [])
- {
- // TODO: Implement recordReport() method.
- }
- public function confirmBill($counting_month, $owner_id)
- {
- list($areaReports, $billReport) = $this->get([
- 'owner_id' => $owner_id,
- 'counting_month' => $counting_month,
- 'type' => $this::TYPE,
- ]);
- OwnerBillReportArchive::query()->create([
- 'owner_bill_report_id' => $billReport->id ?? null,
- 'owner_id' => $owner_id,
- 'counting_month' => $counting_month,
- 'type' => $this::TYPE,
- 'archiver_id' => auth()->id(),
- 'archived_at' => now(),
- 'information' => [
- 'areaReports' => $areaReports,
- 'billReport' => $billReport,
- ],
- ]);
- $this->confirmBillFeeTotal($counting_month, $owner_id);
- }
- }
|