修复BUG

This commit is contained in:
liu
2026-08-27 14:20:09 +08:00
parent 513cc568a9
commit 52dc6efadf
203 changed files with 576 additions and 1130 deletions
+57
View File
@@ -72,6 +72,63 @@ class BillPaymentTest extends ProcurementTestCase
], $attributes));
}
/** 生成账单:按门店保存售后说明与备注(可选,不参与金额计算) */
public function test_generate_bill_saves_after_sale_and_remark(): void
{
$level = CustomerLevelModel::factory()->create();
$store = StoreModel::factory()->create(['level_id' => $level->id]);
$product = ProductModel::factory()->create(['status' => ProductModel::STATUS_ON, 'cost_price' => '5.00']);
$this->actingAsMiniStore($store);
$this->postJson('/mini/order', ['items' => [['product_id' => $product->id, 'quantity' => 4]]])
->assertJsonPath('success', true);
$order = StoreOrderModel::where('store_id', $store->id)->first();
$this->actingAsSysUser();
$this->putJson("/order/store/{$order->id}/status", ['status' => StoreOrderModel::STATUS_SUMMARIZED]);
$this->postJson('/purchase/order/generate', ['purchase_date' => now()->toDateString()])
->assertJsonPath('success', true);
$purchase = PurchaseOrderModel::first();
$this->putJson("/purchase/order/{$purchase->id}/finish")->assertJsonPath('success', true);
$this->postJson("/purchase/order/{$purchase->id}/bill", [
'stores' => [[
'store_id' => $store->id,
'delivery_fee' => 0,
'box_num' => 0,
'tray_num' => 0,
'after_sale' => '白菜烂叶 2 斤已协商',
'remark' => '下次配送顺带回收筐',
]],
])->assertJsonPath('success', true);
$bill = BillModel::where('store_id', $store->id)->first();
$this->assertSame('白菜烂叶 2 斤已协商', $bill->after_sale);
$this->assertSame('下次配送顺带回收筐', $bill->remark);
$this->assertSame('20.00', (string) $bill->total_amount, '售后/备注不影响金额');
// 不传售后/备注时默认空字符串
$store2 = StoreModel::factory()->create(['level_id' => $level->id]);
$this->actingAsMiniStore($store2);
$this->postJson('/mini/order', ['items' => [['product_id' => $product->id, 'quantity' => 1]]])
->assertJsonPath('success', true);
$order2 = StoreOrderModel::where('store_id', $store2->id)->first();
$this->actingAsSysUser();
$this->putJson("/order/store/{$order2->id}/status", ['status' => StoreOrderModel::STATUS_SUMMARIZED]);
$this->postJson('/purchase/order/generate', ['purchase_date' => now()->toDateString()])
->assertJsonPath('success', true);
$purchase2 = PurchaseOrderModel::latest('id')->first();
$this->putJson("/purchase/order/{$purchase2->id}/finish")->assertJsonPath('success', true);
$this->postJson("/purchase/order/{$purchase2->id}/bill", [
'stores' => [['store_id' => $store2->id, 'delivery_fee' => 0, 'box_num' => 0, 'tray_num' => 0]],
])->assertJsonPath('success', true);
$bill2 = BillModel::where('store_id', $store2->id)->first();
$this->assertSame('', (string) $bill2->after_sale);
$this->assertSame('', (string) $bill2->remark);
}
/** 订单状态随业务链自动推进:接单→采购中→配送中→(生成账单)已完成 */
public function test_order_status_progresses_via_business_chain(): void
{