feat(得物支付宝账户): 增加店铺与商户号映射列

This commit is contained in:
qiuxiang 2026-11-24 14:40:50 +08:00
parent 6d9a4d2ddd
commit 5d28ca65db
4 changed files with 51 additions and 4 deletions

View File

@ -58,7 +58,7 @@ class AccountBillColumns
['基础信息', 5],
['账户与交易', 8],
['金额', 3],
['业务关联', 6],
['业务关联', 9],
['维护信息', 4],
];
@ -84,6 +84,9 @@ class AccountBillColumns
['备注', 'remark', 'text'],
['线上单号', 'online_order_no', 'num'],
['线上单号对应实际店铺', 'online_real_store', 'text'],
['支付宝账户名', 'dewu_alipay_account_name', 'text'],
['得物店铺', 'dewu_store_name', 'text'],
['商户号', 'dewu_merchant_no', 'num'],
['业务描述', 'business_description', 'text'],
['业务账单来源', 'business_bill_source', 'text'],
['业务订单号', 'business_order_no', 'num'],

View File

@ -22,6 +22,18 @@ class StoreReceivingDewuAlipayBillMirrorRepository
'支付宝-常州君佰家居有限公司',
];
/** @var array<string,array{store:string,merchant_no:string}> */
public const ACCOUNT_MAP = [
'支付宝-常州春之华家居有限公司' => ['store' => '得物-全米', 'merchant_no' => '2088641917126568'],
'支付宝-常州诗科家电子商务有限公司' => ['store' => '得物-木刻理想', 'merchant_no' => '2088741650909210'],
'支付宝-常州玖阔家居有限公司20240319' => ['store' => '得物-米客米家家居旗舰店', 'merchant_no' => '2088841004631652'],
'支付宝-常州阔之煜家居有限公司' => ['store' => '得物-宜造', 'merchant_no' => '2088841085257651'],
'支付宝-常州熊泽家居有限公司' => ['store' => '得物-墨尚思', 'merchant_no' => '2088841143397934'],
'支付宝-常州雄川家居有限公司' => ['store' => '得物-卓禾', 'merchant_no' => '2088741272387795'],
'支付宝-常州泽之云家居有限公司' => ['store' => '得物-欧意朗', 'merchant_no' => '2088841917714972'],
'支付宝-常州君佰家居有限公司' => ['store' => '得物-亿家达', 'merchant_no' => '2088970585568179'],
];
private readonly TaobaoAlipaySettlementBillRepository $source;
public function __construct(TaobaoAlipaySettlementBillRepository $source)
@ -32,13 +44,21 @@ class StoreReceivingDewuAlipayBillMirrorRepository
/** @return array<string,mixed> */
public function paginate(array $filters, string $sort, string $direction, int $page, int $perPage): array
{
return $this->source->paginate($filters, $sort, $direction, $page, $perPage);
$result = $this->source->paginate($filters, $sort, $direction, $page, $perPage);
$result['data'] = array_map(
fn (array $row): array => $this->withAccountMap($row),
$result['data'],
);
return $result;
}
/** @return iterable<int,array<string,mixed>> */
public function exportRows(array $filters, string $sort = 'occurred_at', string $direction = 'asc'): iterable
{
return $this->source->exportRows($filters, $sort, $direction);
foreach ($this->source->exportRows($filters, $sort, $direction) as $row) {
yield $this->withAccountMap($row);
}
}
/** @return array{shops:list<string>,bill_items:list<string>} */
@ -53,4 +73,16 @@ class StoreReceivingDewuAlipayBillMirrorRepository
'bill_items' => $options['bill_items'],
];
}
/** @param array<string,mixed> $row @return array<string,mixed> */
private function withAccountMap(array $row): array
{
$accountName = trim((string) ($row['store_name'] ?? ''));
$mapping = self::ACCOUNT_MAP[$accountName] ?? null;
$row['dewu_alipay_account_name'] = $accountName;
$row['dewu_store_name'] = $mapping['store'] ?? '';
$row['dewu_merchant_no'] = $mapping['merchant_no'] ?? '';
return $row;
}
}

View File

@ -51,7 +51,7 @@ class DewuAlipayReceivingBillsTest extends FeatureTestCase
]);
$this->app->instance(StoreReceivingDewuAlipayBillMirrorRepository::class, $repository);
$this->loginAs()
$response = $this->loginAs()
->getJson(route('ecommerce-finance.account-bills.index', [
'bill_type' => 'dewu-alipay',
'start' => '2026-10-01',
@ -63,6 +63,13 @@ class DewuAlipayReceivingBillsTest extends FeatureTestCase
->assertJsonPath('total', 1)
->assertJsonPath('data.0.alipay_account', '2088841085257651')
->assertJsonPath('summary.balance', 92957.4);
$columnLabels = array_column($response->json('columns.columns'), 'label');
$actualStoreIndex = array_search('线上单号对应实际店铺', $columnLabels, true);
$this->assertSame(
['支付宝账户名', '得物店铺', '商户号'],
array_slice($columnLabels, $actualStoreIndex + 1, 3),
);
}
public function test_filter_options_expose_the_eight_scoped_accounts(): void

View File

@ -186,6 +186,9 @@ class TaobaoAlipaySettlementBillRepositoryTest extends TestCase
$this->assertSame(30.0, $result['summary']['income']);
$this->assertSame(130.0, $result['summary']['balance']);
$this->assertSame(['支付宝-常州熊泽家居有限公司'], array_column($result['data'], 'store_name'));
$this->assertSame('支付宝-常州熊泽家居有限公司', $result['data'][0]['dewu_alipay_account_name']);
$this->assertSame('得物-墨尚思', $result['data'][0]['dewu_store_name']);
$this->assertSame('2088841143397934', $result['data'][0]['dewu_merchant_no']);
$this->assertCount(8, $options['shops']);
$this->assertContains('支付宝-常州玖阔家居有限公司20240319', $options['shops']);
$this->assertNotContains('支付宝-常州玖阔家居有限公司', $options['shops']);
@ -193,6 +196,8 @@ class TaobaoAlipaySettlementBillRepositoryTest extends TestCase
$this->assertNotContains('支付宝-常州其他主体有限公司', $options['shops']);
$this->assertCount(1, $export);
$this->assertSame('支付宝-常州熊泽家居有限公司', $export[0]['store_name']);
$this->assertSame('得物-墨尚思', $export[0]['dewu_store_name']);
$this->assertSame('2088841143397934', $export[0]['dewu_merchant_no']);
}
public function test_first_imported_month_infers_opening_balance_from_first_account_rows(): void