From bf49e033724cd26d0e4faf63c2a9c3eec537f8e1 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Sun, 6 Dec 2026 11:03:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=99=84=E5=8A=A0=E8=B4=B9):=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=98=8E=E7=A1=AE=E9=85=8D=E7=BD=AE=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E6=94=B9=E5=9C=B0=E5=9D=80=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BillSurchargeQuoteCalculator.php | 3 +- .../Business/BillSurchargeMatchingTest.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/Support/CourierBills/BillSurchargeQuoteCalculator.php b/app/Support/CourierBills/BillSurchargeQuoteCalculator.php index 060860ec4..a78c9343f 100644 --- a/app/Support/CourierBills/BillSurchargeQuoteCalculator.php +++ b/app/Support/CourierBills/BillSurchargeQuoteCalculator.php @@ -195,6 +195,7 @@ final class BillSurchargeQuoteCalculator } } elseif (preg_match('/^查件类型\/查件原因是([^\/]+)\/([^\/]+)$/u', $condition, $path)) { $expected = trim($path[1]) . '/' . trim($path[2]); + $allowedReasons = array_map(static fn ($reason) => trim($path[1]) . '/' . trim($reason), explode('或', $path[2])); $candidates = array_filter($orders, static function ($order) use ($rule): bool { $fields = array_column(json_decode($order->businessFieldList, true, 512, JSON_THROW_ON_ERROR) ?: [], 'value', 'fieldId'); return ($fields['logisticsField'] ?? '') === $rule->courier @@ -208,7 +209,7 @@ final class BillSurchargeQuoteCalculator $actual = trim((string) ($fields['SELECT_CASCADEField1413856620250813172526'] ?? '')); if ($actual === '') return '查件工单未填写查件类型和原因,待核实'; $evidence = '聚工单 ' . $latest->woNo . ' 查件类型/原因为“' . $actual . '”'; - if ($actual !== $expected) return [['settlement_amount' => 0, 'evidence' => $evidence . ',不符合报价条件“' . $expected . '”,不计费']]; + if (! in_array($actual, $allowedReasons, true)) return [['settlement_amount' => 0, 'evidence' => $evidence . ',不符合报价条件“' . $expected . '”,不计费']]; $evidence .= ',符合报价条件'; } elseif (in_array($condition, ['聚工单客服回复通过', '改地址客服回复通过'], true)) { $approved = false; diff --git a/tests/Feature/Business/BillSurchargeMatchingTest.php b/tests/Feature/Business/BillSurchargeMatchingTest.php index 4c9c2f983..d60096ac0 100644 --- a/tests/Feature/Business/BillSurchargeMatchingTest.php +++ b/tests/Feature/Business/BillSurchargeMatchingTest.php @@ -544,6 +544,37 @@ class BillSurchargeMatchingTest extends FeatureTestCase $this->assertEquals(20,$rows['SMALL01']->self_amount); } + public function test_fixed_readdress_accepts_each_explicit_reason_at_the_couriers_own_rate(): void + { + $condition='查件类型/查件原因是改地址、电话/本省改地址.电话或跨省改地址,电话'; + $this->quote('测试快递甲','改地址','固定单价','30元/单',$condition,'自有快递'); + $this->quote('测试快递乙','改地址','固定单价','20元/单',$condition,'自有快递'); + $cases=[['LOCAL02','测试快递甲','改地址、电话/本省改地址.电话',30], + ['CROSS02','测试快递甲','改地址、电话/跨省改地址,电话',30], + ['SMALL02','测试快递乙','改地址、电话/跨省改地址,电话',20], + ['OTHER02','测试快递甲','扣单/跨省改地址,电话',0], + ['LATEST02','测试快递甲','改地址、电话/本省改地址.电话',0], + ['CANCEL02','测试快递甲','改地址、电话/跨省改地址,电话',30]]; + $input=[]; + foreach($cases as[$no,$courier,$reason,$amount]){ + $this->ship($no,$courier); + $this->workOrder($no,$courier,'','',null,'2026-11-03',$reason); + $input[]=['waybill_no'=>$no,'item'=>'改地址']; + } + $this->workOrder('CROSS02','测试快递甲','','',null,'2026-11-04','改地址、电话/跨省改地址,电话'); + $this->workOrder('LATEST02','测试快递甲','','',null,'2026-11-04','催件/其他'); + $this->workOrder('CANCEL02','测试快递甲','','',null,'2026-11-04','催件/其他','CANCELLED'); + $this->ship('WRONG02','测试快递甲');$this->ship('MISSING02','测试快递甲'); + $this->workOrder('WRONG02','测试快递乙','','',null,'2026-11-03','改地址、电话/跨省改地址,电话'); + $input[]=['waybill_no'=>'WRONG02','item'=>'改地址'];$input[]=['waybill_no'=>'MISSING02','item'=>'改地址']; + $r=app(\App\Support\CourierBills\BillSurchargeQuoteCalculator::class)->calculate($input,'courier','2026-11',['测试快递甲','测试快递乙']); + foreach($cases as[$no,$courier,$reason,$amount]){ + $this->assertCount(1,$r['rows'][$no]['改地址']); + $this->assertEquals($amount,$r['rows'][$no]['改地址'][0]->settlement_amount); + } + foreach(['WRONG02','MISSING02']as$no)$this->assertStringContainsString('未找到同快递的有效查件工单',$r['notes'][$no]['改地址']); + } + public function test_long_side_wording_is_supported_without_ignoring_additional_conditions(): void { $this->ship('LONG01','曹县德邦其他');$this->ship('EDGE01','曹县德邦其他');