| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Services;
- use App\DischargeTask;
- use App\Traits\ServiceAppAop;
- use App\Traits\SettlementBillServiceTrait;
- class OwnerDischargeTaskSettlementBillService implements \App\Interfaces\SettlementBillReportInterface
- {
- use \App\Traits\SettlementBillServiceTrait;
- const TYPE = '卸货费';
- use ServiceAppAop;
- public function get(array $kvPairs): array
- {
- $details = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
- $totalFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->sum('expenditure_total_cost');
- return array($details, $totalFee);
- }
- public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return DischargeTask::query()
- ->where('owner_id', $owner_id)
- ->whereBetween('income_at', [$start, $end]);
- }
- public function switchType($type)
- {
- // TODO: Implement switchType() method.
- }
- public function buildExport($details): array
- {
- $result = [];
- foreach ($details as $detail) {
- $result[] = [
- $detail->income_at,
- $detail->type,
- $detail->numbers,
- $detail->expenditure_amount,
- $detail->expenditure_unit,
- $detail->expenditure_unit_price,
- $detail->expenditure_total_cost,
- $detail->income_remark,
- $detail->expenditure_remark,
- ];
- }
- return $result;
- }
- public function add(array $model)
- {
- // TODO: Implement add() method.
- }
- public function getTotalFee($owner_id, $counting_month)
- {
- return $this->getSql($owner_id, $counting_month)->sum('expenditure_total_cost');
- }
- /**
- * @param null $counting_month
- * @param array $ownerIds
- */
- public function recordReport($counting_month = null, array $ownerIds = [])
- {
- // TODO: Implement recordReport() method.
- }
- }
|