CaiWuXiTong/tests/Feature/Business/VipshopMpReceivingBillsTest.php
qiuxiang e147c90a2c 店铺收款账户账单新增「总账备注」列(按平台+账单项目映射表取值)
- 新增 ec_account_ledger_remarks 映射表与 account-ledger-remarks:import 导入命令(平台/账单项目/总账备注)
- 新增 AccountLedgerRemarkMap:按店铺名前缀识别平台,无前缀时用页签默认平台;缺失匹配保持空白
- 全部账户页签(含淘系支付宝自有列定义)在「店铺/店铺名称」右侧新增「总账备注」列,页面/列设置/导出共用同一份列定义
- 控制器在分页与导出流读取时补齐 payload.ledger_remark,不改动上游账单与共享镜像数据
- 用例:新增 AccountLedgerRemarkMapTest;修正唯品会 JX/MP 列清单断言
2026-10-06 15:42:57 +08:00

60 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Modules\EcommerceFinance\Models\AccountBill;
use Tests\Feature\FeatureTestCase;
/**
* 店铺收款账户账单 › 唯品会MP账户(bill_type = vipshop)。
*/
class VipshopMpReceivingBillsTest extends FeatureTestCase
{
public function test_mp_tab_exposes_the_settle_period_column_with_its_own_rows(): void
{
$this->allowPage();
$this->bill('vipshop', '2761547331', '销售订单', '2026-07-31 20:38:40', 39.00, 0.00);
$this->bill('vipshop', '2761292184', '订单退款', '2026-07-31 19:34:32', 0.00, 20.00);
$this->bill('vipshop-jx', '4675', '差异详情-处罚款', '2026-07-16 00:00:00', 0.00, 8.00);
$response = $this->loginAs()
->getJson(route('ecommerce-finance.account-bills.index', ['bill_type' => 'vipshop', 'limit' => 20]))
->assertOk()
->assertJsonPath('columns.title', '唯品会MP账户')
->assertJsonPath('total', 2)
->assertJsonPath('data.0.payload.settle_period', '2026-08')
->assertJsonPath('data.1.payload.settle_period', '2026-08');
$this->assertSame(
['全局ID', '店铺ID', '店铺名称', '总账备注', '订单签收或退款时间', '订单结算时间', '订单类型名称'],
array_slice(array_column($response->json('columns.columns'), 'label'), 0, 7),
);
}
private function bill(string $billType, string $recordCode, string $item, string $occurredAt, float $income, float $expense): void
{
AccountBill::create([
'company_id' => $this->company->id,
'bill_type' => $billType,
'record_code' => $recordCode,
'store_name' => $billType === 'vipshop' ? '卓禾家具特卖旗舰店' : '唯品会JITX_亿家达',
'order_no' => '26072734938113',
'amount' => $income - $expense,
'bill_item' => $item,
'occurred_at' => $occurredAt,
'income' => $income,
'expense' => $expense,
// 现财务系统中唯品会MP账户的订单结算时间均为 2026-08。
'payload' => ['shop_id' => 'ST64055434', 'settle_period' => '2026-08'],
]);
}
private function allowPage(): void
{
$this->user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail()
);
}
}