| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Services;
- use App\OwnerFeeOperation;
- use App\OwnerPriceOperation;
- 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);
- $OwnerPriceOperationQuery = OwnerPriceOperation::query()
- ->select('id')
- ->where('operation_type', '入库');
- return OwnerFeeOperation::query()
- ->with(['details','model','commodity.barcodes'])
- ->whereIn('model_id', $OwnerPriceOperationQuery)
- ->whereBetween('worked_at', [$start, $end])
- ->where('owner_id', $owner_id);
- }
- public function buildExport($details): array
- {
- // $row = ['作业日期', '作业名称', '入库单号', '商品条码', '商品名称', '数量', '单价', '入库费'];
- $results = [];
- foreach ($details as $detail) {
- $results[] = [
- $detail->worked_at ?? '',
- $detail->model->name ?? '',
- $detail->doc_number ?? '',
- $detail->commodity->sku ?? '',
- $detail->commodity->name ?? '',
- $detail->details[0]->amount ?? '',
- $detail->details[0]->price ?? '',
- $detail->total_fee ?? '',
- ];
- }
- return $results;
- }
- }
|