fix: 同步保留旧明细时保持确认目的地 (#1654)

This commit is contained in:
limeng 2026-12-02 14:49:16 +08:00
parent dedb8b7f0e
commit 344c911a11
2 changed files with 9 additions and 0 deletions

View File

@ -3593,6 +3593,7 @@ class ShippingReplicaSynchronizer
/** 因商品/金额无法安全替换而保留的旧包裹:包裹级字段(省市区、快递、仓库、店铺等)仍按本次上游刷新,商品与金额不动。 */
private function refreshRetainedPackages(array $refresh, array $previous): void
{
$refresh = app(ShippingWeightPrecision::class)->shipmentRows($refresh);
foreach ($refresh as $id => $new) {
$set = [];
foreach (self::REFRESHED_PACKAGE_FIELDS as $field) {

View File

@ -49,6 +49,14 @@ class ShippingWeightPrecisionTest extends FeatureTestCase
$this->assertSame('江苏',$rows[0]['receiver_state']);
$this->assertNull($rows[2]['online_weight']);
$this->assertArrayNotHasKey('receiver_state',$rows[2]);
$db->table('jst_oms_shipping')->insert(['source_id'=>1,'sku_source_id'=>1,'express_no'=>'TEST10001',
'express_name1'=>'测试快递','ship_time'=>'2026-11-30','receiver_state'=>'旧省']);
$factory=$this->createMock(UpstreamReadOnlyQueryFactory::class);
$factory->method('forSource')->willReturn($this->createMock(UpstreamReadOnlyQuery::class));
$sync=new ShippingReplicaSynchronizer($factory);
$method=new \ReflectionMethod($sync,'refreshRetainedPackages');
$method->invoke($sync,[1=>array_replace($base,['receiver_state'=>'错误省'])],[]);
$this->assertSame('江苏',$db->table('jst_oms_shipping')->where('source_id',1)->value('receiver_state'));
}
public function test_alignment_keeps_confirmed_tiny_weight_on_the_primary_row(): void