diff --git a/modules/EcommerceFinance/Repositories/ProductCatalogMirrorRepository.php b/modules/EcommerceFinance/Repositories/ProductCatalogMirrorRepository.php index 27bbe8f6..e91cfd4f 100644 --- a/modules/EcommerceFinance/Repositories/ProductCatalogMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/ProductCatalogMirrorRepository.php @@ -128,6 +128,7 @@ class ProductCatalogMirrorRepository ->get() ->all(); + $this->attachPhysicalFields($rows); $purchasePriceSyncStatus = $this->purchasePriceSyncStatus(); $this->attachPurchasePrices($rows, $purchasePriceSyncStatus['initialized']); $priceChangeSyncStatus = $this->priceChangeSyncStatus(); @@ -175,6 +176,7 @@ class ProductCatalogMirrorRepository } $this->attachPurchasePrices($rows, $purchasePriceSyncStatus['initialized']); + $this->attachPhysicalFields($rows); $this->attachPriceChanges($rows, $priceChangeSyncStatus['initialized']); $this->attachWorkPlatformPrices($rows, $workPlatformPriceSyncStatus['initialized']); foreach ($rows as $row) { @@ -188,6 +190,21 @@ class ProductCatalogMirrorRepository } } + /** @param list $rows */ + private function attachPhysicalFields(array $rows): void + { + foreach ($rows as $row) { + $row->board_material = $row->other_2 ?? null; + $row->product_type = $row->item_type ?? null; + $row->creator_id = $row->creator ?? null; + + $dimensions = [$row->l ?? null, $row->w ?? null, $row->h ?? null]; + $row->volume = in_array(null, $dimensions, true) + ? null + : (float) $dimensions[0] * (float) $dimensions[1] * (float) $dimensions[2]; + } + } + /** @param list $rows */ private function attachPurchasePrices(array $rows, bool $initialized): void { @@ -473,6 +490,14 @@ class ProductCatalogMirrorRepository 'brand', 'category', 'supplier_name', + 'weight', + 'l', + 'w', + 'h', + 'unit', + 'other_2', + 'item_type', + 'creator', 'enabled', 'stock_disabled', 'modified', diff --git a/resources/views/business/pages/product-inventory/normal-products.blade.php b/resources/views/business/pages/product-inventory/normal-products.blade.php index e0c8d91f..a3e4bb70 100644 --- a/resources/views/business/pages/product-inventory/normal-products.blade.php +++ b/resources/views/business/pages/product-inventory/normal-products.blade.php @@ -230,7 +230,7 @@ .product-catalog-table { width: 100%; - min-width: 2620px; + min-width: 3180px; border-collapse: collapse; font-size: 0.78125rem; } @@ -570,6 +570,15 @@ 变价时间 数据来源 市场价 + 重量(kg) + 长(cm) + 宽(cm) + 高(cm) + 体积(cm³) + 单位 + 板材 + 类型 + 创建人 商品状态 库存同步 业务更新时间 @@ -620,6 +629,13 @@ @endforelse {{ isset($row->market_price) && $row->market_price !== null ? number_format((float) $row->market_price, 2) : '-' }} + @foreach (['weight', 'l', 'w', 'h', 'volume'] as $physicalField) + {{ isset($row->{$physicalField}) && $row->{$physicalField} !== null ? number_format((float) $row->{$physicalField}, 2) : '-' }} + @endforeach + {{ $row->unit ?? '-' }} + {{ $row->board_material ?? '-' }} + {{ $row->product_type ?? '-' }} + {{ $row->creator_id ?? '-' }} {{ $enabledLabel }} @@ -634,7 +650,7 @@ @empty - + @if ($productCatalogError) 数据暂时不可用。 diff --git a/tests/Feature/Business/ProductCatalogPageTest.php b/tests/Feature/Business/ProductCatalogPageTest.php index 4404d520..7adf0419 100644 --- a/tests/Feature/Business/ProductCatalogPageTest.php +++ b/tests/Feature/Business/ProductCatalogPageTest.php @@ -73,6 +73,15 @@ class ProductCatalogPageTest extends FeatureTestCase 'brand' => '北木', 'category' => '住宅家具', 'supplier_name' => '新北供应商', + 'weight' => 4.32, + 'l' => 49, + 'w' => 18.5, + 'h' => 10.5, + 'volume' => 9518.25, + 'unit' => '个', + 'board_material' => '正常板材', + 'product_type' => '成品', + 'creator_id' => 19203883, 'enabled' => 1, 'stock_disabled' => 0, 'modified' => '2026-08-15 10:00:00', @@ -140,6 +149,15 @@ class ProductCatalogPageTest extends FeatureTestCase ->assertDontSeeText('工作平台价格尚未完成首次同步') ->assertDontSeeText('商品价格变价记录尚未完成首次同步') ->assertSeeText('正常同步') + ->assertSeeText('重量(kg)') + ->assertSeeText('4.32') + ->assertSeeText('长(cm)') + ->assertSeeText('49.00') + ->assertSeeText('体积(cm³)') + ->assertSeeText('9,518.25') + ->assertSeeText('正常板材') + ->assertSeeText('成品') + ->assertSeeText('19203883') ->assertDontSee('pic_url'); } diff --git a/tests/Unit/EcommerceFinance/ProductCatalogMirrorRepositoryTest.php b/tests/Unit/EcommerceFinance/ProductCatalogMirrorRepositoryTest.php index 83bb58cd..b5b8186d 100644 --- a/tests/Unit/EcommerceFinance/ProductCatalogMirrorRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/ProductCatalogMirrorRepositoryTest.php @@ -117,6 +117,47 @@ class ProductCatalogMirrorRepositoryTest extends TestCase $this->assertObjectNotHasProperty('pic_url', $result['data'][0]); } + public function test_it_exposes_physical_and_management_fields_and_calculates_volume(): void + { + $this->markReady(1); + $this->insertProduct(1, [ + 'weight' => 4.32, + 'l' => 49, + 'w' => 18.5, + 'h' => 10.5, + 'unit' => '个', + 'other_2' => '正常板材', + 'item_type' => '成品', + 'creator' => 19203883, + ]); + + $row = $this->repository->paginate($this->filters(), 1, 25)['data'][0]; + + $this->assertSame('4.32', (string) $row->weight); + $this->assertSame('49', (string) $row->l); + $this->assertSame('18.5', (string) $row->w); + $this->assertSame('10.5', (string) $row->h); + $this->assertSame('9518.25', (string) $row->volume); + $this->assertSame('个', $row->unit); + $this->assertSame('正常板材', $row->board_material); + $this->assertSame('成品', $row->product_type); + $this->assertSame(19203883, (int) $row->creator_id); + } + + public function test_it_keeps_volume_empty_when_any_dimension_is_missing(): void + { + $this->markReady(1); + $this->insertProduct(1, [ + 'l' => 49, + 'w' => 18.5, + 'h' => null, + ]); + + $row = $this->repository->paginate($this->filters(), 1, 25)['data'][0]; + + $this->assertNull($row->volume); + } + public function test_it_attaches_the_latest_finished_1688_drop_shipping_price_without_overwriting_product_price(): void { $this->markReady(1); @@ -444,6 +485,14 @@ class ProductCatalogMirrorRepositoryTest extends TestCase $table->text('brand')->nullable(); $table->text('category')->nullable(); $table->text('supplier_name')->nullable(); + $table->decimal('weight', 18, 2)->nullable(); + $table->decimal('l', 18, 2)->nullable(); + $table->decimal('w', 18, 2)->nullable(); + $table->decimal('h', 18, 2)->nullable(); + $table->string('unit')->nullable(); + $table->text('other_2')->nullable(); + $table->string('item_type')->nullable(); + $table->integer('creator')->nullable(); $table->integer('enabled')->nullable(); $table->integer('stock_disabled')->nullable(); $table->dateTime('modified')->nullable(); @@ -587,6 +636,14 @@ class ProductCatalogMirrorRepositoryTest extends TestCase 'brand' => '测试品牌', 'category' => '测试类目', 'supplier_name' => '测试供应商', + 'weight' => null, + 'l' => null, + 'w' => null, + 'h' => null, + 'unit' => null, + 'other_2' => null, + 'item_type' => null, + 'creator' => null, 'enabled' => 1, 'stock_disabled' => 0, 'modified' => '2026-08-15 10:00:00', @@ -647,6 +704,14 @@ class ProductCatalogMirrorRepositoryTest extends TestCase ['brand', 'nvarchar', 100], ['category', 'nvarchar', 100], ['supplier_name', 'nvarchar', 255], + ['weight', 'decimal', null], + ['l', 'decimal', null], + ['w', 'decimal', null], + ['h', 'decimal', null], + ['unit', 'nvarchar', 50], + ['other_2', 'nvarchar', 255], + ['item_type', 'nvarchar', 50], + ['creator', 'int', null], ['enabled', 'int', null], ['stock_disabled', 'int', null], ['modified', 'datetime', null],