diff --git a/app/Http/Controllers/Business/CourierBillController.php b/app/Http/Controllers/Business/CourierBillController.php index fcff3393a..45d4ca030 100644 --- a/app/Http/Controllers/Business/CourierBillController.php +++ b/app/Http/Controllers/Business/CourierBillController.php @@ -562,15 +562,16 @@ final class CourierBillController extends Controller return response()->streamDownload(function () use ($query): void { $book = new StreamingWorkbook(); $book->row('对账明细', ['账单月份', '对账分组', '负责人', '快递单号', '快递提供运费', '快递提供重量', '分类', '发货时间', '发货数据快递名称1', - '核算运费', '结算运费', '运费差', '计费重量', '结算重量', '重量差', '未发出来源', '处理结果', '处理人'], true); + '核算运费', '结算重量', '结算运费', '运费差', '计费重量', '重量差', '未发出来源', '处理结果', '处理人'], true); foreach ($query->orderBy('l.id')->select(['l.*', 's.bill_month', 'g.name as group_name', 'g.owner'])->lazyById(1000, 'l.id', 'id') as $line) { $comparison = \App\Support\CourierBills\SettlementComparison::courier($line); $book->row('对账明细', [$line->bill_month, $line->group_name, $line->owner, (string) $line->waybill_no, $line->bill_amount === null ? null : (float) $line->bill_amount, $line->bill_weight === null ? null : (float) $line->bill_weight, Category::label((string) $line->category, $line->category_month), $line->ship_time, $line->express_name, $line->calc_freight === null ? null : (float) $line->calc_freight, + $comparison['settlement_weight'], $line->self_amount === null ? null : (float) $line->self_amount, $comparison['freight_diff'], - $line->charge_weight === null ? null : (float) $line->charge_weight, $comparison['settlement_weight'], $comparison['weight_diff'], + $line->charge_weight === null ? null : (float) $line->charge_weight, $comparison['weight_diff'], $line->unshipped_sources, Category::RESOLUTIONS[$line->resolution] ?? null, $line->resolved_by]); } $book->writeTo(fopen('php://output', 'wb')); diff --git a/app/Http/Controllers/Business/DropshipFreightController.php b/app/Http/Controllers/Business/DropshipFreightController.php index 32a388a9e..4ba69f521 100644 --- a/app/Http/Controllers/Business/DropshipFreightController.php +++ b/app/Http/Controllers/Business/DropshipFreightController.php @@ -428,10 +428,10 @@ final class DropshipFreightController extends Controller } foreach ($details as [$factory, $rows]) { $sheet = $factories->count() === 1 ? '明细' : mb_substr((string) $factory->name, 0, 28); - $book->row($sheet, ['快递单号', '发货时间', '快递名称1', '仓库', '厂家运费', '我方核算运费', '结算运费', '最终结算运费', '运费差', '厂家重量', '我方计费重量', '结算重量', '重量差', '状态', '说明', '核算公式'], true); + $book->row($sheet, ['快递单号', '发货时间', '快递名称1', '仓库', '厂家运费', '我方核算运费', '结算重量', '结算运费', '最终结算运费', '运费差', '厂家重量', '我方计费重量', '重量差', '状态', '说明', '核算公式'], true); foreach ($rows as $r) { - $book->row($sheet, [$r['waybill'], $r['ship_time'], $r['express'], $r['warehouse'], $r['bill'], $r['calc'], $r['settle'], - $r['final'] ?? $r['settle'], $r['freight_diff'], $r['bill_weight'], $r['charge_weight'], $r['settlement_weight'], $r['weight_diff'], $r['label'], $r['note'], $r['formula']]); + $book->row($sheet, [$r['waybill'], $r['ship_time'], $r['express'], $r['warehouse'], $r['bill'], $r['calc'], $r['settlement_weight'], $r['settle'], + $r['final'] ?? $r['settle'], $r['freight_diff'], $r['bill_weight'], $r['charge_weight'], $r['weight_diff'], $r['label'], $r['note'], $r['formula']]); } } $book->writeTo(fopen('php://output', 'wb')); diff --git a/app/Support/CourierBills/StatementExporter.php b/app/Support/CourierBills/StatementExporter.php index 4324af84f..997df2a54 100644 --- a/app/Support/CourierBills/StatementExporter.php +++ b/app/Support/CourierBills/StatementExporter.php @@ -19,7 +19,7 @@ final class StatementExporter public const FRONT = [ '称重重量' => '_measured', '首重' => 'qc_first_price', '面单' => 'qc_miandan', '快递单号' => 'express_no', '交易单号' => 'trade_no', '商品ID' => 'item_id', '条形码' => 'barcode', '商品名称' => 'product_name', '数量' => 'qty', - '计费重量' => 'qc_charge_weight', '结算重量' => '_settlement_weight', '续重/费率' => 'qc_rate', '核算运费' => 'qc_freight', '重量差' => '_weight_diff', + '计费重量' => 'qc_charge_weight', '续重/费率' => 'qc_rate', '核算运费' => 'qc_freight', '结算重量' => '_settlement_weight', '重量差' => '_weight_diff', '运费差' => '_freight_diff', '省' => 'receiver_state', '买家昵称' => 'buyer_nick', '收货姓名' => 'receiver_name', '店铺名称' => 'shop_name', '快递名称1' => 'express_name1', '仓库' => 'warehouse_name', '发货时间' => 'ship_time', '未发出' => '_unshipped', '运费' => 'freight', '线上重量' => 'online_weight', '实称重量' => 'actual_weight', @@ -111,7 +111,7 @@ final class StatementExporter $front = []; foreach (self::FRONT as $label => $field) { $front[$label] = $field; - if ($field === 'qc_freight') $front['结算运费'] = '_settlement'; + if ($field === '_settlement_weight') $front['结算运费'] = '_settlement'; } $rest = array_diff_key(ShippingLookup::COLUMNS, array_flip(array_filter(self::FRONT, static fn ($f) => $f[0] !== '_'))); $rest['settle_freight'] = '发货数据结算运费'; diff --git a/app/Support/DropshipFreight/DropshipExporter.php b/app/Support/DropshipFreight/DropshipExporter.php index 5fbec5c5c..cf5777806 100644 --- a/app/Support/DropshipFreight/DropshipExporter.php +++ b/app/Support/DropshipFreight/DropshipExporter.php @@ -315,14 +315,14 @@ final class DropshipExporter }, $original); } - /** 对账表前面几列:照快递对账单的,「核算运费」后面加「最终结算运费」。 @return array */ + /** 对账表前面几列:核算运费、结算重量、最终结算运费依次相邻。 @return array */ private static function frontColumns(): array { $result = []; foreach (StatementExporter::FRONT as $label => $field) { if ($field === 'qc_charge_weight') $result['厂家重量(kg)'] = '_bill_weight'; $result[$label] = $field; - if ($field === 'qc_freight') { + if ($field === '_settlement_weight') { $result['最终结算运费'] = '_final'; } } diff --git a/resources/views/business/pages/courier-payables/courier-bills/details.blade.php b/resources/views/business/pages/courier-payables/courier-bills/details.blade.php index c6b94309b..9af26c9c1 100644 --- a/resources/views/business/pages/courier-payables/courier-bills/details.blade.php +++ b/resources/views/business/pages/courier-payables/courier-bills/details.blade.php @@ -29,8 +29,8 @@ 账单月份对账分组负责人快递单号分类 - 快递运费核算运费结算运费运费差 - 快递重量计费重量结算重量重量差 + 快递运费核算运费结算重量结算运费运费差 + 快递重量计费重量重量差 发货时间发货数据快递名称1处理结果 @@ -41,10 +41,10 @@ {{ $line->bill_month }}{{ $line->group_name }}{{ $line->owner }}{{ $line->waybill_no }} {{ \App\Support\CourierBills\Category::label((string) $line->category, $line->category_month) }} {{ $money($line->bill_amount) }}{{ $money($line->calc_freight) }} + {{ $comparison['settlement_weight'] === null ? '' : round($comparison['settlement_weight'], 4) }} {{ $money($line->self_amount) }}{{ $money($comparison['freight_diff']) }} {{ $line->bill_weight === null ? '' : round((float) $line->bill_weight, 4) }} {{ $line->charge_weight === null ? '' : round((float) $line->charge_weight, 4) }} - {{ $comparison['settlement_weight'] === null ? '' : round($comparison['settlement_weight'], 4) }} {{ $comparison['weight_diff'] ?? '' }} {{ $line->ship_time ? substr((string) $line->ship_time, 0, 16) : '' }}{{ $line->express_name }} {{ \App\Support\CourierBills\Category::RESOLUTIONS[$line->resolution] ?? '' }}{{ $line->statement_status === 'confirmed' ? '(已确认结算)' : '' }} diff --git a/resources/views/business/pages/courier-payables/courier-bills/statement.blade.php b/resources/views/business/pages/courier-payables/courier-bills/statement.blade.php index 7fa993818..5d19a7d28 100644 --- a/resources/views/business/pages/courier-payables/courier-bills/statement.blade.php +++ b/resources/views/business/pages/courier-payables/courier-bills/statement.blade.php @@ -111,7 +111,7 @@ @else @if ($open)@endif 快递单号快递运费快递重量 - 发货时间发货数据快递名称1核算运费结算运费计费重量结算重量 + 发货时间发货数据快递名称1核算运费结算重量结算运费计费重量 运费差重量差未发出来源处理结果 @endif @@ -129,9 +129,9 @@ {{ $line->ship_time ? substr((string) $line->ship_time, 0, 16) : '' }} {{ $line->express_name }} {{ $money($line->calc_freight) }} + {{ $comparison['settlement_weight'] === null ? '' : round($comparison['settlement_weight'], 4) }} {{ $money($line->self_amount) }} {{ $line->charge_weight === null ? '' : rtrim(rtrim(number_format((float) $line->charge_weight, 3), '0'), '.') }} - {{ $comparison['settlement_weight'] === null ? '' : round($comparison['settlement_weight'], 4) }} {{ $money($comparison['freight_diff']) }} {{ $comparison['weight_diff'] ?? '' }} {{ $line->unshipped_sources }} diff --git a/resources/views/business/pages/courier-payables/dropship-freight/factory.blade.php b/resources/views/business/pages/courier-payables/dropship-freight/factory.blade.php index d9a9d3091..a9d9a4d20 100644 --- a/resources/views/business/pages/courier-payables/dropship-freight/factory.blade.php +++ b/resources/views/business/pages/courier-payables/dropship-freight/factory.blade.php @@ -70,8 +70,8 @@ $feedbackPageFor = function (string $waybill) use ($dfCurrentDisputes): int {

运费差 = 厂家运费 − 最终结算运费;重量差 = 厂家重量 − 结算重量(公斤)。按厂家较低运费结算时,结算重量也取厂家重量;厂家未提供重量则留空。上方差异原因仍按原核算值识别。

逐单核算明细

-
-@forelse($dfLines as $r)@foreach(['bill_weight','charge_weight','settlement_weight','weight_diff'] as $weightKey)@endforeach@empty@endforelse +
快递单号发货 / 快递厂家重量(kg)我方计费重量(kg)结算重量(kg)重量差(kg)厂家运费我方核算最终结算运费差分类 / 说明厂家反馈
{{ $r['waybill'] }}{{ $r['ship_time'] }}
{{ $r['express'] }}
{{ $r[$weightKey]===null?'—':rtrim(rtrim(number_format($r[$weightKey],4,'.',''),'0'),'.') }}{{ $money($r['bill']) }}{{ $money($r['calc']) }}{{ $money($r['final']??$r['settle']) }}{{ $money($r['freight_diff']) }}{{ $r['label'] }}@if($r['diff_kind'])
{{ ['weight_diff'=>'重量差','price_diff'=>'价格差','missing_weight'=>'重量待补充'][$r['diff_kind']] }}
@endif
{{ $r['note'] }}
@if(isset($dfDisputeMap[$r['waybill']])){{ isset($dfDisputeMap[$r['waybill']]['decision'])?'查看处理':'待处理异议' }}@else—@endif
当前筛选没有明细。
+@forelse($dfLines as $r)@foreach(['bill_weight','charge_weight','weight_diff'] as $weightKey)@endforeach@empty@endforelse
快递单号发货 / 快递厂家重量(kg)我方计费重量(kg)重量差(kg)厂家运费我方核算结算重量(kg)最终结算运费差分类 / 说明厂家反馈
{{ $r['waybill'] }}{{ $r['ship_time'] }}
{{ $r['express'] }}
{{ $r[$weightKey]===null?'—':rtrim(rtrim(number_format($r[$weightKey],4,'.',''),'0'),'.') }}{{ $money($r['bill']) }}{{ $money($r['calc']) }}{{ $r['settlement_weight']===null?'—':rtrim(rtrim(number_format($r['settlement_weight'],4,'.',''),'0'),'.') }}{{ $money($r['final']??$r['settle']) }}{{ $money($r['freight_diff']) }}{{ $r['label'] }}@if($r['diff_kind'])
{{ ['weight_diff'=>'重量差','price_diff'=>'价格差','missing_weight'=>'重量待补充'][$r['diff_kind']] }}
@endif
{{ $r['note'] }}
@if(isset($dfDisputeMap[$r['waybill']])){{ isset($dfDisputeMap[$r['waybill']]['decision'])?'查看处理':'待处理异议' }}@else—@endif
当前筛选没有明细。
{{ $dfLines->links() }}
@if(($dfSurchargeSummary??collect())->isNotEmpty())

附加费核对

@foreach($dfSurchargeSummary as $fee)@endforeach
项目厂家金额自算金额
{{ $fee->item }}{{ $money($fee->bill) }}{{ $money($fee->self) }}
@endif @include('business.pages.courier-payables.partials.surcharge-matches',['surchargeRows'=>$dfSurchargeRows??null]) diff --git a/tests/Feature/Business/CourierSettlementRulesTest.php b/tests/Feature/Business/CourierSettlementRulesTest.php index fc2cb02dd..5f8c8095f 100644 --- a/tests/Feature/Business/CourierSettlementRulesTest.php +++ b/tests/Feature/Business/CourierSettlementRulesTest.php @@ -141,7 +141,8 @@ class CourierSettlementRulesTest extends FeatureTestCase try { $book=IOFactory::load($path);$grid=$book->getSheetByName('对账')->toArray(null,false,false);$headers=$grid[0]; $calcCol=array_search('核算运费',$headers,true);$settleCol=array_search('结算运费',$headers,true); - $this->assertSame($calcCol+1,$settleCol);$this->assertEquals(10,$grid[1][$settleCol]); + $this->assertSame('结算重量',$headers[$calcCol+1]); + $this->assertSame($calcCol+2,$settleCol);$this->assertEquals(10,$grid[1][$settleCol]); $this->assertSame(1,count(array_filter($headers,fn($h)=>$h==='结算运费')));$book->disconnectWorksheets(); } finally {@unlink($path);} } diff --git a/tests/Feature/Business/DropshipFreightTest.php b/tests/Feature/Business/DropshipFreightTest.php index a80723749..4ce489f0e 100644 --- a/tests/Feature/Business/DropshipFreightTest.php +++ b/tests/Feature/Business/DropshipFreightTest.php @@ -180,14 +180,14 @@ final class DropshipFreightTest extends FeatureTestCase $this->assertSame('卿德客申通', $row[1]); $this->assertEquals(6, $row[2]); $this->assertSame('一致但运费有差', $row[count($row) - 2]); - // 核算运费后面是最终结算运费;运费差 = 厂家运费 − 最终结算运费 + // 核算运费、结算重量、最终结算运费依次相邻;运费差 = 厂家运费 − 最终结算运费 $head = $recon[0]; $at = array_search('核算运费', $head, true); - $this->assertSame('最终结算运费', $head[$at + 1]); + $this->assertSame(['结算重量', '最终结算运费'], array_slice($head, $at + 1, 2)); $under = collect($recon)->first(fn ($r) => $r[0] === '773444000003'); // 厂家 5、核算 6 → 按 5 结,运费差 0 - $this->assertEquals([6, 5], [$under[$at], $under[$at + 1]]); + $this->assertEquals([6, 5], [$under[$at], $under[$at + 2]]); $this->assertEquals(0, $under[array_search('运费差', $head, true)]); - $this->assertEquals([5, 5, 1], [$row[$at], $row[$at + 1], $row[array_search('运费差', $head, true)]]); // 厂家 6、核算 5:多开 1 + $this->assertEquals([5, 5, 1], [$row[$at], $row[$at + 2], $row[array_search('运费差', $head, true)]]); // 厂家 6、核算 5:多开 1 $swapRow = collect($recon)->first(fn ($r) => $r[0] === 'OLD0000001'); $this->assertSame('773444000020', $swapRow[6]); $sheet = $book->getSheetByName('汇总');