修复一些错误

This commit is contained in:
liu
2026-08-14 22:20:13 +08:00
parent 228212f8e3
commit 4bdaf2a219
12 changed files with 454 additions and 37 deletions
+45
View File
@@ -8,6 +8,7 @@ use App\Models\ProductPriceModel;
use App\Models\StoreModel;
use App\Models\StoreOrderModel;
use App\Models\UserModel;
use Modules\SystemTool\Models\SysFileModel;
/**
* 小程序下单:等级价快照、服务端重算总价、取消限制、门店数据隔离
@@ -321,4 +322,48 @@ class StoreOrderTest extends ProcurementTestCase
])->assertJsonPath('success', false);
$this->assertSame(StoreOrderModel::STATUS_SUMMARIZED, $pending1->fresh()->status);
}
/** 订单列表商品预览:附带首图/规格/单位供小程序端展示 */
public function test_order_list_preview_includes_image_spec_and_unit(): void
{
$file = SysFileModel::create([
'group_id' => 1,
'disk' => 'local',
'channel' => 10,
'file_type' => 10,
'file_name' => '白菜.jpg',
'file_path' => 'product/baicai.jpg',
'file_size' => 1024,
'file_ext' => 'jpg',
'uploader_id' => 1,
]);
$level = CustomerLevelModel::factory()->create();
$store = StoreModel::factory()->create(['level_id' => $level->id]);
$product = ProductModel::factory()->create([
'status' => ProductModel::STATUS_ON,
'spec' => '30斤/筐',
'unit' => '筐',
'image_ids' => (string) $file->id,
]);
ProductPriceModel::factory()->create([
'product_id' => $product->id,
'level_id' => $level->id,
'price' => '5.00',
]);
$user = UserModel::factory()->forStore($store->id)->create();
$this->actingAsMiniUser($user);
$this->postJson('/mini/order', ['items' => [['product_id' => $product->id, 'quantity' => 2]]])
->assertJsonPath('success', true);
$rows = $this->getJson('/mini/order')->assertOk()->json('data.data');
$preview = $rows[0]['items'][0];
$this->assertSame($product->name, $preview['product_name']);
$this->assertSame('30斤/筐', $preview['product_spec'], '预览附规格');
$this->assertSame('筐', $preview['unit'], '预览附单位');
$this->assertStringContainsString('baicai.jpg', (string) $preview['image'], '预览附首图URL');
$this->assertArrayNotHasKey('image_ids', $preview, 'image_ids 解析后不输出');
}
}