CaiWuXiTong/tests/Unit/EcommerceFinance/PlantingReimbursementBatchesTest.php

39 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Tests\Unit\EcommerceFinance;
use Modules\EcommerceFinance\Services\PlantingReimbursementBatches as Batches;
use PHPUnit\Framework\TestCase;
class PlantingReimbursementBatchesTest extends TestCase
{
public function test_operations_follow_manual_order_and_track_progress(): void
{
$batch = ['rows' => [
['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']);
}
}