| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Services;
- use App\Traits\ServiceAppAop;
- use App\OwnerStoreFeeDetail;
- use App\Traits\SettlementBillTrait;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Builder;
- class OwnerStoreFeeDetailService
- {
- use ServiceAppAop;
- use \App\Traits\SettlementBillServiceTrait;
- const TYPE = '入库费-明细';
- protected $modelClass = OwnerStoreFeeDetail::class;
- public function get(array $kvPairs): \Illuminate\Contracts\Pagination\LengthAwarePaginator
- {
- return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
- }
- /**
- * @param $counting_month
- * @param $owner_id
- * @return Builder
- */
- public function getSql($counting_month, $owner_id): Builder
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return OwnerStoreFeeDetail::query()
- ->with([
- 'ownerFeeDetail:id,worked_at',
- 'commodity:id,name',
- ])
- ->whereBetween('created_at', [$start, $end])
- ->where('owner_id', $owner_id);
- }
- public function buildExport($details): array
- {
- $results = [];
- foreach ($details as $detail) {
- $results[] = [
- $detail->ownerFeeDetail->worked_at ?? null,
- $detail->work_name ?? null,
- $detail->asn_code ?? null,
- $detail->sku ?? null,
- $detail->commodity->name ?? null,
- $detail->amount ?? null,
- $detail->unit_price ?? null,
- $detail->fee ?? null,
- ];
- }
- return $results;
- }
- }
|