修复一些错误
This commit is contained in:
@@ -257,4 +257,68 @@ class StoreOrderTest extends ProcurementTestCase
|
||||
$this->deleteJson("/order/store/{$order->id}")->assertOk()->assertJsonPath('success', true);
|
||||
$this->deleteJson("/order/store/{$order->id}")->assertJsonPath('success', false);
|
||||
}
|
||||
|
||||
/** 手动流转:仅保留接单与取消(待接单 → 已接单/已取消) */
|
||||
public function test_manual_status_flow_only_accept_and_cancel(): void
|
||||
{
|
||||
$order = $this->makeOrderWithStatus(StoreOrderModel::STATUS_PENDING);
|
||||
$this->actingAsSysUser();
|
||||
|
||||
$this->putJson("/order/store/{$order->id}/status", ['status' => StoreOrderModel::STATUS_SUMMARIZED])
|
||||
->assertJsonPath('success', true);
|
||||
$this->assertSame(StoreOrderModel::STATUS_SUMMARIZED, $order->fresh()->status);
|
||||
|
||||
$order2 = $this->makeOrderWithStatus(StoreOrderModel::STATUS_PENDING);
|
||||
$this->actingAsSysUser();
|
||||
$this->putJson("/order/store/{$order2->id}/status", ['status' => StoreOrderModel::STATUS_CANCELLED])
|
||||
->assertJsonPath('success', true);
|
||||
$this->assertSame(StoreOrderModel::STATUS_CANCELLED, $order2->fresh()->status);
|
||||
}
|
||||
|
||||
/** 手动流转:配送中/已完成等目标状态被拒绝(由采购/账单链路自动推进) */
|
||||
public function test_manual_status_flow_rejects_delivery_and_completion(): void
|
||||
{
|
||||
foreach ([StoreOrderModel::STATUS_DISTRIBUTION, StoreOrderModel::STATUS_COMPLETED] as $target) {
|
||||
$order = $this->makeOrderWithStatus(StoreOrderModel::STATUS_DELIVERING);
|
||||
$this->actingAsSysUser();
|
||||
$this->putJson("/order/store/{$order->id}/status", ['status' => $target])
|
||||
->assertJsonPath('success', false);
|
||||
$this->assertSame(StoreOrderModel::STATUS_DELIVERING, $order->fresh()->status);
|
||||
}
|
||||
|
||||
// 已接单不能手动转采购中(须经生成采购单)
|
||||
$order = $this->makeOrderWithStatus(StoreOrderModel::STATUS_SUMMARIZED);
|
||||
$this->actingAsSysUser();
|
||||
$this->putJson("/order/store/{$order->id}/status", ['status' => StoreOrderModel::STATUS_DELIVERING])
|
||||
->assertJsonPath('success', false);
|
||||
}
|
||||
|
||||
/** 批量流转:仅接单/取消可选,配送/完成目标整批校验拒绝 */
|
||||
public function test_batch_status_only_accept_and_cancel(): void
|
||||
{
|
||||
$pending1 = $this->makeOrderWithStatus(StoreOrderModel::STATUS_PENDING);
|
||||
$pending2 = $this->makeOrderWithStatus(StoreOrderModel::STATUS_PENDING);
|
||||
$this->actingAsSysUser();
|
||||
|
||||
// 批量接单
|
||||
$this->putJson('/order/store/batchStatus', [
|
||||
'ids' => [$pending1->id, $pending2->id],
|
||||
'status' => StoreOrderModel::STATUS_SUMMARIZED,
|
||||
])->assertJsonPath('success', true);
|
||||
$this->assertSame(StoreOrderModel::STATUS_SUMMARIZED, $pending1->fresh()->status);
|
||||
$this->assertSame(StoreOrderModel::STATUS_SUMMARIZED, $pending2->fresh()->status);
|
||||
|
||||
// 批量完成被拒绝(目标状态校验拦截)
|
||||
$this->putJson('/order/store/batchStatus', [
|
||||
'ids' => [$pending1->id],
|
||||
'status' => StoreOrderModel::STATUS_COMPLETED,
|
||||
])->assertJsonPath('success', false);
|
||||
|
||||
// 已接单订单不可批量取消(仅待接单可取消),整批中止
|
||||
$this->putJson('/order/store/batchStatus', [
|
||||
'ids' => [$pending1->id],
|
||||
'status' => StoreOrderModel::STATUS_CANCELLED,
|
||||
])->assertJsonPath('success', false);
|
||||
$this->assertSame(StoreOrderModel::STATUS_SUMMARIZED, $pending1->fresh()->status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user