repo = new SupplierPayableRepository(); } // ============================================================ // 退货对账 // ============================================================ public function returnReconciliationsIndex() { $filters = $this->filters('return'); $result = $this->repo->returnReconciliations($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function returnReconciliationsSummary() { return response()->json($this->repo->returnReconciliationSummary($this->filters('return'))); } public function returnReconciliationsOptions() { return response()->json($this->repo->filterOptionsForReturn()); } // ============================================================ // 发票扣款 // ============================================================ public function invoiceDeductionsIndex() { $filters = $this->filters('invoice'); $result = $this->repo->invoiceDeductions($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function invoiceDeductionsSummary() { return response()->json($this->repo->invoiceDeductionSummary($this->filters('invoice'))); } public function invoiceDeductionsOptions() { return response()->json($this->repo->filterOptionsForInvoice()); } // ============================================================ // 赔偿明细 // ============================================================ public function compensationDetailsIndex() { $filters = $this->filters('compensation'); $result = $this->repo->compensationDetails($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function compensationDetailsSummary() { return response()->json($this->repo->compensationDetailSummary($this->filters('compensation'))); } public function compensationDetailsOptions() { return response()->json($this->repo->filterOptionsForCompensation()); } // ============================================================ // 借支明细 // ============================================================ public function advanceDetailsIndex() { $filters = $this->filters('advance'); $result = $this->repo->advanceDetails($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function advanceDetailsSummary() { return response()->json($this->repo->advanceDetailSummary($this->filters('advance'))); } public function advanceDetailsOptions() { return response()->json($this->repo->filterOptionsForAdvance()); } // ============================================================ // 送货未定价 // ============================================================ public function deliveryUnpricedIndex() { $filters = $this->filters('delivery-unpriced'); $result = $this->repo->deliveryUnpriced($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function deliveryUnpricedSummary() { return response()->json($this->repo->deliveryUnpricedSummary($this->filters('delivery-unpriced'))); } public function deliveryUnpricedOptions() { return response()->json($this->repo->filterOptionsForDeliveryUnpriced()); } // ============================================================ // 退货未定价 // ============================================================ public function returnUnpricedIndex() { $filters = $this->filters('return-unpriced'); $result = $this->repo->returnUnpriced($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function returnUnpricedSummary() { return response()->json($this->repo->returnUnpricedSummary($this->filters('return-unpriced'))); } public function returnUnpricedOptions() { return response()->json($this->repo->filterOptionsForReturnUnpriced()); } // ============================================================ // 样品扣款 // ============================================================ public function sampleDeductionsIndex() { $filters = $this->filters('sample'); $result = $this->repo->sampleDeductions($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function sampleDeductionsSummary() { return response()->json($this->repo->sampleDeductionSummary($this->filters('sample'))); } public function sampleDeductionsOptions() { return response()->json($this->repo->filterOptionsForSample()); } // ============================================================ // 其他扣款补款 // ============================================================ public function otherAdjustmentsIndex() { $filters = $this->filters('other-adjustments'); $result = $this->repo->otherAdjustments($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function otherAdjustmentsSummary() { return response()->json($this->repo->otherAdjustmentsSummary($this->filters('other-adjustments'))); } public function otherAdjustmentsOptions() { return response()->json($this->repo->filterOptionsForOtherAdjustments()); } // ============================================================ // 代发快递 // ============================================================ public function dropshippingExpressIndex() { $filters = $this->filters('dropshipping-express'); $result = $this->repo->dropshippingExpress($filters, $this->page(), $this->limit()); return response()->json([ 'data' => $result['data'], 'total' => $result['total'], 'page' => $this->page(), 'per_page' => $this->limit(), 'last_page' => (int) ceil(max($result['total'], 0) / $this->limit()), ]); } public function dropshippingExpressSummary() { return response()->json($this->repo->dropshippingExpressSummary($this->filters('dropshipping-express'))); } public function dropshippingExpressOptions() { return response()->json($this->repo->filterOptionsForDropshippingExpress()); } // ============================================================ // Helpers // ============================================================ private function filters(string $type): array { $filters = []; // 通用文本字段 $text = ['supplier', 'warehouse', 'sku_id', 'express_no', 'creator', 'department', 'purchase', 'barcode', 'express_name']; foreach ($text as $field) { if ($val = request($field)) { $filters[$field] = trim($val); } } // 日期 foreach (['date_from', 'date_to', 'month_from', 'month_to'] as $field) { if ($val = request($field)) { $filters[$field] = $val; } } return $filters; } private function page(): int { return max((int) request('page', 1), 1); } private function limit(): int { return min(max((int) request('limit', 25), 1), 100); } }