[ ['work_order_no' => 'GD1', 'online_order_no' => '111', 'decision' => 'pass'], ['work_order_no' => 'GD2', 'online_order_no' => '222', 'decision' => 'pass'], ['work_order_no' => 'GD3', 'online_order_no' => '333', 'decision' => 'cancel'], ['work_order_no' => 'GD4', 'online_order_no' => '333', 'decision' => 'recheck'], ]]; // 刚确认:全部还是待处理。 $ops = Batches::operations($batch, ['GD1' => 'WAIT_CONFIRM', 'GD2' => 'WAIT_CONFIRM', 'GD3' => 'WAIT_CONFIRM', 'GD4' => 'WAIT_CONFIRM']); $this->assertSame(['lock', 'cancel', 'paid'], array_keys($ops)); // 锁单是整批(含取消、待复查),线上订单号去重。 $this->assertCount(4, $ops['lock']['items']); $this->assertSame('111,222,333', $ops['lock']['online_orders']); $this->assertSame(['GD3'], array_column($ops['cancel']['items'], 'work_order_no')); $this->assertSame(['GD1', 'GD2'], array_column($ops['paid']['items'], 'work_order_no')); $this->assertSame('待处理', $ops['lock']['items'][0]['status']); // 锁单后取消了 GD3、GD1 已标记打款,GD2 还在处理中。 $ops = Batches::operations($batch, ['GD1' => 'CONFIRMED', 'GD2' => 'CONFIRMING', 'GD3' => 'DISABLED', 'GD4' => 'CONFIRMING']); $this->assertSame(4, $ops['lock']['done_count']); $this->assertSame([], $ops['lock']['pending']); $this->assertSame(1, $ops['cancel']['done_count']); $this->assertSame(1, $ops['paid']['done_count']); $this->assertSame('222', $ops['paid']['online_orders']); $this->assertSame('未同步', Batches::operations($batch, [])['lock']['items'][0]['status']); } }