新增功能页面: - 货款对账 (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 动态视图解析
116 lines
3.1 KiB
PHP
116 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Http\Controllers\Api;
|
|
|
|
use App\Abstracts\Http\ApiController;
|
|
use Modules\EcommerceFinance\Repositories\GoodsReconciliationRepository;
|
|
|
|
/**
|
|
* 货款对账 API
|
|
*
|
|
* 提供供应商应付-货款对账页面的全部数据接口:
|
|
* GET /api/ecommerce-finance/goods-reconciliations 列表(分页 + 筛选)
|
|
* GET /api/ecommerce-finance/goods-reconciliations/summary 统计卡片
|
|
* GET /api/ecommerce-finance/goods-reconciliations/options 筛选器选项
|
|
*/
|
|
class GoodsReconciliations extends ApiController
|
|
{
|
|
private GoodsReconciliationRepository $repo;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->repo = new GoodsReconciliationRepository();
|
|
}
|
|
|
|
/**
|
|
* 货款对账列表(分页 + 筛选)
|
|
*/
|
|
public function index()
|
|
{
|
|
$filters = $this->buildFilters();
|
|
$page = max((int) request('page', 1), 1);
|
|
$limit = $this->limit();
|
|
|
|
$result = $this->repo->list($filters, $page, $limit);
|
|
|
|
return response()->json([
|
|
'data' => $result['data'],
|
|
'total' => $result['total'],
|
|
'page' => $page,
|
|
'per_page' => $limit,
|
|
'last_page' => (int) ceil($result['total'] / $limit),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 汇总统计卡片
|
|
*/
|
|
public function summary()
|
|
{
|
|
$filters = $this->buildFilters();
|
|
$summary = $this->repo->summary($filters);
|
|
|
|
return response()->json($summary);
|
|
}
|
|
|
|
/**
|
|
* 筛选器选项(供应商/仓库下拉列表等)
|
|
*/
|
|
public function options()
|
|
{
|
|
$options = $this->repo->filterOptions();
|
|
|
|
return response()->json($options);
|
|
}
|
|
|
|
// ===================================================================
|
|
// Helpers
|
|
// ===================================================================
|
|
|
|
/**
|
|
* 从请求参数构建筛选条件
|
|
*/
|
|
private function buildFilters(): array
|
|
{
|
|
$filters = [];
|
|
|
|
// 记录类型
|
|
if ($type = request('record_type')) {
|
|
$filters['record_type'] = $type; // purchase | sale | all
|
|
}
|
|
|
|
// 文本筛选
|
|
$textFields = ['supplier', 'stock_no', 'purchase_no', 'product_code', 'express_no', 'warehouse'];
|
|
foreach ($textFields as $field) {
|
|
if ($val = request($field)) {
|
|
$filters[$field] = trim($val);
|
|
}
|
|
}
|
|
|
|
// 日期范围
|
|
$dateFields = ['send_time_from', 'send_time_to', 'create_time_from', 'create_time_to'];
|
|
foreach ($dateFields as $field) {
|
|
if ($val = request($field)) {
|
|
$filters[$field] = $val;
|
|
}
|
|
}
|
|
|
|
// 发出状态
|
|
if (($sent = request('sent_status')) && $sent !== 'all') {
|
|
$filters['sent_status'] = $sent; // sent | unsent
|
|
}
|
|
|
|
// 是否有差异
|
|
if (request('has_diff')) {
|
|
$filters['has_diff'] = true;
|
|
}
|
|
|
|
return $filters;
|
|
}
|
|
|
|
private function limit(): int
|
|
{
|
|
return min(max((int) request('limit', 25), 1), 100);
|
|
}
|
|
}
|