补齐新增6家快递的报价计费方式 #1601

Merged
limeng merged 1 commits from feature/limeng-freight-six-carriers into main 2026-12-01 14:38:09 +08:00
3 changed files with 92 additions and 1 deletions

View File

@ -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,

View File

@ -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) . ')');
}

View File

@ -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']);
}
}
}