| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Services;
- use App\Logistic;
- use App\OwnerFeeDetail;
- use App\OwnerFeeExpress;
- use App\Traits\ServiceAppAop;
- use App\OwnerLogisticFeeDetail;
- use App\Traits\SettlementBillServiceTrait;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Pagination\LengthAwarePaginator;
- class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
- {
- use SettlementBillServiceTrait;
- const TYPE = '快递费-明细';
- use ServiceAppAop;
- /**
- * @var $modelClass OwnerFeeExpress
- */
- protected $modelClass = OwnerFeeExpress::class;
- /**
- * 根据货主查询 和时间段查询
- * @param array $kvPairs
- * @return LengthAwarePaginator
- */
- public function get(array $kvPairs): LengthAwarePaginator
- {
- 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 OwnerFeeExpress::query()
- ->with(['province', 'logistic'])
- ->where('owner_id', $owner_id)
- ->whereBetween('created_at', [$start, $end])
- ->orderBy('logistic_id');
- }
- public function switchType($type)
- {
- }
- public function buildExport($details): array
- {
- $result = [];
- foreach ($details as $key => $detail) {
- // $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
- $result[] = [
- $detail->id,
- $detail->logistic->name ?? '',
- $detail->province->name ?? '',
- $detail->logistic_number ?? '',
- $detail->weight ?? '',
- $detail->initial_weight_price ?? '',
- $detail->additional_weight_price ?? '',
- $detail->total_fee ?? '',
- ];
- }
- return $result;
- }
- public function add(array $model)
- {
- }
- public function getTotalFee($owner_id, $counting_month)
- {
- }
- }
|