新增功能页面: - 货款对账 (payment-reconciliation): 入库+代发合并对账,228K+2.8M条记录 - 退货对账 (return-reconciliation): finance_purchaseReturn, 36791行 - 发票扣款 (invoice-deductions): finance_invoiceDeduction, 195行 - 赔偿明细 (compensation-details): 纸板厂+压板厂 UNION, 98行 - 借支明细 (advance-details): finance_advanceLoans, 4行 - 样品扣款 (sample-deductions): finance_sampleDeduction, 12行 后端: - JianSunConnection: PDO_ODBC 直连 SQL Server - SupplierPayableRepository: 5个子页面的数据查询+分页 - GoodsReconciliationRepository: 货款对账数据查询 - 15个新API路由 (supplier-payables/*) - 12个JianSun Eloquent模型 前端: - 6个Blade视图 + 6个Vue组件 - webpack.mix.js 新增5个编译入口 - show.blade.php 动态视图解析
197 lines
6.6 KiB
PHP
197 lines
6.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Http\Controllers\Api;
|
|
|
|
use App\Abstracts\Http\ApiController;
|
|
use Modules\EcommerceFinance\Repositories\SupplierPayableRepository;
|
|
|
|
/**
|
|
* 供应商应付 - 子功能页面 API
|
|
*
|
|
* 为 5 个子页面提供数据接口:
|
|
* 退货对账 : /return-reconciliations + /return-reconciliations/summary + /return-reconciliations/options
|
|
* 发票扣款 : /invoice-deductions + /invoice-deductions/summary + /invoice-deductions/options
|
|
* 赔偿明细 : /compensation-details + /compensation-details/summary + /compensation-details/options
|
|
* 借支明细 : /advance-details + /advance-details/summary + /advance-details/options
|
|
* 样品扣款 : /sample-deductions + /sample-deductions/summary + /sample-deductions/options
|
|
*/
|
|
class SupplierPayables extends ApiController
|
|
{
|
|
private SupplierPayableRepository $repo;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->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 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());
|
|
}
|
|
|
|
// ============================================================
|
|
// Helpers
|
|
// ============================================================
|
|
private function filters(string $type): array
|
|
{
|
|
$filters = [];
|
|
|
|
// 通用文本字段
|
|
$text = ['supplier', 'warehouse', 'sku_id', 'express_no', 'creator', 'department'];
|
|
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);
|
|
}
|
|
}
|