diff --git a/modules/EcommerceFinance/AccountBillColumns.php b/modules/EcommerceFinance/AccountBillColumns.php index 08026c5f..48706622 100644 --- a/modules/EcommerceFinance/AccountBillColumns.php +++ b/modules/EcommerceFinance/AccountBillColumns.php @@ -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'], diff --git a/modules/EcommerceFinance/Repositories/StoreReceivingDewuAlipayBillMirrorRepository.php b/modules/EcommerceFinance/Repositories/StoreReceivingDewuAlipayBillMirrorRepository.php index 3a0ebb51..affb1d37 100644 --- a/modules/EcommerceFinance/Repositories/StoreReceivingDewuAlipayBillMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/StoreReceivingDewuAlipayBillMirrorRepository.php @@ -22,6 +22,18 @@ class StoreReceivingDewuAlipayBillMirrorRepository '支付宝-常州君佰家居有限公司', ]; + /** @var array */ + 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 */ 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> */ 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,bill_items:list} */ @@ -53,4 +73,16 @@ class StoreReceivingDewuAlipayBillMirrorRepository 'bill_items' => $options['bill_items'], ]; } + + /** @param array $row @return array */ + 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; + } } diff --git a/tests/Feature/Business/DewuAlipayReceivingBillsTest.php b/tests/Feature/Business/DewuAlipayReceivingBillsTest.php index 9fcac526..9482b333 100644 --- a/tests/Feature/Business/DewuAlipayReceivingBillsTest.php +++ b/tests/Feature/Business/DewuAlipayReceivingBillsTest.php @@ -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 diff --git a/tests/Unit/EcommerceFinance/TaobaoAlipaySettlementBillRepositoryTest.php b/tests/Unit/EcommerceFinance/TaobaoAlipaySettlementBillRepositoryTest.php index 30756d79..26ceba03 100644 --- a/tests/Unit/EcommerceFinance/TaobaoAlipaySettlementBillRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/TaobaoAlipaySettlementBillRepositoryTest.php @@ -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