| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Services;
- use App\OwnerFeeDetail;
- use App\OwnerFeeLogistic;
- use App\Traits\ServiceAppAop;
- use App\Waybill;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Support\Facades\DB;
- class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBillDetailInterface
- {
- use ServiceAppAop;
- use \App\Traits\SettlementBillServiceTrait;
- const TYPE = '物流费';
- public function get(array $kvPairs)
- {
- return $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
- }
- /**
- * @param $owner_id
- * @param $counting_month
- * @return Builder
- */
- public function getSql($owner_id, $counting_month): Builder
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return OwnerFeeLogistic::query()
- ->where('owner_id', $owner_id)
- ->whereBetween('created_at', [$start, $end])
- ->with(['province', 'logistic', 'city','unit']);
- }
- public function switchType($type)
- {
- // TODO: Implement switchType() method.
- }
- public function buildExport($details): array
- {
- $results = [];
- foreach ($details as $detail) {
- $results[] = [
- $detail->logistic->name ?? '',
- $detail->order_number ?? '',
- $detail->recipient_name ?? '',
- $detail->recipient_phone ?? '',
- $detail->quantity ?? '',
- $detail->unit->name ?? '',
- $detail->interval ?? '',
- $detail->province->name ?? '',
- $detail->city->name ?? '',
- $detail->price ?? '',
- $detail->delivery_fee ?? '',
- $detail->pick_fee ?? '',
- $detail->fuel_fee ?? '',
- $detail->info_fee ?? '',
- $detail->other_fee ?? '',
- $detail->remark ?? '',
- $detail->initial_fee ?? '',
- $detail->initial_amount ?? '',
- $detail->total_fee ?? '',
- ];
- }
- return $results;
- }
- public function add(array $model)
- {
- // TODO: Implement add() method.
- }
- public function getTotalFee($owner_id, $counting_month)
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return OwnerFeeLogistic::query()
- ->selectRaw("
- sum(total_fee) as fee,
- sum(tax_rate*total_fee) as tax_fee
- ")
- ->where('owner_id', $owner_id)
- ->whereBetween('created_at', [$start, $end])
- ->first();
- }
- }
|