| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Services;
- use App\Interfaces\SettlementBillDetailInterface;
- use App\OwnerFeeDetail;
- use App\Traits\ServiceAppAop;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Support\Facades\DB;
- 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)
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return DB::table('owner_fee_details')
- ->selectRaw("sum(work_fee) as fee,sum(work_tax_fee) as tax_fee")
- ->where('owner_id', $owner_id)
- ->whereBetween('worked_at', [$start, $end])
- ->where('outer_table_name','processes')
- ->first();
- }
- }
|