| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Services;
- use App\Interfaces\SettlementBillDetailInterface;
- use App\OwnerFeeDetail;
- use App\Traits\ServiceAppAop;
- use Illuminate\Database\Eloquent\Builder;
- class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
- {
- 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('work_fee');
- return array($details,$totalFee);
- }
- public function getSql($owner_id, $counting_month): Builder
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return OwnerFeeDetail::query()
- ->with(['process.processMethod'])
- ->where('owner_id', $owner_id)
- ->whereBetween('worked_at', [$start, $end])
- ->where('outer_table_name','processes');
- }
- public function switchType($type)
- {
- // TODO: Implement switchType() method.
- }
- public function buildExport($details): array
- {
- $result = array();
- foreach ($details as $detail) {
- $result[] = [
- $detail->worked_at,
- $detail->process->processMethod->name??'',
- $detail->process->code??'',
- $detail->operation_bill,
- $detail->process->remark??'',
- $detail->commodity_amount,
- $detail->process->unit_price??'',
- $detail->work_fee,
- ];
- }
- return $result;
- }
- public function add(array $model)
- {
- // TODO: Implement add() method.
- }
- public function getTotalFee($owner_id, $counting_month)
- {
- // TODO: Implement getTotalFee() method.
- }
- }
|