默认重量

This commit is contained in:
liu
2026-09-05 14:37:22 +08:00
parent 364471a086
commit 12cbed411b
10 changed files with 205 additions and 8 deletions
+34
View File
@@ -72,6 +72,40 @@ class StoreOrderTest extends ProcurementTestCase
$this->assertSame('10.00', (string) $order->total_amount, '应按等级价 5.00×2 计算,忽略前端金额');
}
/** 下单预填参考重量 = 订货量 × 规格折算(按重量计价的商品订货量即重量),订单总重量 = 明细合计 */
public function test_place_order_prefills_reference_weight(): void
{
$level = CustomerLevelModel::factory()->create();
$store = StoreModel::factory()->create(['level_id' => $level->id]);
$byBox = ProductModel::factory()->create([
'status' => ProductModel::STATUS_ON,
'cost_price' => '5.00',
'spec' => '10斤/箱',
'unit' => '箱',
]);
$byJin = ProductModel::factory()->create([
'status' => ProductModel::STATUS_ON,
'cost_price' => '5.00',
'spec' => '散装',
'unit' => '斤',
]);
$this->actingAsMiniStore($store);
$this->postJson('/mini/order', [
'items' => [
['product_id' => $byBox->id, 'quantity' => 3],
['product_id' => $byJin->id, 'quantity' => 5],
],
])->assertOk()->assertJsonPath('success', true);
$order = StoreOrderModel::where('store_id', $store->id)->first();
$boxItem = $order->items->firstWhere('product_id', $byBox->id);
$jinItem = $order->items->firstWhere('product_id', $byJin->id);
$this->assertSame('30.000', (string) $boxItem->weight, '3 箱 × 10斤/箱');
$this->assertSame('5.000', (string) $jinItem->weight, '按斤计价:订货量即重量');
$this->assertSame('35.000', (string) $order->total_weight, '订单总重量 = 明细参考重量合计');
}
/** 门店绑定的客户等级被删除时拒绝下单 */
public function test_store_level_missing_rejected(): void
{