From 63a369152ef7e2354e1c1556a7e1363db7935481 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 14:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E8=B4=A7=E6=95=B0=E6=8D=AE=E8=BF=90?= =?UTF-8?q?=E8=B4=B9=EF=BC=9A=E6=96=B0=E5=A2=9E=E6=B7=BC=E7=BC=98=E9=9F=B5?= =?UTF-8?q?=E8=BE=BE=E3=80=81=E9=9B=84=E9=83=A8=E8=90=BD=E9=9F=B5=E8=BE=BE?= =?UTF-8?q?=E3=80=81=E5=B8=9D=E5=AF=8C=E5=B0=BC=E9=A1=BA=E4=B8=B0=E5=BF=AB?= =?UTF-8?q?=E8=BF=90/=E5=B9=B2=E9=85=8D=E3=80=81=E8=8E=B2=E5=BC=BA?= =?UTF-8?q?=E9=A1=BA=E4=B8=B0=E5=B9=B2=E9=85=8D/=E9=9F=B5=E8=BE=BE=20?= =?UTF-8?q?=E7=9A=84=E8=AE=A1=E8=B4=B9=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户 2026-12-01 在报价管理新增这几家报价,核算状态为「计费方式未配置」,核算运费为空。 - 淼缘韵达:同淼缘中通快运版式(MY),整省文字「面单5+10/kg」也能算 - 雄部落韵达:1-10kg 整公斤段一口价,以上 首重+(重量-1)×费率;计泡 9000;北京+1、上海+0.9/票 - 帝富尼顺丰快运/干配:首重20kg+(重量-20)×费率(第一档);计泡 12000 - 莲强顺丰干配/韵达:首重10kg+(重量-10)×费率;不计泡 11 月真实包裹试算:帝富尼 33/33、淼缘韵达 21/21、莲强 5/6(1 单在报价里是偏远不发货)。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UNTa9mVziToe5w52mmrrar --- .../Services/Freight/FreightCarrierRules.php | 34 +++++++++++++ .../Freight/ShippingFreightCalculator.php | 8 ++- .../ShippingFreightCalculatorTest.php | 51 +++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/modules/EcommerceFinance/Services/Freight/FreightCarrierRules.php b/modules/EcommerceFinance/Services/Freight/FreightCarrierRules.php index a57412c1..0dc9a458 100644 --- a/modules/EcommerceFinance/Services/Freight/FreightCarrierRules.php +++ b/modules/EcommerceFinance/Services/Freight/FreightCarrierRules.php @@ -286,6 +286,40 @@ final class FreightCarrierRules 'mode' => 'MY', 'coef' => null, ], + // 2026-12-01 新增报价:淼缘韵达和淼缘中通快运同一版式(0-1/1.01-3/3.01-5kg 一口价,5.01-10、10.01-30kg 面单+元/kg),不计泡 + '淼缘韵达' => [ + 'mode' => 'MY', + 'coef' => null, + ], + // 雄部落韵达:1-10kg 按整公斤段一口价;10kg 以上 首重(1kg)+(重量-1)×费率;计泡 9000;北京+1 元/票、上海+0.9 元/票(深圳+0.9 按城市,系统暂不加) + '雄部落韵达' => [ + 'mode' => 'B6C', + 'coef' => 9000, + 'flat_max' => 10, + 'remote_add' => ['北京' => 1, '上海' => 0.9], + ], + // 帝富尼顺丰快运/干配:面单(首重20kg)+(重量-20)×费率;计泡 12000;报价有两档(月量5万-10万/10万以上),按第一档 + '帝富尼顺丰快运' => [ + 'mode' => 'C', + 'first' => 20, + 'coef' => 12000, + ], + '帝富尼顺丰干配' => [ + 'mode' => 'C', + 'first' => 20, + 'coef' => 12000, + ], + // 莲强顺丰干配/韵达:首重10kg+(重量-10)×费率;报价没写计泡,不计泡 + '莲强顺丰干配' => [ + 'mode' => 'C', + 'first' => 10, + 'coef' => null, + ], + '莲强韵达' => [ + 'mode' => 'C', + 'first' => 10, + 'coef' => null, + ], '迈当极兔' => [ 'mode' => 'MDJT', 'coef' => 8000, diff --git a/modules/EcommerceFinance/Services/Freight/ShippingFreightCalculator.php b/modules/EcommerceFinance/Services/Freight/ShippingFreightCalculator.php index e6eec7b0..48826fa5 100644 --- a/modules/EcommerceFinance/Services/Freight/ShippingFreightCalculator.php +++ b/modules/EcommerceFinance/Services/Freight/ShippingFreightCalculator.php @@ -533,6 +533,11 @@ final class ShippingFreightCalculator [$fee, $F, $w] = [$r['fee'], $r['F'], $r['w']]; break; case 'MY': + // 整省写成文字「面单5+10/kg」(如淼缘韵达 海南):面单 + 元/kg × 重量 + if (preg_match('/面单\s*([\d.]+)\s*\+\s*([\d.]+)\s*元?\s*\/\s*(kg|公斤)/iu', QuoteSheet::text($g(2)), $mt)) { + [$fee, $F] = $lin((float) $mt[1], (float) $mt[2], $w); + break; + } if ($w <= 1) { [$v, $seg] = [$g(2), '0-1kg']; } elseif ($w <= 3) { @@ -758,7 +763,8 @@ final class ShippingFreightCalculator $F = "{$f($w)}kg落在{$seg}段,一口价{$f($v)}"; } else { $a = $g($col(['首重'])); - $b = $g($col(['续重'])); + // 续重列:叫「续重」;没有就认「…以上费率」这类费率列(如雄部落韵达「10.01KG以上费率」) + $b = $g($col(['续重']) ?? $col(['费率'], ['首重'])); if (! $need($a, $b)) { return $bad('报价单元格无数值(' . self::show($a) . ',' . self::show($b) . ')'); } diff --git a/tests/Unit/EcommerceFinance/ShippingFreightCalculatorTest.php b/tests/Unit/EcommerceFinance/ShippingFreightCalculatorTest.php index 8742a394..1f65df18 100644 --- a/tests/Unit/EcommerceFinance/ShippingFreightCalculatorTest.php +++ b/tests/Unit/EcommerceFinance/ShippingFreightCalculatorTest.php @@ -205,4 +205,55 @@ class ShippingFreightCalculatorTest extends TestCase $this->assertSame('JDCITY', FreightCarrierRules::for($name)['mode'], $name); } } + + public function test_new_quotes_added_on_2026_12_01(): void + { + $calc = new ShippingFreightCalculator(); + $pkg = fn (string $name, string $state, float $w, array $over = []) => $this->pkg($over + ['express_name1' => $name, 'receiver_state' => $state, + 'online_weight' => $w, 'weight_kg' => null, 'length_cm' => null, 'width_cm' => null, 'height_cm' => null]); + + // 淼缘韵达:和淼缘中通快运同版式;海南写成「面单5+10/kg」 + $my = $this->quote([ + ['省份', null, '0-1kg', '1.01-3kg', '3.01-5kg', '5.01-10kg', null, '10.01-30kg', null, '备注'], + [null, null, '一口价', '一口价', '一口价', '面单费', '元/kg', '面单费', '元/kg'], + ['湖北', null, 3, 5, 10.5, 4, 2, 5, 2], + ['海南', null, '面单5+10/kg'], + ]); + $cfg = $this->cfg('淼缘韵达'); + $this->assertSame(10.5, $calc->calculate($pkg('淼缘韵达', '湖北省', 4.5), $my, $cfg)['fee']); + $this->assertSame(18.0, $calc->calculate($pkg('淼缘韵达', '湖北省', 7), $my, $cfg)['fee']); + $r = $calc->calculate($pkg('淼缘韵达', '海南省', 3), $my, $cfg); + $this->assertSame(['OK', 35.0], [$r['status'], $r['fee']]); + + // 雄部落韵达:1-10kg 整公斤段一口价,10kg 以上 首重+(重量-1)×费率;计泡 9000;北京每票+1 + $xbl = $this->quote([ + ['省份', '1KG', '2KG', '3KG', '4KG', '5KG', '6KG', '7KG', '8KG', '9KG', '10KG', '10.01KG以上费率', '首重/1KG', '备注'], + ['广东', 3, 4, 4.8, 7, 8, 9, 10, 11, 12, 13, 1, 4, null], + ['北京', 3, 4, 4.8, 9, 10.5, 12, 13.5, 15, 16.5, 18, 1.5, 4.5, null], + ]); + $cfg = $this->cfg('雄部落韵达'); + $this->assertSame(4.8, $calc->calculate($pkg('雄部落韵达', '广东省', 2.3), $xbl, $cfg)['fee']); + $this->assertSame(15.3, $calc->calculate($pkg('雄部落韵达', '广东省', 12.3), $xbl, $cfg)['fee']); + $this->assertSame(5.0, $calc->calculate($pkg('雄部落韵达', '北京', 2), $xbl, $cfg)['fee']); + $r = $calc->calculate($pkg('雄部落韵达', '广东省', 2, ['length_cm' => 60, 'width_cm' => 50, 'height_cm' => 30]), $xbl, $cfg); + $this->assertSame([10.0, 13.0], [$r['settle_w'], $r['fee']]); // 60×50×30÷9000 = 10kg + + // 帝富尼顺丰:首重20kg + (重量-20)×费率,按第一档;计泡 12000 + $dfn = $this->quote([ + ['公斤段', '20kg+(5万-10万区间)', null, '20kg+(10万以上区间)', null, '备注'], + ['省份', '首重', '费率', '首重', '费率'], + ['江苏', 43, 2.01, 42, 1.91], + ]); + foreach (['帝富尼顺丰快运', '帝富尼顺丰干配'] as $name) { + $this->assertSame(43.0, $calc->calculate($pkg($name, '江苏省', 15), $dfn, $this->cfg($name))['fee']); + $this->assertSame(74.16, $calc->calculate($pkg($name, '江苏省', 35.5), $dfn, $this->cfg($name))['fee']); + } + + // 莲强:首重10kg + (重量-10)×费率,不计泡 + $lq = $this->quote([['省份', '首重10kg', '费率', '备注'], ['河北', 26.5, 2.2, null]]); + foreach (['莲强顺丰干配', '莲强韵达'] as $name) { + $this->assertSame(26.5, $calc->calculate($pkg($name, '河北省', 8, ['length_cm' => 100, 'width_cm' => 100, 'height_cm' => 100]), $lq, $this->cfg($name))['fee']); + $this->assertSame(55.1, $calc->calculate($pkg($name, '河北省', 23), $lq, $this->cfg($name))['fee']); + } + } } -- 2.47.2