createMirrorTables(); $this->markReady(ProductCatalogMirrorRepository::DATASET_KEY, 'operations_replica', 'rpt.jst_sku', 'ops_jst_sku'); $this->markReady(SupplierManagementMirrorRepository::DATASET, 'jiansun', 'dbo.js_supplier_View', 'js_supplier_management'); $mirror->table('store_receipt_product_cost_rows')->insert([ 'report_month' => '2026-09-01', 'row_key' => 'attribute-row', 'platform' => '京东账单', 'occurred_date' => '2026-09-01', 'store_name' => '京东-HX旗舰店101', 'online_order_no' => 'ORDER-ATTRIBUTE', 'warehouse' => '简尚-崔桥工厂仓', 'warehouse_short_name' => '崔桥工厂仓', 'product_code' => 'SKU-ATTRIBUTE', 'product_quantity' => 1, 'unit_price' => 10, 'product_cost' => 10, 'remark' => null, 'imported_at' => now(), ]); $mirror->table('ops_jst_sku')->insert([ 'autoid' => 1001, 'sku_id' => 'SKU-ATTRIBUTE', 'sku_type' => 'normal', 'brand' => '测试品牌', 'category' => '测试类目', 'supplier_name' => '测试供应商', 'enabled' => 1, ]); $mirror->table('js_supplier_management')->insert([ 'Id' => 2001, 'scmcode' => 'N2001', 'scmname' => '测试供应商', ]); app(SupplierFreeShippingStore::class)->save( 2001, true, (int) $this->company->id, (int) $this->user->id, ); $response = $this->loginAs()->get(route('business.pages.show', [ 'section' => 'financial-operations', 'page' => 'product-costs', 'month' => '2026-09', ])); $response ->assertOk() ->assertSee('测试品牌') ->assertSee('测试类目') ->assertSee('测试供应商') ->assertSee('包邮'); } private function createMirrorTables(): void { $schema = Schema::connection('business_mirror'); if (! $schema->hasTable('business_mirror_table_states')) { $schema->create('business_mirror_table_states', function (Blueprint $table): void { $table->string('dataset_key')->primary(); $table->string('source_key'); $table->string('source_object'); $table->string('target_table'); $table->string('status')->default('pending'); $table->dateTime('initial_completed_at')->nullable(); $table->dateTime('last_succeeded_at')->nullable(); $table->unsignedBigInteger('mirror_row_count')->default(0); $table->timestamps(); }); } if (! $schema->hasTable('ops_jst_sku')) { $schema->create('ops_jst_sku', function (Blueprint $table): void { $table->unsignedBigInteger('autoid'); $table->string('sku_id')->nullable(); $table->string('sku_type')->nullable(); $table->string('brand')->nullable(); $table->string('category')->nullable(); $table->string('supplier_name')->nullable(); $table->integer('enabled')->nullable(); }); } if (! $schema->hasTable('js_supplier_management')) { $schema->create('js_supplier_management', function (Blueprint $table): void { $table->unsignedBigInteger('Id')->primary(); $table->string('scmcode')->nullable(); $table->string('scmname')->nullable(); }); } } private function markReady( string $datasetKey, string $sourceKey, string $sourceObject, string $targetTable ): void { DB::connection('business_mirror')->table('business_mirror_table_states')->updateOrInsert( ['dataset_key' => $datasetKey], [ 'source_key' => $sourceKey, 'source_object' => $sourceObject, 'target_table' => $targetTable, 'status' => 'succeeded', 'initial_completed_at' => now(), 'last_succeeded_at' => now(), 'mirror_row_count' => 1, 'created_at' => now(), 'updated_at' => now(), ], ); } }