修复京东钱包账单集成
This commit is contained in:
parent
8912ae7a83
commit
720d521be8
@ -957,54 +957,44 @@ class Pages extends Controller
|
||||
$repository = app(JdWalletBillRepository::class);
|
||||
$cache = $this->upstreamCaches->forSource('jiansun');
|
||||
$scopePrefix = 'jd-wallet-bills.' . $ledger;
|
||||
$errors = [];
|
||||
$remember = function (string $scope, array $parameters, callable $resolver, mixed $fallback) use ($cache, &$errors): mixed {
|
||||
try {
|
||||
return $cache->remember($scope, $parameters, $resolver);
|
||||
} catch (ServiceUnavailableHttpException $exception) {
|
||||
$errors[] = $exception->getMessage();
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
$errors[] = '京东账单数据暂时无法读取,请稍后重试。';
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $cache->remember(
|
||||
$scopePrefix . '.list',
|
||||
['filters' => $filters, 'page' => $page, 'limit' => $pageSize],
|
||||
fn () => $ledger === 'consumption'
|
||||
? $repository->paginateConsumption($filters['store_name'], $filters['from'], $filters['to'], $page, $pageSize)
|
||||
: $repository->paginateRecharge($filters['store_name'], $filters['from'], $filters['to'], $page, $pageSize),
|
||||
);
|
||||
$summary = $cache->remember(
|
||||
$scopePrefix . '.summary',
|
||||
['filters' => $filters],
|
||||
fn () => $ledger === 'consumption'
|
||||
? $repository->summaryConsumption($filters['store_name'], $filters['from'], $filters['to'])
|
||||
: $repository->summaryRecharge($filters['store_name'], $filters['from'], $filters['to']),
|
||||
);
|
||||
$shopOptions = $cache->remember(
|
||||
'jd-wallet-bills.options',
|
||||
[],
|
||||
fn () => $repository->shopOptions(),
|
||||
);
|
||||
} catch (ServiceUnavailableHttpException $exception) {
|
||||
return [
|
||||
'view' => 'banking.marketing_jd_wallet_bills.partials.embedded-table',
|
||||
'ledger' => $ledger,
|
||||
'bills' => new LengthAwarePaginator([], 0, $pageSize, $page, [
|
||||
'path' => $request->url(), 'query' => $request->query(),
|
||||
]),
|
||||
'filters' => $filters,
|
||||
'summary' => ['amount_total' => 0, 'balance_total' => 0, 'count' => 0],
|
||||
'shopOptions' => [],
|
||||
'error' => $exception->getMessage(),
|
||||
];
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
return $fallback;
|
||||
};
|
||||
|
||||
return [
|
||||
'view' => 'banking.marketing_jd_wallet_bills.partials.embedded-table',
|
||||
'ledger' => $ledger,
|
||||
'bills' => new LengthAwarePaginator([], 0, $pageSize, $page, [
|
||||
'path' => $request->url(), 'query' => $request->query(),
|
||||
]),
|
||||
'filters' => $filters,
|
||||
'summary' => ['amount_total' => 0, 'balance_total' => 0, 'count' => 0],
|
||||
'shopOptions' => [],
|
||||
'error' => '京东账单数据暂时无法读取,请稍后重试。',
|
||||
];
|
||||
}
|
||||
// 三项分别读取,确保生产冷启动时一次请求就能登记列表、汇总和选项,
|
||||
// 同时保留已经命中的共享快照,不因另一项暂缺而清空整页。
|
||||
$result = $remember(
|
||||
$scopePrefix . '.list',
|
||||
['filters' => $filters, 'page' => $page, 'limit' => $pageSize],
|
||||
fn () => $ledger === 'consumption'
|
||||
? $repository->paginateConsumption($filters['store_name'], $filters['from'], $filters['to'], $page, $pageSize)
|
||||
: $repository->paginateRecharge($filters['store_name'], $filters['from'], $filters['to'], $page, $pageSize),
|
||||
['rows' => [], 'total' => 0],
|
||||
);
|
||||
$summary = $remember(
|
||||
$scopePrefix . '.summary',
|
||||
['filters' => $filters],
|
||||
fn () => $ledger === 'consumption'
|
||||
? $repository->summaryConsumption($filters['store_name'], $filters['from'], $filters['to'])
|
||||
: $repository->summaryRecharge($filters['store_name'], $filters['from'], $filters['to']),
|
||||
['amount_total' => 0, 'balance_total' => 0, 'count' => 0],
|
||||
);
|
||||
$shopOptions = $remember(
|
||||
'jd-wallet-bills.options',
|
||||
[],
|
||||
fn () => $repository->shopOptions(),
|
||||
[],
|
||||
);
|
||||
|
||||
return [
|
||||
'view' => 'banking.marketing_jd_wallet_bills.partials.embedded-table',
|
||||
@ -1019,7 +1009,9 @@ class Pages extends Controller
|
||||
'filters' => $filters,
|
||||
'summary' => $summary,
|
||||
'shopOptions' => $shopOptions,
|
||||
'error' => null,
|
||||
'error' => $errors === []
|
||||
? null
|
||||
: implode(' ', array_values(array_unique(array_filter($errors)))),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -144,8 +144,8 @@ class JdWalletBillRepository
|
||||
$bindings[] = $fromDate . ' 00:00:00';
|
||||
}
|
||||
if ($toDate !== null && preg_match('/^\d{4}-\d{2}-\d{2}$/', $toDate) === 1) {
|
||||
$conditions[] = $dateField . ' <= ?';
|
||||
$bindings[] = $toDate . ' 23:59:59';
|
||||
$conditions[] = $dateField . ' < DATEADD(day, 1, CAST(? AS date))';
|
||||
$bindings[] = $toDate;
|
||||
}
|
||||
|
||||
return ['sql' => $conditions === [] ? '' : ' WHERE ' . implode(' AND ', $conditions), 'bindings' => $bindings];
|
||||
|
||||
@ -33,7 +33,7 @@ class JianSunSnapshotRefresher implements UpstreamSnapshotRefresher
|
||||
private readonly TmallTaobaoSpreadBillRepository $taobaoAlipay,
|
||||
private readonly SupplierPayableRepository $supplier,
|
||||
private readonly SupplierPayableReportRepository $supplierPayableReports,
|
||||
private readonly ?JdWalletBillRepository $jdWallet = null,
|
||||
private readonly JdWalletBillRepository $jdWallet,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -114,31 +114,31 @@ class JianSunSnapshotRefresher implements UpstreamSnapshotRefresher
|
||||
),
|
||||
'pinduoduo-bills.options' => $this->pinduoduo->storeOptions(),
|
||||
|
||||
'jd-wallet-bills.recharge.list' => $this->jdWallet?->paginateRecharge(
|
||||
'jd-wallet-bills.recharge.list' => $this->jdWallet->paginateRecharge(
|
||||
$storeName,
|
||||
$fromDate,
|
||||
$toDate,
|
||||
$page,
|
||||
$limit,
|
||||
),
|
||||
'jd-wallet-bills.recharge.summary' => $this->jdWallet?->summaryRecharge(
|
||||
'jd-wallet-bills.recharge.summary' => $this->jdWallet->summaryRecharge(
|
||||
$storeName,
|
||||
$fromDate,
|
||||
$toDate,
|
||||
),
|
||||
'jd-wallet-bills.consumption.list' => $this->jdWallet?->paginateConsumption(
|
||||
'jd-wallet-bills.consumption.list' => $this->jdWallet->paginateConsumption(
|
||||
$storeName,
|
||||
$fromDate,
|
||||
$toDate,
|
||||
$page,
|
||||
$limit,
|
||||
),
|
||||
'jd-wallet-bills.consumption.summary' => $this->jdWallet?->summaryConsumption(
|
||||
'jd-wallet-bills.consumption.summary' => $this->jdWallet->summaryConsumption(
|
||||
$storeName,
|
||||
$fromDate,
|
||||
$toDate,
|
||||
),
|
||||
'jd-wallet-bills.options' => $this->jdWallet?->shopOptions(),
|
||||
'jd-wallet-bills.options' => $this->jdWallet->shopOptions(),
|
||||
|
||||
'taobao-alipay-bills.list' => $this->taobaoAlipay->paginate(
|
||||
$storeName,
|
||||
|
||||
206
resources/assets/js/views/business/marketing-account-bills.js
vendored
Normal file
206
resources/assets/js/views/business/marketing-account-bills.js
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
/**
|
||||
* 营销账户账单页面的服务端局部导航。
|
||||
*
|
||||
* 链接始终保留完整 href 作为渐进增强回退;普通左键操作只替换当前
|
||||
* 工作区并同步 History,避免平台标签、京东账单类型、筛选和分页触发整页刷新。
|
||||
*/
|
||||
(function () {
|
||||
const workspaceSelector = '[data-marketing-account-bills-workspace]';
|
||||
const pagePathMarker = '/workspace/billing-transactions/marketing-account-bills';
|
||||
let activeRequest = null;
|
||||
|
||||
function currentWorkspace() {
|
||||
return document.querySelector(workspaceSelector);
|
||||
}
|
||||
|
||||
function isSupportedUrl(url) {
|
||||
const target = new URL(url, window.location.origin);
|
||||
|
||||
return target.origin === window.location.origin
|
||||
&& target.pathname.indexOf(pagePathMarker) !== -1;
|
||||
}
|
||||
|
||||
function updateHeader(nextDocument) {
|
||||
const currentHeader = document.querySelector('[data-page-title-first]');
|
||||
const nextHeader = nextDocument.querySelector('[data-page-title-first]');
|
||||
|
||||
if (currentHeader && nextHeader) {
|
||||
currentHeader.innerHTML = nextHeader.innerHTML;
|
||||
}
|
||||
|
||||
if (nextDocument.title) {
|
||||
document.title = nextDocument.title;
|
||||
}
|
||||
}
|
||||
|
||||
function setLoading(workspace, loading) {
|
||||
const status = workspace.querySelector('[data-marketing-account-bills-status]');
|
||||
|
||||
if (loading) {
|
||||
workspace.setAttribute('aria-busy', 'true');
|
||||
if (status) {
|
||||
status.textContent = '正在加载账单数据';
|
||||
}
|
||||
} else {
|
||||
workspace.removeAttribute('aria-busy');
|
||||
}
|
||||
}
|
||||
|
||||
function showError(workspace, url) {
|
||||
const error = workspace.querySelector('[data-marketing-account-bills-navigation-error]');
|
||||
const status = workspace.querySelector('[data-marketing-account-bills-status]');
|
||||
|
||||
setLoading(workspace, false);
|
||||
|
||||
if (status) {
|
||||
status.textContent = '账单内容加载失败';
|
||||
}
|
||||
|
||||
if (error) {
|
||||
const retry = error.querySelector('[data-marketing-account-bills-retry]');
|
||||
error.hidden = false;
|
||||
if (retry) {
|
||||
retry.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initialiseInsertedContent(workspace) {
|
||||
if (window.Alpine && typeof window.Alpine.initTree === 'function') {
|
||||
window.Alpine.initTree(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
async function navigate(url, options) {
|
||||
const settings = Object.assign({ pushState: true, focus: null }, options || {});
|
||||
const workspace = currentWorkspace();
|
||||
|
||||
if (!workspace || !isSupportedUrl(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeRequest) {
|
||||
activeRequest.abort();
|
||||
}
|
||||
|
||||
const request = new AbortController();
|
||||
activeRequest = request;
|
||||
setLoading(workspace, true);
|
||||
|
||||
try {
|
||||
const response = await window.fetch(url, {
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
Accept: 'text/html',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
signal: request.signal,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
const html = await response.text();
|
||||
const nextDocument = new DOMParser().parseFromString(html, 'text/html');
|
||||
const nextWorkspace = nextDocument.querySelector(workspaceSelector);
|
||||
|
||||
if (!nextWorkspace) {
|
||||
throw new Error('目标页面缺少营销账单工作区');
|
||||
}
|
||||
|
||||
const importedWorkspace = document.importNode(nextWorkspace, true);
|
||||
workspace.replaceWith(importedWorkspace);
|
||||
initialiseInsertedContent(importedWorkspace);
|
||||
updateHeader(nextDocument);
|
||||
|
||||
const target = new URL(url, window.location.origin);
|
||||
const relativeUrl = `${target.pathname}${target.search}${target.hash}`;
|
||||
|
||||
if (settings.pushState && relativeUrl !== `${window.location.pathname}${window.location.search}${window.location.hash}`) {
|
||||
window.history.pushState({ marketingAccountBills: true }, '', relativeUrl);
|
||||
}
|
||||
|
||||
if (settings.focus) {
|
||||
const focusTarget = importedWorkspace.querySelector(settings.focus);
|
||||
if (focusTarget) {
|
||||
window.requestAnimationFrame(() => focusTarget.focus({ preventScroll: true }));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error.name !== 'AbortError') {
|
||||
showError(workspace, url);
|
||||
}
|
||||
|
||||
return false;
|
||||
} finally {
|
||||
if (activeRequest === request) {
|
||||
activeRequest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const link = event.target.closest(
|
||||
`${workspaceSelector} .business-tab-link, `
|
||||
+ `${workspaceSelector} [data-jd-wallet-navigation], `
|
||||
+ `${workspaceSelector} .jd-wallet-pagination a`
|
||||
);
|
||||
|
||||
if (!link
|
||||
|| link.hasAttribute('data-marketing-account-bills-full-page')
|
||||
|| event.button !== 0
|
||||
|| event.metaKey
|
||||
|| event.ctrlKey
|
||||
|| event.shiftKey
|
||||
|| event.altKey
|
||||
|| link.target === '_blank'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSupportedUrl(link.href)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const focusSelector = link.classList.contains('marketing-bills-subtab')
|
||||
? '.marketing-bills-subtab.is-active'
|
||||
: '.business-tab-link.is-active';
|
||||
|
||||
navigate(link.href, { focus: focusSelector });
|
||||
}, true);
|
||||
|
||||
document.addEventListener('submit', (event) => {
|
||||
const form = event.target.closest(`${workspaceSelector} [data-jd-wallet-filter]`);
|
||||
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
const target = new URL(form.action, window.location.origin);
|
||||
|
||||
new FormData(form).forEach((value, key) => {
|
||||
const normalized = String(value).trim();
|
||||
if (normalized === '') {
|
||||
target.searchParams.delete(key);
|
||||
} else {
|
||||
target.searchParams.set(key, normalized);
|
||||
}
|
||||
});
|
||||
|
||||
target.searchParams.delete('page');
|
||||
navigate(target.href, { focus: '#jd-filter-store' });
|
||||
}, true);
|
||||
|
||||
window.addEventListener('popstate', () => {
|
||||
if (currentWorkspace() && isSupportedUrl(window.location.href)) {
|
||||
navigate(window.location.href, { pushState: false });
|
||||
}
|
||||
});
|
||||
}());
|
||||
@ -3,6 +3,15 @@
|
||||
.marketing-bills-subtabs { display: flex; gap: 8px; margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--vip-border, #D8D2C7); }
|
||||
.marketing-bills-subtab { display: inline-flex; min-height: 34px; align-items: center; gap: 6px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; padding: 0 12px; color: #595959; font-size: 0.8125rem; font-weight: 500; }
|
||||
.marketing-bills-subtab:hover, .marketing-bills-subtab.is-active { border-color: var(--vip-content-accent-dark, #856632); background: var(--vip-content-accent-soft, #F7F0DE); color: var(--vip-content-accent-dark, #856632); }
|
||||
.marketing-bills-subtab:focus-visible, .jd-wallet-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(133, 102, 50, 0.2); }
|
||||
[data-marketing-account-bills-workspace][aria-busy="true"] { cursor: progress; opacity: 0.72; }
|
||||
.jd-wallet-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
|
||||
.jd-wallet-summary-card { border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: #fff; padding: 12px 16px; }
|
||||
.jd-wallet-summary-label { color: #595959; font-size: 0.75rem; font-weight: 500; }
|
||||
.jd-wallet-summary-value { margin-top: 4px; color: #171717; font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.jd-wallet-filter { margin-bottom: 16px; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; background: var(--vip-content-bg, #F8F6F1); padding: 12px 16px; }
|
||||
.jd-wallet-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; border: 1px solid #B80000; border-radius: 8px; background: #FFF1F1; padding: 12px 16px; color: #B80000; font-size: 0.8125rem; }
|
||||
.jd-wallet-empty { padding: 40px 20px; color: #595959; text-align: center; }
|
||||
.jd-wallet-table-wrap { overflow-x: auto; border: 1px solid var(--vip-border, #D8D2C7); border-radius: 8px; }
|
||||
.jd-wallet-table { min-width: 100%; white-space: nowrap; font-size: 0.78125rem; }
|
||||
.jd-wallet-table th { position: sticky; top: 0; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--vip-border, #D8D2C7); background: var(--vip-content-accent-soft, #F7F0DE); color: #171717; font-size: 0.75rem; font-weight: 600; text-align: left; }
|
||||
@ -28,6 +37,7 @@
|
||||
.jd-wallet-pagination .pagination-xs { display: flex; width: 100%; justify-content: center; margin-top: 0; }
|
||||
.jd-wallet-pagination .pagination-xs > nav,
|
||||
.jd-wallet-pagination .pagination-xs > nav > ul { margin-right: auto; margin-left: auto; }
|
||||
@media (min-width: 640px) { .jd-wallet-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||||
</style>
|
||||
|
||||
@php
|
||||
@ -41,38 +51,45 @@
|
||||
$currentUrl = request()->url();
|
||||
@endphp
|
||||
|
||||
<div class="w-full">
|
||||
<div class="w-full" data-jd-wallet-panel>
|
||||
<nav class="marketing-bills-subtabs" aria-label="京东账单类型">
|
||||
<a href="{{ route('business.pages.show', ['section' => request()->route('section') ?? 'billing-transactions', 'page' => request()->route('page') ?? 'marketing-account-bills', 'tab' => 'jd-wallet', 'jd_ledger' => 'recharge']) }}"
|
||||
@class(['marketing-bills-subtab', 'is-active' => ! $isConsumption])>
|
||||
data-jd-wallet-navigation
|
||||
@class(['marketing-bills-subtab', 'is-active' => ! $isConsumption])
|
||||
@if (! $isConsumption) aria-current="page" @endif>
|
||||
<span class="material-icons-outlined text-base" aria-hidden="true">account_balance</span><span>充值账单</span>
|
||||
</a>
|
||||
<a href="{{ route('business.pages.show', ['section' => request()->route('section') ?? 'billing-transactions', 'page' => request()->route('page') ?? 'marketing-account-bills', 'tab' => 'jd-wallet', 'jd_ledger' => 'consumption']) }}"
|
||||
@class(['marketing-bills-subtab', 'is-active' => $isConsumption])>
|
||||
data-jd-wallet-navigation
|
||||
@class(['marketing-bills-subtab', 'is-active' => $isConsumption])
|
||||
@if ($isConsumption) aria-current="page" @endif>
|
||||
<span class="material-icons-outlined text-base" aria-hidden="true">receipt_long</span><span>消耗账单</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="mb-4 grid grid-cols-2 gap-3 sm:grid-cols-3">
|
||||
<div class="rounded-lg border border-gray-200 bg-white px-4 py-3">
|
||||
<div class="text-xs font-medium text-gray-500">{{ $isConsumption ? '消耗金额合计' : '充值金额合计' }}(万元)</div>
|
||||
<div class="mt-1 text-lg font-semibold tabular-nums">{{ number_format($amountWan, 2) }}</div>
|
||||
<div class="jd-wallet-summary-grid">
|
||||
<div class="jd-wallet-summary-card">
|
||||
<div class="jd-wallet-summary-label">{{ $isConsumption ? '消耗金额合计' : '充值金额合计' }}(万元)</div>
|
||||
<div class="jd-wallet-summary-value">{{ number_format($amountWan, 2) }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-gray-200 bg-white px-4 py-3">
|
||||
<div class="text-xs font-medium text-gray-500">余额合计(万元)</div>
|
||||
<div class="mt-1 text-lg font-semibold tabular-nums">{{ number_format($balanceWan, 2) }}</div>
|
||||
<div class="jd-wallet-summary-card">
|
||||
<div class="jd-wallet-summary-label">余额合计(万元)</div>
|
||||
<div class="jd-wallet-summary-value">{{ number_format($balanceWan, 2) }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-gray-200 bg-white px-4 py-3">
|
||||
<div class="text-xs font-medium text-gray-500">账单笔数</div>
|
||||
<div class="mt-1 text-lg font-semibold tabular-nums">{{ number_format((int) ($summary['count'] ?? 0)) }}</div>
|
||||
<div class="jd-wallet-summary-card">
|
||||
<div class="jd-wallet-summary-label">账单笔数</div>
|
||||
<div class="jd-wallet-summary-value">{{ number_format((int) ($summary['count'] ?? 0)) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (! empty($error))
|
||||
<div class="mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700" role="alert">{{ $error }}</div>
|
||||
<div class="jd-wallet-error" role="alert">
|
||||
<span>{{ $error }}</span>
|
||||
<a href="{{ request()->fullUrl() }}" data-jd-wallet-navigation>重新加载</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="GET" action="{{ $currentUrl }}" class="mb-4 rounded-lg border border-gray-200 bg-gray-50 px-4 py-3">
|
||||
<form method="GET" action="{{ $currentUrl }}" class="jd-wallet-filter" data-jd-wallet-filter>
|
||||
<input type="hidden" name="jd_ledger" value="{{ $ledger }}" />
|
||||
<div class="flex flex-wrap items-end gap-4">
|
||||
<div>
|
||||
@ -94,7 +111,7 @@
|
||||
</div>
|
||||
<div class="flex items-end gap-2">
|
||||
<button type="submit" class="jd-wallet-button jd-wallet-button-primary"><span class="material-icons text-base" aria-hidden="true">search</span>查询</button>
|
||||
<a href="{{ $currentUrl }}?jd_ledger={{ $ledger }}" class="jd-wallet-button jd-wallet-button-secondary"><span class="material-icons text-base" aria-hidden="true">clear</span>清除</a>
|
||||
<a href="{{ $currentUrl }}?jd_ledger={{ $ledger }}" data-jd-wallet-navigation class="jd-wallet-button jd-wallet-button-secondary"><span class="material-icons text-base" aria-hidden="true">clear</span>清除</a>
|
||||
</div>
|
||||
<div class="ml-auto self-center text-xs text-gray-500">共匹配 {{ $bills->total() }} 条</div>
|
||||
</div>
|
||||
@ -119,7 +136,7 @@
|
||||
@endif
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="{{ $isConsumption ? 7 : 10 }}" class="px-5 py-10 text-center text-gray-400">暂无符合条件的账单</td></tr>
|
||||
<tr><td colspan="{{ $isConsumption ? 7 : 10 }}" class="jd-wallet-empty">当前筛选条件下没有账单,可调整筛选条件后重新查询。</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -2,9 +2,8 @@
|
||||
$isMarketingAccountBillsPage = ($section['slug'] ?? null) === 'billing-transactions'
|
||||
&& ($page['slug'] ?? null) === 'marketing-account-bills';
|
||||
$marketingAccountTabTitles = [
|
||||
'taobao-alipay' => '淘系账户',
|
||||
'taobao-wechat' => '阿里巴巴账户',
|
||||
'jd-wallet' => '京东账户',
|
||||
'taobao-wechat' => 'Alibaba',
|
||||
'jd-wallet' => '京东',
|
||||
];
|
||||
$activeContentTitle = $activeTab['title'] ?? ($page['title'] ?? $section['title']);
|
||||
|
||||
@ -391,10 +390,20 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<div @class([
|
||||
'my-6',
|
||||
'business-page--marketing-account-bills' => $isMarketingAccountBillsPage,
|
||||
])>
|
||||
<div
|
||||
@class([
|
||||
'my-6',
|
||||
'business-page--marketing-account-bills' => $isMarketingAccountBillsPage,
|
||||
])
|
||||
@if ($isMarketingAccountBillsPage) data-marketing-account-bills-workspace @endif
|
||||
>
|
||||
@if ($isMarketingAccountBillsPage)
|
||||
<p class="sr-only" role="status" aria-live="polite" data-marketing-account-bills-status></p>
|
||||
<div class="biz-alert biz-alert-error" role="alert" data-marketing-account-bills-navigation-error hidden>
|
||||
<span>账单内容局部加载失败,当前页面内容已保留。</span>
|
||||
<a href="{{ request()->fullUrl() }}" data-marketing-account-bills-retry data-marketing-account-bills-full-page>重新加载</a>
|
||||
</div>
|
||||
@endif
|
||||
@if (is_string(session('success')))
|
||||
<div class="biz-alert" role="status">{{ session('success') }}</div>
|
||||
@endif
|
||||
@ -714,7 +723,11 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if (($page['slug'] ?? null) === 'store-receiving-bills')
|
||||
@if ($isMarketingAccountBillsPage)
|
||||
@push('scripts_start')
|
||||
<script src="{{ asset('public/js/business/marketing-account-bills.min.js') }}?id={{ md5_file(public_path('js/business/marketing-account-bills.min.js')) }}"></script>
|
||||
@endpush
|
||||
@elseif (($page['slug'] ?? null) === 'store-receiving-bills')
|
||||
@push('scripts_start')
|
||||
<script src="{{ asset('public/js/business/pages.min.js') }}?id={{ md5_file(public_path('js/business/pages.min.js')) }}"></script>
|
||||
@endpush
|
||||
|
||||
@ -153,6 +153,7 @@ $jsCacheValid = Test-CacheFingerprint `
|
||||
-Expected $jsFingerprint `
|
||||
-RequiredOutputs @(
|
||||
(Join-Path $frontendOutputRoot 'js/auth/common.min.js'),
|
||||
(Join-Path $frontendOutputRoot 'js/business/marketing-account-bills.min.js'),
|
||||
(Join-Path $frontendOutputRoot 'js/manifest.js'),
|
||||
(Join-Path $frontendOutputRoot 'js/vendor.js'),
|
||||
(Join-Path $cachedVendorPath 'apexcharts/apexcharts.min.js'),
|
||||
@ -261,6 +262,7 @@ try {
|
||||
|
||||
foreach ($output in @(
|
||||
'public/js/auth/common.min.js',
|
||||
'public/js/business/marketing-account-bills.min.js',
|
||||
'public/js/manifest.js',
|
||||
'public/js/vendor.js',
|
||||
'public/mix-manifest.json'
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
namespace Tests\Feature\Business;
|
||||
|
||||
use App\Models\Auth\Permission;
|
||||
use Mockery;
|
||||
use Modules\EcommerceFinance\Repositories\JdWalletBillRepository;
|
||||
use Modules\EcommerceFinance\Services\UpstreamQueryCache;
|
||||
use Modules\EcommerceFinance\Services\UpstreamQueryCacheFactory;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class MarketingAccountBillsTabsTest extends FeatureTestCase
|
||||
@ -18,10 +23,10 @@ class MarketingAccountBillsTabsTest extends FeatureTestCase
|
||||
'tab' => 'taobao-wechat',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('淘系账户')
|
||||
->assertSeeText('阿里巴巴账户')
|
||||
->assertSeeText('京东账户')
|
||||
->assertDontSeeText('淘系支付宝账户')
|
||||
->assertSeeText('淘系支付宝账户')
|
||||
->assertSeeText('Alibaba')
|
||||
->assertSeeText('京东')
|
||||
->assertDontSeeText('淘系微信账户')
|
||||
->assertDontSeeText('京东网银钱包账户')
|
||||
->assertSee('class="my-6 business-page--marketing-account-bills"', false);
|
||||
}
|
||||
@ -43,7 +48,9 @@ class MarketingAccountBillsTabsTest extends FeatureTestCase
|
||||
->assertSeeText('消耗账单')
|
||||
->assertSeeText('金额(元)')
|
||||
->assertSeeText('充值时间')
|
||||
->assertDontSeeText('投放日期');
|
||||
->assertDontSeeText('投放日期')
|
||||
->assertSee('data-jd-wallet-panel', false)
|
||||
->assertSee('data-jd-wallet-navigation', false);
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', array_merge($base, ['jd_ledger' => 'consumption'])))
|
||||
@ -56,6 +63,56 @@ class MarketingAccountBillsTabsTest extends FeatureTestCase
|
||||
->assertDontSeeText('充值时间');
|
||||
}
|
||||
|
||||
public function testJdWalletColdStartRegistersEveryRequiredSnapshotScope(): void
|
||||
{
|
||||
$this->allowMarketingAccountBillsPage();
|
||||
$scopes = [];
|
||||
$cache = Mockery::mock(UpstreamQueryCache::class);
|
||||
$cache->shouldReceive('remember')
|
||||
->times(3)
|
||||
->andReturnUsing(function (string $scope, array $parameters, callable $resolver) use (&$scopes): array {
|
||||
$scopes[] = $scope;
|
||||
|
||||
if (count($scopes) === 1) {
|
||||
throw new ServiceUnavailableHttpException(30, '首份共享快照正在准备。');
|
||||
}
|
||||
|
||||
return match ($scope) {
|
||||
'jd-wallet-bills.recharge.summary' => [
|
||||
'amount_total' => 0,
|
||||
'balance_total' => 0,
|
||||
'count' => 0,
|
||||
],
|
||||
'jd-wallet-bills.options' => [],
|
||||
default => ['rows' => [], 'total' => 0],
|
||||
};
|
||||
});
|
||||
|
||||
$factory = Mockery::mock(UpstreamQueryCacheFactory::class);
|
||||
$factory->shouldReceive('forSource')
|
||||
->once()
|
||||
->with('jiansun')
|
||||
->andReturn($cache);
|
||||
|
||||
$this->app->instance(UpstreamQueryCacheFactory::class, $factory);
|
||||
$this->app->instance(JdWalletBillRepository::class, Mockery::mock(JdWalletBillRepository::class));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
'section' => 'billing-transactions',
|
||||
'page' => 'marketing-account-bills',
|
||||
'tab' => 'jd-wallet',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('首份共享快照正在准备。');
|
||||
|
||||
$this->assertSame([
|
||||
'jd-wallet-bills.recharge.list',
|
||||
'jd-wallet-bills.recharge.summary',
|
||||
'jd-wallet-bills.options',
|
||||
], $scopes);
|
||||
}
|
||||
|
||||
private function allowMarketingAccountBillsPage(): void
|
||||
{
|
||||
$this->user->update(['locale' => 'zh-CN']);
|
||||
|
||||
@ -75,5 +75,7 @@ class JdWalletBillRepositoryTest extends TestCase
|
||||
$this->assertSame('推广费开票', $consumption['rows'][0]['notes']);
|
||||
$this->assertSame(12.35, $summary['amount_total']);
|
||||
$this->assertStringContainsString('ABS(amount)', $query->calls[4]['sql']);
|
||||
$this->assertStringContainsString('< DATEADD(day, 1, CAST(? AS date))', $query->calls[0]['sql']);
|
||||
$this->assertSame(['2026-08-03 00:00:00', '2026-08-03'], $query->calls[0]['bindings']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ use Modules\EcommerceFinance\Repositories\AlibabaBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\EdgeBandingRepository;
|
||||
use Modules\EcommerceFinance\Repositories\GoodsReconciliationRepository;
|
||||
use Modules\EcommerceFinance\Repositories\InventoryRepository;
|
||||
use Modules\EcommerceFinance\Repositories\JdWalletBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\PinduoduoSpreadBillRepository;
|
||||
use Modules\EcommerceFinance\Repositories\ProductPriceRepository;
|
||||
use Modules\EcommerceFinance\Repositories\RawBoardPayablesRepository;
|
||||
@ -217,6 +218,141 @@ class JianSunSnapshotRefresherTest extends TestCase
|
||||
$this->assertSame([['supplier' => '测试厂'], 2, 50], $rawBoardPayables->arguments);
|
||||
}
|
||||
|
||||
public function test_jd_wallet_scopes_are_available_to_background_refresh(): void
|
||||
{
|
||||
$jdWallet = new class extends JdWalletBillRepository {
|
||||
public array $calls = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function paginateConsumption(
|
||||
?string $shopName = null,
|
||||
?string $fromDate = null,
|
||||
?string $toDate = null,
|
||||
int $page = 1,
|
||||
int $pageSize = 25,
|
||||
): array {
|
||||
$this->calls['consumption.list'] = func_get_args();
|
||||
|
||||
return ['rows' => [], 'total' => 0];
|
||||
}
|
||||
|
||||
public function paginateRecharge(
|
||||
?string $shopName = null,
|
||||
?string $fromDate = null,
|
||||
?string $toDate = null,
|
||||
int $page = 1,
|
||||
int $pageSize = 25,
|
||||
): array {
|
||||
$this->calls['recharge.list'] = func_get_args();
|
||||
|
||||
return ['rows' => [], 'total' => 0];
|
||||
}
|
||||
|
||||
public function summaryConsumption(
|
||||
?string $shopName = null,
|
||||
?string $fromDate = null,
|
||||
?string $toDate = null,
|
||||
): array {
|
||||
$this->calls['consumption.summary'] = func_get_args();
|
||||
|
||||
return ['amount_total' => 0, 'balance_total' => 0, 'count' => 0];
|
||||
}
|
||||
|
||||
public function summaryRecharge(
|
||||
?string $shopName = null,
|
||||
?string $fromDate = null,
|
||||
?string $toDate = null,
|
||||
): array {
|
||||
$this->calls['recharge.summary'] = func_get_args();
|
||||
|
||||
return ['amount_total' => 0, 'balance_total' => 0, 'count' => 0];
|
||||
}
|
||||
|
||||
public function shopOptions(): array
|
||||
{
|
||||
$this->calls['options'] = [];
|
||||
|
||||
return ['测试京东店铺'];
|
||||
}
|
||||
};
|
||||
|
||||
$refresher = $this->refresher(jdWallet: $jdWallet);
|
||||
$rechargeStatus = $refresher->refresh([
|
||||
'scope' => 'jd-wallet-bills.recharge.list',
|
||||
'parameters' => [
|
||||
'filters' => [
|
||||
'store_name' => '测试京东店铺',
|
||||
'from' => '2026-08-01',
|
||||
'to' => '2026-08-10',
|
||||
],
|
||||
'page' => 2,
|
||||
'limit' => 50,
|
||||
],
|
||||
]);
|
||||
$consumptionSummaryStatus = $refresher->refresh([
|
||||
'scope' => 'jd-wallet-bills.consumption.summary',
|
||||
'parameters' => [
|
||||
'filters' => [
|
||||
'store_name' => '测试京东店铺',
|
||||
'from' => '2026-08-01',
|
||||
'to' => '2026-08-10',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$rechargeSummaryStatus = $refresher->refresh([
|
||||
'scope' => 'jd-wallet-bills.recharge.summary',
|
||||
'parameters' => [
|
||||
'filters' => [
|
||||
'store_name' => '测试京东店铺',
|
||||
'from' => '2026-08-01',
|
||||
'to' => '2026-08-10',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$consumptionListStatus = $refresher->refresh([
|
||||
'scope' => 'jd-wallet-bills.consumption.list',
|
||||
'parameters' => [
|
||||
'filters' => [
|
||||
'store_name' => '测试京东店铺',
|
||||
'from' => '2026-08-01',
|
||||
'to' => '2026-08-10',
|
||||
],
|
||||
'page' => 3,
|
||||
'limit' => 25,
|
||||
],
|
||||
]);
|
||||
$optionsStatus = $refresher->refresh([
|
||||
'scope' => 'jd-wallet-bills.options',
|
||||
'parameters' => [],
|
||||
]);
|
||||
|
||||
$this->assertSame('fresh', $rechargeStatus);
|
||||
$this->assertSame('fresh', $consumptionSummaryStatus);
|
||||
$this->assertSame('fresh', $rechargeSummaryStatus);
|
||||
$this->assertSame('fresh', $consumptionListStatus);
|
||||
$this->assertSame('fresh', $optionsStatus);
|
||||
$this->assertSame(
|
||||
['测试京东店铺', '2026-08-01', '2026-08-10', 2, 50],
|
||||
$jdWallet->calls['recharge.list'],
|
||||
);
|
||||
$this->assertSame(
|
||||
['测试京东店铺', '2026-08-01', '2026-08-10'],
|
||||
$jdWallet->calls['consumption.summary'],
|
||||
);
|
||||
$this->assertSame(
|
||||
['测试京东店铺', '2026-08-01', '2026-08-10'],
|
||||
$jdWallet->calls['recharge.summary'],
|
||||
);
|
||||
$this->assertSame(
|
||||
['测试京东店铺', '2026-08-01', '2026-08-10', 3, 25],
|
||||
$jdWallet->calls['consumption.list'],
|
||||
);
|
||||
$this->assertSame([], $jdWallet->calls['options']);
|
||||
}
|
||||
|
||||
private function refresher(
|
||||
?InventoryRepository $inventory = null,
|
||||
?AlibabaBillRepository $alibaba = null,
|
||||
@ -225,6 +361,7 @@ class JianSunSnapshotRefresherTest extends TestCase
|
||||
?RawBoardPayablesRepository $rawBoardPayables = null,
|
||||
?TmallTaobaoSpreadBillRepository $taobaoAlipay = null,
|
||||
?SupplierPayableReportRepository $supplierPayableReports = null,
|
||||
?JdWalletBillRepository $jdWallet = null,
|
||||
): JianSunSnapshotRefresher {
|
||||
return new JianSunSnapshotRefresher(
|
||||
new class extends JianSunQueryCache {
|
||||
@ -251,6 +388,7 @@ class JianSunSnapshotRefresherTest extends TestCase
|
||||
$taobaoAlipay ?? $this->placeholder(TmallTaobaoSpreadBillRepository::class),
|
||||
$this->placeholder(SupplierPayableRepository::class),
|
||||
$supplierPayableReports ?? $this->placeholder(SupplierPayableReportRepository::class),
|
||||
$jdWallet ?? $this->placeholder(JdWalletBillRepository::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
1
webpack.mix.js
vendored
1
webpack.mix.js
vendored
@ -72,6 +72,7 @@ if (buildJavaScript) {
|
||||
|
||||
// Business workspace(店铺管理 › 各子功能)
|
||||
.js('resources/assets/js/views/business/pages.js', 'public/js/business/pages.min.js')
|
||||
.js('resources/assets/js/views/business/marketing-account-bills.js', 'public/js/business/marketing-account-bills.min.js')
|
||||
|
||||
// Ecommerce Finance
|
||||
.js('resources/assets/js/views/ecommerce-finance/goods-reconciliations.js', 'public/js/ecommerce-finance/goods-reconciliations.min.js')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user