| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Services;
- use App\Interfaces\SettlementBillDetailInterface;
- use App\Traits\ServiceAppAop;
- use App\OwnerStoreOutFeeDetail;
- use App\Traits\SettlementBillServiceTrait;
- use Illuminate\Contracts\Pagination\LengthAwarePaginator;
- use Illuminate\Database\Eloquent\Builder;
- class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
- {
- const TYPE = '出库费-明细';
- use ServiceAppAop;
- use SettlementBillServiceTrait;
- protected $modelClass = OwnerStoreOutFeeDetail::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);
- }
- public function getSql($owner_id, $counting_month): Builder
- {
- list($start, $end) = $this->getStartAndEnd($counting_month);
- return OwnerStoreOutFeeDetail::query()
- ->with(['commodity:id,name,sku', 'ownerFeeDetail:id,worked_at,operation_bill,work_fee'])
- ->where('owner_id', $owner_id)
- ->whereBetween('created_at', [$start, $end]);
- }
- public function switchType($type)
- {
- // TODO: Implement switchType() method.
- }
- public function buildExport($details): array
- {
- $result = [];
- foreach ($details as $detail) {
- $result[] = [
- $detail->ownerFeeDetail->worked_at,
- $detail->work_name,
- $detail->source_bill,
- $detail->ownerFeeDetail->operation_bill,
- $detail->commodity->sku,
- $detail->commodity->name,
- $detail->amount,
- $detail->remark,
- $detail->ownerFeeDetail->work_fee,
- ];
- }
- return $result;
- }
- public function add(array $model)
- {
- // TODO: Implement add() method.
- }
- }
|