user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); AlipayBill::create([ 'company_id' => $this->company->id, 'record_code' => 'time-format-test', 'store_name' => '测试店铺', 'bill_item' => '交易收款', 'business_type' => '交易付款', 'alipay_account' => '2088000000000000', 'counterparty_account' => '测试账号', 'account_order_no' => 'account-order-test', 'business_serial_no' => 'business-serial-test', 'goods_name' => '测试商品', 'income' => 1, 'expense' => 0, 'balance' => 1, 'occurred_at' => '2026-07-15 23:59:12', ]); $this->loginAs() ->withHeader('X-Requested-With', 'XMLHttpRequest') ->get(route('ecommerce-finance.alipay-bills.index')) ->assertOk() ->assertJsonStructure([ 'current_page', 'data', 'total', 'summary' => ['income', 'expense', 'count', 'balance'], ]) ->assertJsonPath('data.0.occurred_at', '2026-07-15 23:59:12'); } public function testTaobaoAlipayBillsPageProvidesTheVueMountPoint() { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'billing-transactions', 'page' => 'store-receiving-bills', 'tab' => 'taobao-alipay', ])) ->assertOk() ->assertSee('class="biz-card mt-6 business-blank-page"', false) ->assertSee('public/js/business/pages.min.js', false); } public function testSupplierPayablesPageRendersItsSpecificContent() { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'supplier-payables', 'page' => 'payment-reconciliation', ])) ->assertOk() ->assertSee('id="goods-reconciliation-app"', false) ->assertSee('public/js/ecommerce-finance/goods-reconciliations.min.js', false) ->assertDontSee('class="business-blank-page"', false); } public function testReceivingAccountTabsUseTheFourWorkbookPages(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs()->get(route('business.pages.show', [ 'section' => 'fund-management', 'page' => 'store-receiving-accounts', ]))->assertRedirect(route('business.pages.show', [ 'company_id' => $this->company->id, 'section' => 'fund-management', 'page' => 'store-receiving-accounts', 'tab' => 'taobao', ])); $html = $this->get(route('business.pages.show', [ 'section' => 'fund-management', 'page' => 'store-receiving-accounts', 'tab' => 'taobao', ]))->assertOk()->getContent(); $this->assertStringContainsString('淘宝', $html); $this->assertStringContainsString('京东', $html); $this->assertStringContainsString('抖音小店', $html); $this->assertStringContainsString('拼多多', $html); $this->assertStringContainsString('下载四页模板', $html); $this->assertStringContainsString('id="biz-import-modal"', $html); $this->assertStringContainsString('name="erp_store_name"', $html); $this->assertStringContainsString('name="company_name"', $html); $this->assertStringContainsString('导出数据', $html); } public function testReceivingAccountExportContainsVisiblePasswordFieldsAsText(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); StoreReceivingAccount::create([ 'company_id' => $this->company->id, 'store_platform' => '淘宝', 'store_type' => '淘宝', 'erp_store_name' => 'Export test shop', 'store_name' => 'Export test shop', 'store_entity_name' => 'Export test company', 'login_account' => 'export-test@example.invalid', 'login_password' => 'Login-Test-Password-001', 'payment_password' => 'Payment-Test-Password-002', ]); $this->mock(\App\Business\UpstreamBusinessInformation::class, function ($mock): void { $mock->shouldReceive('storesByPlatforms')->once()->with( ['淘宝', '阿里巴巴', '天猫', '淘宝分销', '唯品会'], 1000, )->andReturn([]); }); $response = $this->loginAs()->get(route('business.pages.export', [ 'section' => 'fund-management', 'page' => 'store-receiving-accounts', 'tab' => 'taobao', ]))->assertOk(); $this->assertStringContainsString( 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type') ); $temporaryFile = tempnam(sys_get_temp_dir(), 'receiving-account-export-'); try { file_put_contents($temporaryFile, $response->streamedContent()); $sheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($temporaryFile)->getActiveSheet(); $headers = $sheet->rangeToArray('A1:M1', null, true, false)[0]; $values = $sheet->rangeToArray('A2:M2', null, true, false)[0]; $this->assertContains('登录密码', $headers); $this->assertContains('支付密码', $headers); $this->assertContains('Login-Test-Password-001', $values); $this->assertContains('Payment-Test-Password-002', $values); } finally { @unlink($temporaryFile); } } public function testReceivingAccountInvalidTabFallsBackToTaobao(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs()->get(route('business.pages.show', [ 'section' => 'fund-management', 'page' => 'store-receiving-accounts', 'tab' => 'taobao-alipay', ]))->assertRedirect(route('business.pages.show', [ 'company_id' => $this->company->id, 'section' => 'fund-management', 'page' => 'store-receiving-accounts', 'tab' => 'taobao', ])); } public function testReceivingAccountDirectoryLinkHasNoLegacyTabSlug(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs()->get(route('business.pages.show', [ 'section' => 'fund-management', 'page' => 'bank-accounts', ]))->assertOk()->assertSee(route('business.pages.show', [ 'section' => 'fund-management', 'page' => 'store-receiving-accounts', ]), false); } public function testOrderDataTablesRenderAsRawDataPageTabs() { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs() ->get(route('business.pages.show', ['section' => 'order-data'])) ->assertRedirect(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'after-sales-expenses', ])); $this->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', ])) ->assertRedirect(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'after-sales-expenses', ])); $this->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'after-sales-expenses', ])) ->assertOk() ->assertSeeText('订单售后费用明细') ->assertSee('aria-label="订单售后费用明细"', false) ->assertSeeText('内部订单号') ->assertSeeText('800503发空包/赠品费用') ->assertSeeText('暂无数据') ->assertSee('class="business-tab-bar"', false) ->assertSee(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'after-sales-expenses', ]), false) ->assertSee(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'promotion-expenses', ]), false) ->assertDontSee(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'after-sales-expenses', ]), false) ->assertDontSee('class="business-blank-page"', false); $this->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'promotion-expenses', ])) ->assertOk() ->assertSeeText('商品推广费用明细') ->assertSee('aria-label="商品推广费用明细"', false) ->assertSeeText('店铺') ->assertSeeText('8001201直通车/钻展/快车等') ->assertSeeText('暂无数据') ->assertDontSee('class="business-blank-page"', false); } public function testOrderDataIncludesTheConfiguredBillOffsetSubpage(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->loginAs(); $this->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'bill-offset', ])) ->assertOk() ->assertSeeInOrder([ route('business.pages.show', [ 'section' => 'order-data', 'page' => 'raw-data', 'tab' => 'after-sales-expenses', ]), route('business.pages.show', [ 'section' => 'order-data', 'page' => 'bill-offset', ]), ], false); $this->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => 'bill-offset', ])) ->assertOk() ->assertSeeText('账单冲减') ->assertSeeText('该页面暂未配置数据表,敬请期待。'); $this->withExceptionHandling(); foreach (['national-subsidy', 'hundred-subsidy', 'consumption-coupon'] as $removedSlug) { $this->withHeader('X-Requested-With', 'XMLHttpRequest') ->get(route('business.pages.show', [ 'section' => 'order-data', 'page' => $removedSlug, ])) ->assertNotFound(); } } public function testRefundPagesUseTheGenericBusinessPageRoute() { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $repository = \Mockery::mock(NonJingxiRefundMirrorRepository::class); $repository->shouldReceive('available')->once()->andReturnFalse(); $repository->shouldNotReceive('states'); $repository->shouldNotReceive('syncStatus'); $repository->shouldNotReceive('ready'); $repository->shouldNotReceive('queryReady'); $repository->shouldNotReceive('paginate'); $this->app->instance(NonJingxiRefundMirrorRepository::class, $repository); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'refunds', ])) ->assertRedirect(route('business.pages.show', [ 'section' => 'refunds', 'page' => 'jingxi-refund-data', ])); $this->get(route('business.pages.show', [ 'section' => 'refunds', 'page' => 'jingxi-refund-data', ])) ->assertOk() ->assertSeeText('京喜退款数据') ->assertSeeText('该页面暂未配置数据表,敬请期待。') ->assertSee('class="biz-empty"', false); $response = $this->get(route('business.pages.show', [ 'section' => 'refunds', 'page' => 'non-jingxi-refund-data', ])); $response ->assertOk() ->assertSeeText('售后(退货退款)') ->assertSee('aria-label="售后(退货退款)"', false) ->assertSee('aria-label="售后(退货退款)分页"', false) ->assertDontSeeText('非京喜退款数据') ->assertSeeText('共享业务镜像尚未建立') ->assertSeeText('数据暂时无法读取') ->assertSee('class="upstream-data-table refund-data-table refund-data-table--wide"', false) ->assertSee('data-header-row="labels"', false) ->assertSee('data-header-row="fields"', false) ->assertDontSee('class="biz-empty"', false); $html = $response->getContent(); $headerRows = []; preg_match_all( '/