calculate($package + [ 'receiver_state' => '江苏省', 'warehouse_name' => '测试仓', 'actual_weight' => $weight, ], ['id' => 'TEST-QUOTE', 'p' => QuoteSheet::parse($values), 'vals' => $values, 'rules' => ''], FreightCarrierRules::for($name) + ['_name' => $name]); } public function test_henglin_uses_three_kg_first_weight_and_unrounded_volume_weight(): void { $values = [['省份', '首重3kg', '费率1kg', '备注'], ['江苏', 9, 2, '测试数据']]; foreach ([[0.5, 9], [3, 9], [3.25, 9.5], [12, 27]] as [$weight, $fee]) { $r = $this->calculate('横林顺丰干配', $values, $weight); $this->assertSame('OK', $r['status']); $this->assertSame((float) $fee, $r['fee']); } $r = $this->calculate('横林顺丰干配', $values, 1, ['volume_cm3' => 39000]); $this->assertSame(6.5, $r['settle_w']); $this->assertSame(16.0, $r['fee']); $r = $this->calculate('横林顺丰干配', $values, 8, ['measured_weight' => 4]); $this->assertSame('称重重量', $r['base_src']); $this->assertSame(11.0, $r['fee']); $this->assertNull($this->calculate('横林顺丰干配', $values, 0)['fee']); } public function test_yuanwo_uses_flat_bands_then_waybill_plus_rate_and_remote_minimum(): void { $values = [['省份', '0-1kg', '1.01-2kg', '2.01-3kg', '3.01-4kg', '4.01-5kg', '5.01-30kg费率', '面单费', '备注'], [null, '元/票', '元/票', '元/票', '元/票', '元/票', null, null, null], ['江苏', 3, 4, 5, 6, 7, 2, 3, '测试数据'], ['海南', '7元/kg最低收费7元']]; foreach ([[1, 3], [1.001, 4], [2, 4], [3, 5], [4, 6], [5, 7], [5.1, 13.2], [30, 63]] as [$weight, $fee]) { $r = $this->calculate('源沃圆通', $values, $weight); $this->assertSame('OK', $r['status']); $this->assertSame((float) $fee, $r['fee']); } $this->assertNull($this->calculate('源沃圆通', $values, 30.1)['fee']); $r = $this->calculate('源沃圆通', $values, 0.2, ['receiver_state' => '海南省']); $this->assertSame(7.0, $r['fee']); $this->assertStringContainsString('最低收费7', $r['formula']); $this->assertSame(21.0, $this->calculate('源沃圆通', $values, 3, ['receiver_state' => '海南省'])['fee']); $r = $this->calculate('源沃圆通', $values, 1, ['volume_cm3' => 60000]); $this->assertSame(15.0, $r['fee']); } public function test_ems_has_one_price_up_to_one_hundred_kg_and_does_not_price_no_service_regions(): void { $values = [['公斤段', '0-100kg', '备注'], ['省份', '一口价', null], ['江苏', 12, '测试数据'], ['黑龙', 40], ['新疆', '不发'], ['西藏', '不发']]; foreach ([0.5, 100] as $weight) { $r = $this->calculate('飞燕EMS', $values, $weight, ['volume_cm3' => 9000000]); $this->assertSame('OK', $r['status']); $this->assertSame(12.0, $r['fee']); } $this->assertSame(40.0, $this->calculate('飞燕EMS', $values, 10, ['receiver_state' => '黑龙江省'])['fee']); $this->assertNull($this->calculate('飞燕EMS', $values, 100.1)['fee']); $this->assertNull($this->calculate('飞燕EMS', $values, 10, ['receiver_state' => '新疆维吾尔自治区'])['fee']); $this->assertNull($this->calculate('飞燕EMS', $values, 0)['fee']); } }