CaiWuXiTong/modules/EcommerceFinance/Services/SupplierPayableMaintenanceRegistry.php
renshen 813e956df5 应付款终版目录接入独立按表数据
两个「终版」目录(供应商应付(终版)、快递应付(终版))改为独立数据:
保留原有导入、导出、查询、重置、编辑按钮和导入模板,数据初始为空、按表独立存放,
不再借用基础目录的页面与数据。

- 终版目录拥有自己的同名子页面与横向页签
- 新增终版按表数据的独立导入/导出/模板/编辑接口(数据集键 final:<目录>:<页面>)
- 供应商终版 13 个页面、快递终版 4 个页面已接入
- 终版导入模板统一增加“月份”列,记录标识列改为选填
2026-09-29 11:06:41 +08:00

125 lines
9.0 KiB
PHP

<?php
namespace Modules\EcommerceFinance\Services;
use Illuminate\Validation\ValidationException;
class SupplierPayableMaintenanceRegistry
{
/** @return array<string,array{label:string,type:string}> */
public function fields(string $dataset): array
{
$money = static fn (string $label): array => ['label' => $label, 'type' => 'number'];
$text = static fn (string $label): array => ['label' => $label, 'type' => 'text'];
$date = static fn (string $label): array => ['label' => $label, 'type' => 'date'];
$month = static fn (string $label): array => ['label' => $label, 'type' => 'month'];
return match ($dataset) {
'payment-reconciliation' => [
'supplier' => $text('供应商'), 'skuCode' => $text('货号'), 'productCode' => $text('商品编码'),
'skuName' => $text('规格名称'), 'qty' => $money('数量'), 'unitPrice' => $money('单价'),
'amount' => $money('金额'), 'guessUnitPrice' => $money('预估单价'), 'guessAmount' => $money('预估金额'),
'supplierGoodsCode' => $text('供应商商品编码'), 'remark' => $text('备注'),
'warehouse' => $text('仓库名称'), 'expressName' => $text('快递名称'), 'expressNo' => $text('快递单号'),
],
'return-reconciliation', 'return-unpriced' => [
'send_time' => $date('发货时间'), 'supplier' => $text('明细供应商'), 'barcode' => $text('条形码'),
'sku_name' => $text('商品名称'), 'qty' => $money('发货量'), 'unit_price' => $money('单价'),
'amount' => $money('金额'), 'guess_unit_price' => $money('预估单价'), 'guess_amount' => $money('预估金额'),
'supplier_barcode' => $text('供应商条码'), 'remark' => $text('备注'), 'title' => $text('标题'),
'warehouse' => $text('仓库名称'), 'express_no' => $text('快递单号'),
'express_name' => $text('快递名称'), 'labels' => $text('标记多标签'), 'reconciler' => $text('对账人'),
],
'invoice-deductions' => [
'month_str' => $month('日期'), 'category' => $text('类别'), 'payee' => $text('打款抬头'),
'receiver' => $text('收款方'), 'board_factory' => $text('供板材厂家/代扣厂家'),
'subsidy_fee' => $money('补贴费用'), 'remark' => $text('备注'), 'price' => $money('对私打款金额'),
'detail' => $text('明细'), 'note' => $text('注明'), 'person_charge' => $text('负责人'),
],
'compensation-details' => [
'month' => $month('日期'), 'supplier' => $text('供应商'), 'amount' => $money('赔付金额'),
'reason' => $text('赔付原因'), 'remark' => $text('备注'),
],
'advance-details' => [
'supplier' => $text('供应商'), 'contract_name' => $text('协议签订名称'),
'advance_amount' => $money('借支金额'), 'actual_pay' => $money('实际打款金额'),
'month_deduct' => $money('本月扣款金额'), 'should_deduct' => $money('应扣金额'),
'deduct_start_month' => $month('分期起始扣款月份'), 'deduct_end_month' => $month('分期最后扣款月份'),
'remain_periods' => $money('分期剩余期数'), 'month_str' => $month('借支日期'),
'loan_term' => $text('借款期限'), 'remark' => $text('备注'), 'is_paid' => $text('是否打款'),
'pay_month' => $month('打款月份'), 'serial_no' => $text('流水号'),
'loan_agreement' => $text('借支协议'), 'person_charge' => $text('负责人'),
],
'sample-deductions' => [
'finish_time' => $date('日期'), 'department' => $text('部门'), 'creator' => $text('申请人'),
'sku_id' => $text('商品代码'), 'skuName' => $text('商品名称'), 'num' => $money('数量'),
'supplier' => $text('厂家'), 'purchase' => $text('对应采购'), 'productCode' => $text('扣款厂家商品代码'),
'shipping_fee' => $money('运费'), 'cost_price' => $money('成本价'),
'total_amount' => $money('合计扣款金额'), 'estimated_price' => $money('预估价'),
'estimated_price_all' => $money('预估金额'), 'remark' => $text('备注'),
],
'delivery-unpriced' => [
'transactionNo' => $text('来源单号'), 'distributionNo' => $text('单据编号(采购单号)'),
'date' => $date('创建时间'), 'supplier' => $text('供应商'), 'sku' => $text('货号'),
'barCode' => $text('条码'), 'skuName' => $text('规格名'), 'supplier_barcode' => $text('供应商条码'),
'remark' => $text('备注'), 'warehouse' => $text('仓库'), 'expressName' => $text('快递名称'),
'expressNo' => $text('快递单号'), 'purchase' => $text('负责人'),
],
'other-adjustments' => [
'project' => $text('项目'), 'month_str' => $month('日期'), 'supplier' => $text('厂家'),
'supplement_amount' => $money('补款金额'), 'supplement_reason' => $text('补款原因'),
'remark' => $text('备注'), 'remark2' => $text('备注2'), 'person_charge' => $text('负责人'),
],
'dropshipping-express' => [
'reconciliation_person' => $text('对账人'), 'month_str' => $month('日期'), 'supplier' => $text('供应商'),
'express_freight' => $money('快递运费'), 'express_account' => $money('快递记账'),
'replenish_freight' => $money('补运费'), 'replenish_account' => $money('补记账'),
'return_fee' => $money('退回费'), 'intercept_fee' => $money('拦截'),
'change_address_fee' => $money('改地址'), 'turnover_fee' => $money('翻箱费'),
'overlong_fee' => $money('超长费'), 'total_freight' => $money('合计运费'),
'remark' => $text('备注'), 'express_name' => $text('快递'), 'remark2' => $text('备注2'),
],
'board-deductions' => [
'stock_in_date' => $date('入库日期'), 'stock_out_date' => $date('出库日期'),
'furniture_factory' => $text('家具厂'), 'lamination_factory' => $text('压贴厂'),
'deduction_type' => $text('类型'), 'specification' => $text('规格'), 'material_name' => $text('原料名称'),
'received_quantity' => $money('实收数量'), 'unit_price' => $money('单价'), 'amount' => $money('金额'),
'unit' => $text('单位'), 'batch_date' => $date('批次日期'), 'stock_out_number' => $text('出库单号'),
'stock_out_remark' => $text('出库备注'), 'claim_number' => $text('申领单号'),
'number_type' => $text('单号类型'), 'delivery_number' => $text('送货单号'),
],
'supplier-payables-report' => [
'checker' => $text('对账人'), 'settlement_method' => $text('结算方式'), 'company' => $text('供应商公司主体名称'),
'supplier' => $text('供应商简称'), 'express_freight' => $money('快递运费'),
'beginning_payable' => $money('月初未付'), 'unpriced' => $money('之前未定价-本月定价'),
'advance_loan' => $money('预支借款'), 'loan' => $money('货款金额'), 'refund' => $money('退货金额'),
'procurement' => $money('采购小计'), 'invoice_deduction' => $money('发票扣款'),
'board_deduction' => $money('板材扣款'), 'sample_deduction' => $money('样品扣款'),
'total_compensation' => $money('总赔偿金额'), 'other_adjustment' => $money('其他费用'),
'supplier_supplement' => $money('补给厂家'), 'supplier_balance' => $money('供应商余额'),
'should_pay' => $money('应付余额'), 'estimated_price' => $money('预估金额'),
'to_corporate' => $money('对公打款金额'), 'to_private' => $money('对私打款金额'),
'cashier_paid' => $money('已销账金额'), 'remarks' => $text('备注'),
'private_reason' => $text('对私原因'), 'deposit' => $money('押款金额'),
'negative_reason' => $text('负数原因'),
],
default => throw ValidationException::withMessages(['dataset' => '不支持该供应商应付页面。']),
};
}
public function normalize(string $dataset, array $input): array
{
return app(PayablesFieldNormalizer::class)->normalize($this->fields($dataset), $input);
}
public function publicDefinition(string $dataset): array
{
return [
'dataset' => $dataset,
'fields' => collect($this->fields($dataset))->map(
static fn (array $definition, string $name): array => ['name' => $name] + $definition
)->values()->all(),
];
}
}