loginAs() ->get(route('business.pages.show', [ 'section' => 'posting-data', 'page' => 'kuka-reconciliation', ])) ->assertOk() ->assertSeeText('顾家对账') ->assertSeeText('顾家过账数据') ->assertSeeText('TOC订单') ->assertSeeText('灵珊虚拟过账') ->assertSeeText('顾家ERP商品导入') ->assertSeeText('开票填写模板-货物-灵珊') ->assertSeeText('库存管理模板') ->assertSeeText('灵珊对账单') ->assertSeeText('欧伯娜对账单') ->assertSee('data-kuka-reconciliation-tabs', false) ->assertSee('data-kuka-reconciliation-panel="posting-data"', false) ->assertSee('data-kuka-reconciliation-panel="oberna-statement"', false) ->assertSee('id="kuka-reconciliation-tab-posting-data"', false) ->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false) ->assertSee('data-kuka-reconciliation-template="顾家过账数据"', false) ->assertSee('data-kuka-reconciliation-template="TOC订单"', false) ->assertSee('data-kuka-reconciliation-template="灵珊虚拟过账"', false) ->assertSee('data-kuka-reconciliation-template="顾家ERP商品导入"', false) ->assertSee('data-kuka-reconciliation-template="开票填写模板-货物-灵珊"', false) ->assertSee('data-kuka-reconciliation-template="库存管理模版"', false) ->assertSeeText('供货商金额') ->assertSeeText('装载号') ->assertSeeText('nationalSubsidySubject') ->assertSeeText('提交人电话(手机)') ->assertSeeText('toElsAccount') ->assertSeeText('实际可用库存数量') ->assertSeeText('灵珊对账单页面已建立') ->assertSeeText('欧伯娜对账单页面已建立'); $html = $response->getContent(); $this->assertSame([ 'posting-data' => 7, 'toc-orders' => 6, 'lingshan-virtual-posting' => 16, 'erp-product-import' => 34, 'invoice-entry-template' => 20, 'inventory-management-template' => 28, ], [ 'posting-data' => $this->headerCount($html, 'posting-data'), 'toc-orders' => $this->headerCount($html, 'toc-orders'), 'lingshan-virtual-posting' => $this->headerCount($html, 'lingshan-virtual-posting'), 'erp-product-import' => $this->headerCount($html, 'erp-product-import'), 'invoice-entry-template' => $this->headerCount($html, 'invoice-entry-template'), 'inventory-management-template' => $this->headerCount($html, 'inventory-management-template'), ]); } public function test_kuka_reconciliation_tab_can_open_directly_from_the_url(): void { $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'posting-data', 'page' => 'kuka-reconciliation', 'reconciliation_view' => 'toc-orders', ])) ->assertOk() ->assertSee('id="kuka-reconciliation-tab-toc-orders"', false) ->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false) ->assertSee('data-kuka-reconciliation-panel="toc-orders"', false) ->assertSee('data-kuka-reconciliation-template="TOC订单"', false) ->assertSeeText('订单号') ->assertSeeText('发货数量'); } public function test_reconciliation_panels_render_rows_generated_from_shipment_rules(): void { $connection = DB::connection('business_mirror'); $payload = [ '内部订单号' => 'INTERNAL-1', '线上订单号' => 'ONLINE-1', '原始线上订单号' => 'ONLINE-1', '订单状态' => '已发货', '发货仓' => '测试仓', '店铺' => '天猫-HX旗舰店101', '买家账号' => 'buyer-1', '卖家备注' => '测试备注', '订单日期' => '2026-10-31 10:00:00', '付款日期' => '2026-10-31 10:05:00', '发货日期' => '2026-10-31 18:00:00', '省' => '江苏省', '市' => '常州市', '区县' => '武进区', '订单快递公司' => '测试快递', '订单快递单号' => 'EXPRESS-1', '收货人' => '张三', '商品编码' => 'PRODUCT-1', '款式编码' => 'STYLE-1', '货号' => 'ITEM-1', '型号' => '测试物料描述', '商品名称' => '测试商品', '颜色规格' => '测试颜色', '材质' => '板材', '业务员' => '业务员A', '运费支出' => '5.00', '物料编号' => 'MATERIAL-1', '成本' => '100.00', '实发数量' => '2', '发货金额' => '200.00', ]; $encoded = json_encode( $payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR, ); $now = now(); $connection->table('kuka_posting_base_imports')->insert([ 'company_id' => $this->company->id, 'period' => '2026-10', 'row_count' => 1, 'store_count' => 1, 'order_count' => 1, 'store_counts' => '{"天猫-HX旗舰店101":1}', 'file_name' => 'test.xlsx', 'file_sha256' => str_repeat('a', 64), 'source_sheet' => '发货明细表', 'completed_at' => $now, 'created_at' => $now, 'updated_at' => $now, ]); $connection->table('kuka_posting_base_rows')->insert([ 'company_id' => $this->company->id, 'period' => '2026-10', 'store_name' => '天猫-HX旗舰店101', 'internal_order_no' => 'INTERNAL-1', 'online_order_no' => 'ONLINE-1', 'product_code' => 'PRODUCT-1', 'order_status' => '已发货', 'row_hash' => hash('sha256', $encoded), 'source_values' => $encoded, 'source_row_number' => 2, 'imported_at' => $now, ]); $connection->table('kuka_posting_quotation_rows')->insert([ 'company_id' => $this->company->id, 'material_number' => 'MATERIAL-1', 'material_desc' => '测试物料描述', 'supplier_account' => '435421', 'supplier_name' => '常州欧伯娜家居有限公司', 'record_status' => '生效', 'price_including_tax' => '100.0000', 'price_excluding_tax' => '88.5000', 'row_hash' => str_repeat('b', 64), 'source_values' => '{}', 'source_row_number' => 3, 'imported_at' => $now, ]); $connection->table('jst_oms_shipping')->insert([ 'trade_no' => 'ONLINE-1', 'barcode' => 'PRODUCT-1', 'product_code' => 'STYLE-1', 'receiver_name' => '张三', 'receiver_state' => '江苏省', 'receiver_city' => '常州市', 'receiver_district' => '武进区', 'receiver_address' => '江苏省常州市武进区测试路1号', 'receiver_mobile' => '13800000000', 'express_no' => 'EXPRESS-1', 'express_name1' => '测试快递', 'freight' => '5.00', ]); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'posting-data', 'page' => 'kuka-reconciliation', 'period' => '2026-10', ])) ->assertOk() ->assertSeeText('MATERIAL-1') ->assertSeeText('测试物料描述') ->assertSeeText('222.22') ->assertSeeText('常州欧伯娜家居有限公司') ->assertSeeText('435421') ->assertSeeText('宁波顾家望业家居有限公司') ->assertSeeText('江苏省常州市武进区测试路1号') ->assertSeeText('13800000000'); } private function headerCount(string $html, string $slug): int { $panelStart = strpos($html, 'data-kuka-reconciliation-panel="'.$slug.'"'); $this->assertNotFalse($panelStart); $panelEnd = strpos($html, '', $panelStart); $this->assertNotFalse($panelEnd); $panel = substr($html, $panelStart, $panelEnd - $panelStart); preg_match_all('/