From 6cf88ec3be746249a4e72b0fb5c7cb8615b9ccf6 Mon Sep 17 00:00:00 2001 From: qiuxiang Date: Sat, 7 Nov 2026 17:01:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=98=E7=B3=BB=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=9C=9F=E5=88=9D=E4=BD=99=E9=A2=9D=E6=9A=82=E7=BD=AE=E4=B8=BA?= =?UTF-8?q?=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TaobaoWechatAccountBills.php | 13 +++--- .../js/components/business/AccountBills.vue | 6 ++- .../TaobaoWechatReceivingBillsTest.php | 41 +++++++++++++++++-- tests/Unit/View/AccountBillsTableTest.php | 1 + 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/modules/EcommerceFinance/Http/Controllers/TaobaoWechatAccountBills.php b/modules/EcommerceFinance/Http/Controllers/TaobaoWechatAccountBills.php index 5aaeff2b..cf481e48 100644 --- a/modules/EcommerceFinance/Http/Controllers/TaobaoWechatAccountBills.php +++ b/modules/EcommerceFinance/Http/Controllers/TaobaoWechatAccountBills.php @@ -62,7 +62,8 @@ class TaobaoWechatAccountBills extends Controller $alipaySummary = null; try { - // 微信账单没有余额列,期初和期末统一取同一筛选条件下淘系支付宝的账户汇总。 + // 微信账单没有余额列;期初待各店铺6月期末余额录入,暂时固定为0, + // 期末仍按现有口径取同一筛选条件下淘系支付宝的账户余额。 $alipaySummary = $alipayRepository->summary($filters); } catch (RuntimeException $exception) { if ($exception->getMessage() !== 'taobao_alipay_authoritative_bills_not_ready') { @@ -71,9 +72,9 @@ class TaobaoWechatAccountBills extends Controller } $data['summary'] = array_merge($data['summary'], [ - 'opening_balance' => $alipaySummary['opening_balance'] ?? null, - 'opening_balance_date' => $alipaySummary['opening_balance_date'] ?? null, - 'opening_balance_source' => $alipaySummary['opening_balance_source'] ?? null, + 'opening_balance' => 0, + 'opening_balance_date' => null, + 'opening_balance_source' => 'pending_june_ending', 'balance' => $alipaySummary['balance'] ?? null, 'balance_source' => $alipaySummary === null ? 'unavailable' : 'taobao_alipay', ]); @@ -88,9 +89,9 @@ class TaobaoWechatAccountBills extends Controller return [ 'income' => 0, 'expense' => 0, - 'opening_balance' => null, + 'opening_balance' => 0, 'opening_balance_date' => null, - 'opening_balance_source' => null, + 'opening_balance_source' => 'pending_june_ending', 'balance' => null, 'balance_source' => 'unavailable', 'count' => 0, diff --git a/resources/assets/js/components/business/AccountBills.vue b/resources/assets/js/components/business/AccountBills.vue index d04143c5..bab00093 100644 --- a/resources/assets/js/components/business/AccountBills.vue +++ b/resources/assets/js/components/business/AccountBills.vue @@ -318,9 +318,11 @@ export default { if(this.billType==='taobao-wechat'){ const openingSource=this.summary.opening_balance_source; const openingDate=this.summary.opening_balance_date; - const openingNote=openingSource==='first_row_estimate' + const openingNote=openingSource==='pending_june_ending' + ?'待录入各店铺6月期末余额' + :(openingSource==='first_row_estimate' ?'首月按淘系支付宝首笔余额倒推' - :(openingDate?`截至 ${openingDate} 淘系支付宝最后一笔`:'淘系支付宝上月最后一笔'); + :(openingDate?`截至 ${openingDate} 淘系支付宝最后一笔`:'淘系支付宝上月最后一笔')); const balanceNote=this.summary.balance_source==='unavailable'?'淘系支付宝余额暂不可用':'同淘系支付宝账户'; return [ {label:'期初余额',value:this.moneyWan(this.summary.opening_balance),note:openingNote,className:''}, diff --git a/tests/Feature/Business/TaobaoWechatReceivingBillsTest.php b/tests/Feature/Business/TaobaoWechatReceivingBillsTest.php index ba2fe24d..3cd9ddef 100644 --- a/tests/Feature/Business/TaobaoWechatReceivingBillsTest.php +++ b/tests/Feature/Business/TaobaoWechatReceivingBillsTest.php @@ -68,13 +68,48 @@ class TaobaoWechatReceivingBillsTest extends FeatureTestCase ->assertJsonPath('data.0.payload.entry_type', '收入') ->assertJsonPath('columns.title', '淘系微信账户') ->assertJsonPath('summary.count', 41) - ->assertJsonPath('summary.opening_balance', 230) - ->assertJsonPath('summary.opening_balance_date', '2026-08-31') - ->assertJsonPath('summary.opening_balance_source', 'previous_period') + ->assertJsonPath('summary.opening_balance', 0) + ->assertJsonPath('summary.opening_balance_date', null) + ->assertJsonPath('summary.opening_balance_source', 'pending_june_ending') ->assertJsonPath('summary.balance', 525) ->assertJsonPath('summary.balance_source', 'taobao_alipay'); } + public function test_opening_balance_stays_zero_when_alipay_summary_is_unavailable(): void + { + $this->allowPage(); + $repository = Mockery::mock(TaobaoWechatSettlementBillRepository::class); + $repository->shouldReceive('paginateAccountBills')->once()->andReturn([ + 'current_page' => 1, + 'last_page' => 1, + 'per_page' => 20, + 'total' => 1, + 'data' => [], + 'summary' => ['income' => 10.0, 'expense' => 2.0, 'balance' => 8.0, 'count' => 1], + ]); + $this->app->instance(TaobaoWechatSettlementBillRepository::class, $repository); + + $alipayRepository = Mockery::mock(TaobaoAlipaySettlementBillRepository::class); + $alipayRepository->shouldReceive('summary')->once()->andThrow( + new RuntimeException('taobao_alipay_authoritative_bills_not_ready') + ); + $this->app->instance(TaobaoAlipaySettlementBillRepository::class, $alipayRepository); + + $this->withExceptionHandling() + ->loginAs() + ->getJson(route('ecommerce-finance.account-bills.index', [ + 'bill_type' => 'taobao-wechat', + 'start' => '2026-11-01', + 'end' => '2026-11-30', + ])) + ->assertOk() + ->assertJsonPath('summary.opening_balance', 0) + ->assertJsonPath('summary.opening_balance_date', null) + ->assertJsonPath('summary.opening_balance_source', 'pending_june_ending') + ->assertJsonPath('summary.balance', null) + ->assertJsonPath('summary.balance_source', 'unavailable'); + } + public function test_filter_options_and_selected_column_export_use_the_same_mirror(): void { $this->allowPage(); diff --git a/tests/Unit/View/AccountBillsTableTest.php b/tests/Unit/View/AccountBillsTableTest.php index 6817926a..4db79544 100644 --- a/tests/Unit/View/AccountBillsTableTest.php +++ b/tests/Unit/View/AccountBillsTableTest.php @@ -90,6 +90,7 @@ class AccountBillsTableTest extends TestCase $this->assertStringContainsString("if(this.billType==='taobao-wechat')", $source); $this->assertStringContainsString("label:'期初余额'", $source); $this->assertStringContainsString("label:'期末余额(最新)'", $source); + $this->assertStringContainsString('待录入各店铺6月期末余额', $source); $this->assertStringContainsString("this.summary.balance_source==='unavailable'?'淘系支付宝余额暂不可用':'同淘系支付宝账户'", $source); $this->assertLessThan( strpos($source, "label:'收入合计'"), -- 2.47.2