From e6716cb9589377f22bf18c329137773c53f0bb89 Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Thu, 13 Aug 2026 15:35:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=E5=A4=84=E7=90=86=E4=B8=AD=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Business/Pages.php | 5 +++ .../UpstreamSnapshotPendingException.php | 16 +++++++++ .../Services/UpstreamQueryCache.php | 6 ++-- .../partials/embedded-table.blade.php | 36 +++++++++++++++++++ .../MarketingAccountBillsTabsTest.php | 33 +++++++++++++++++ .../UpstreamQueryCacheTest.php | 4 ++- 6 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 modules/EcommerceFinance/Exceptions/UpstreamSnapshotPendingException.php diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 9172eda1..769756eb 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -13,6 +13,7 @@ use Illuminate\Routing\Controller; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; +use Modules\EcommerceFinance\Exceptions\UpstreamSnapshotPendingException; use Modules\EcommerceFinance\Repositories\AlibabaBillRepository; use Modules\EcommerceFinance\Repositories\EdgeBandingRepository; use Modules\EcommerceFinance\Repositories\InventoryRepository; @@ -248,6 +249,7 @@ class Pages extends Controller 'platform' => $tab, 'balances' => collect(), 'error' => null, + 'pending' => false, ]; if (! in_array($tab, ['taobao-alipay', 'pinduoduo'], true)) { @@ -282,6 +284,9 @@ class Pages extends Controller $pageSize, ), ); + } catch (UpstreamSnapshotPendingException $exception) { + $content['pending'] = true; + $result = ['rows' => [], 'total' => 0]; } catch (ServiceUnavailableHttpException $exception) { $content['error'] = $exception->getMessage(); $result = ['rows' => [], 'total' => 0]; diff --git a/modules/EcommerceFinance/Exceptions/UpstreamSnapshotPendingException.php b/modules/EcommerceFinance/Exceptions/UpstreamSnapshotPendingException.php new file mode 100644 index 00000000..cd472f11 --- /dev/null +++ b/modules/EcommerceFinance/Exceptions/UpstreamSnapshotPendingException.php @@ -0,0 +1,16 @@ +register($scope, $parameters, true); if (! (bool) config('upstreams.snapshots.allow_inline_refresh', false)) { - throw new ServiceUnavailableHttpException( - 15, - '数据同步请求已登记,后台正在准备首份共享数据,请稍后刷新。' - ); + throw new UpstreamSnapshotPendingException(); } $resolved = $this->resolve($scope, $parameters, $resolver, false); diff --git a/resources/views/banking/marketing_account_balances/partials/embedded-table.blade.php b/resources/views/banking/marketing_account_balances/partials/embedded-table.blade.php index ad0f28a4..fcfd5183 100644 --- a/resources/views/banking/marketing_account_balances/partials/embedded-table.blade.php +++ b/resources/views/banking/marketing_account_balances/partials/embedded-table.blade.php @@ -24,6 +24,8 @@ .marketing-balance-pagination .page-item.disabled .page-link { color: #595959; cursor: not-allowed; } .marketing-balance-pagination div.lg\:flex > div:first-child { display: none !important; } .marketing-balance-pagination div.lg\:flex { justify-content: center; } + .marketing-balance-status { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 12px; background: var(--vip-content-accent-soft, #F7F0DE); padding: 12px 14px; color: #513E21; font-size: 0.875rem; line-height: 1.5; } + .marketing-balance-status .material-icons-outlined { flex: 0 0 auto; color: var(--vip-content-accent-dark, #856632); font-size: 14px; }
@@ -71,6 +73,11 @@ @if (! empty($error)) +@elseif (! empty($pending)) +
+ + 同步请求已进入后台队列,页面会自动检查首份共享数据,无需重复操作。 +
@endif @if ($supportsBalances) @@ -104,3 +111,32 @@
该平台余额数据表尚未配置。
@endif + +@if (! empty($pending)) + +@elseif ($supportsBalances) + +@endif diff --git a/tests/Feature/Business/MarketingAccountBillsTabsTest.php b/tests/Feature/Business/MarketingAccountBillsTabsTest.php index e5b0c98e..d12be030 100644 --- a/tests/Feature/Business/MarketingAccountBillsTabsTest.php +++ b/tests/Feature/Business/MarketingAccountBillsTabsTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature\Business; use App\Models\Auth\Permission; use Mockery; +use Modules\EcommerceFinance\Exceptions\UpstreamSnapshotPendingException; use Modules\EcommerceFinance\Repositories\JdWalletBillRepository; use Modules\EcommerceFinance\Repositories\PinduoduoSpreadBillRepository; use Modules\EcommerceFinance\Repositories\TmallTaobaoSpreadBillRepository; @@ -196,6 +197,38 @@ class MarketingAccountBillsTabsTest extends FeatureTestCase ->assertSessionHas('error', '首份共享快照正在准备,系统已登记刷新请求;请稍后刷新页面后再导出。'); } + public function testMarketingAccountBalanceColdStartShowsProcessingStateAndAutomaticCheck(): void + { + $this->allowMarketingAccountBalancePage(); + $cache = Mockery::mock(UpstreamQueryCache::class); + $cache->shouldReceive('remember') + ->once() + ->withArgs(fn (string $scope): bool => $scope === 'taobao-alipay-bills.list') + ->andThrow(new UpstreamSnapshotPendingException()); + $cache->shouldReceive('remember') + ->once() + ->withArgs(fn (string $scope): bool => $scope === 'taobao-alipay-bills.options') + ->andReturn([]); + + $factory = Mockery::mock(UpstreamQueryCacheFactory::class); + $factory->shouldReceive('forSource')->once()->with('jiansun')->andReturn($cache); + + $this->app->instance(UpstreamQueryCacheFactory::class, $factory); + $this->app->instance(TmallTaobaoSpreadBillRepository::class, Mockery::mock(TmallTaobaoSpreadBillRepository::class)); + + $this->loginAs() + ->get(route('business.pages.show', [ + 'section' => 'billing-transactions', + 'page' => 'marketing-account-balance', + 'tab' => 'taobao-alipay', + ])) + ->assertOk() + ->assertSeeText('同步请求已进入后台队列,页面会自动检查首份共享数据,无需重复操作。') + ->assertSee('data-marketing-balance-pending', false) + ->assertSee('window.location.reload()', false) + ->assertDontSee('