CaiWuXiTong/resources/views/business/pages/posting-data/kuka-store-performance.blade.php
chenxi 814f9a4520 feat: 汇总灵珊店铺月度收入 (#1060)
feat: 汇总灵珊店铺月度收入 (#1060)
2026-11-10 19:19:34 +08:00

424 lines
16 KiB
PHP

@php
$performance = $kukaStorePerformance ?? [];
$summary = $performance['summary'] ?? [];
$stores = $performance['stores'] ?? [];
$months = $performance['months'] ?? [];
$monthlyTotals = $performance['monthly_totals'] ?? [];
$selectedMonth = $performance['month'] ?? '';
$error = $performance['error'] ?? null;
$money = static fn (mixed $value): string => ((float) $value < 0 ? '-¥' : '¥')
. number_format(abs((float) $value), 2);
$monthUrl = static fn (string $month): string => route('business.pages.show', [
'section' => 'posting-data',
'page' => 'kuka-basic-data',
'submenu' => 'performance',
'month' => $month,
]);
@endphp
<style>
.kuka-performance-page {
--kp-gold: var(--vip-content-accent, #b9954f);
--kp-gold-dark: var(--vip-content-accent-dark, #856632);
--kp-gold-soft: var(--vip-content-accent-soft, #f7f0de);
--kp-border: var(--vip-border, #d8d2c7);
--kp-ink: var(--vip-content-ink, #171717);
--kp-muted: var(--vip-content-muted, #595959);
display: grid;
gap: 16px;
color: var(--kp-ink);
}
.kuka-performance-page * { box-sizing: border-box; }
.kuka-performance-toolbar {
display: flex;
align-items: end;
justify-content: space-between;
gap: 16px;
padding: 14px 16px;
border: 1px solid var(--kp-border);
border-radius: 12px;
background: #fff;
}
.kuka-performance-toolbar__scope {
display: grid;
gap: 4px;
}
.kuka-performance-toolbar__scope strong {
font-size: 13px;
font-weight: 600;
}
.kuka-performance-toolbar__scope span {
color: var(--kp-muted);
font-size: 11px;
line-height: 1.5;
}
.kuka-performance-month-form {
display: flex;
align-items: end;
gap: 8px;
}
.kuka-performance-month-form label {
display: grid;
gap: 4px;
color: var(--kp-muted);
font-size: 11px;
font-weight: 500;
}
.kuka-performance-month-form select {
width: 132px;
height: 34px;
padding: 0 10px;
border: 1px solid var(--kp-border);
border-radius: 8px;
background: #fff;
color: var(--kp-ink);
font: inherit;
font-size: 12px;
}
.kuka-performance-month-form button {
height: 34px;
padding: 0 14px;
border: 1px solid var(--kp-gold-dark);
border-radius: 8px;
background: var(--kp-gold-dark);
color: #fff;
font: inherit;
font-size: 12px;
cursor: pointer;
}
.kuka-performance-alert {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border: 1px solid #dfbbbb;
border-radius: 8px;
background: #fff4f4;
color: var(--vip-danger, #b80000);
font-size: 12px;
}
.kuka-performance-alert .material-icons-outlined { font-size: 18px; }
.kuka-performance-cards {
display: grid;
grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
gap: 10px;
}
.kuka-performance-card {
min-width: 0;
padding: 14px 16px;
border: 1px solid var(--kp-border);
border-radius: 12px;
background: #fffdf8;
}
.kuka-performance-card--primary {
border-color: #d9c89c;
background: var(--kp-gold-soft);
}
.kuka-performance-card span {
display: block;
color: var(--kp-muted);
font-size: 11px;
line-height: 1.4;
}
.kuka-performance-card strong {
display: block;
margin-top: 5px;
overflow: hidden;
color: var(--kp-ink);
font-size: 20px;
font-weight: 700;
line-height: 1.25;
text-overflow: ellipsis;
white-space: nowrap;
}
.kuka-performance-card--primary strong {
color: var(--kp-gold-dark);
font-size: 24px;
}
.kuka-performance-card small {
display: block;
margin-top: 5px;
color: var(--kp-muted);
font-size: 10px;
line-height: 1.4;
}
.kuka-performance-components {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
overflow: hidden;
border: 1px solid var(--kp-border);
border-radius: 12px;
background: #fff;
}
.kuka-performance-component {
min-width: 0;
padding: 12px 14px;
border-right: 1px solid var(--kp-border);
}
.kuka-performance-component:last-child { border-right: 0; }
.kuka-performance-component span {
display: block;
color: var(--kp-muted);
font-size: 10px;
line-height: 1.4;
}
.kuka-performance-component strong {
display: block;
margin-top: 4px;
font-size: 13px;
font-variant-numeric: tabular-nums;
line-height: 1.4;
white-space: nowrap;
}
.kuka-performance-section {
overflow: hidden;
border: 1px solid var(--kp-border);
border-radius: 12px;
background: #fff;
}
.kuka-performance-section__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 14px;
border-bottom: 1px solid var(--kp-border);
}
.kuka-performance-section__head strong {
font-size: 12px;
font-weight: 600;
}
.kuka-performance-section__head span {
color: var(--kp-muted);
font-size: 10px;
}
.kuka-performance-table-wrap { overflow-x: auto; }
.kuka-performance-table {
width: 100%;
min-width: 920px;
border-collapse: collapse;
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.kuka-performance-table th,
.kuka-performance-table td {
padding: 9px 12px;
border-bottom: 1px solid #ece7dd;
text-align: right;
white-space: nowrap;
}
.kuka-performance-table th {
background: #faf6eb;
color: var(--kp-muted);
font-size: 11px;
font-weight: 600;
}
.kuka-performance-table th:first-child,
.kuka-performance-table td:first-child {
text-align: left;
}
.kuka-performance-table tbody tr:hover {
background: #fcf8ee;
}
.kuka-performance-table tbody tr.is-selected {
background: var(--kp-gold-soft);
}
.kuka-performance-table tfoot td {
border-top: 1px solid #d9c89c;
border-bottom: 0;
background: #fbf7ec;
color: var(--kp-ink);
font-weight: 600;
}
.kuka-performance-table .is-negative { color: var(--vip-danger, #b80000); }
.kuka-performance-month-link {
color: var(--kp-gold-dark);
font-weight: 600;
text-decoration: none;
}
.kuka-performance-month-link:hover { text-decoration: underline; }
.kuka-performance-empty {
padding: 24px;
color: var(--kp-muted);
font-size: 12px;
text-align: center;
}
@media (max-width: 1120px) {
.kuka-performance-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kuka-performance-components { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kuka-performance-component:nth-child(3) { border-right: 0; }
.kuka-performance-component:nth-child(n + 4) { border-top: 1px solid var(--kp-border); }
}
@media (max-width: 700px) {
.kuka-performance-toolbar { align-items: stretch; flex-direction: column; }
.kuka-performance-month-form { flex-wrap: wrap; }
.kuka-performance-cards { grid-template-columns: 1fr; }
.kuka-performance-components { grid-template-columns: 1fr; }
.kuka-performance-component { border-right: 0; border-bottom: 1px solid var(--kp-border); }
.kuka-performance-component:last-child { border-bottom: 0; }
}
</style>
<div class="kuka-performance-page">
<div class="kuka-performance-toolbar">
<div class="kuka-performance-toolbar__scope">
<strong>灵珊店铺业绩 · 月度收入</strong>
<span>收入 = 账单收入 + 优惠金额 + 冲减金额 + 退款金额 + 违约赔付(冲减收入)</span>
</div>
<form
class="kuka-performance-month-form"
method="GET"
action="{{ route('business.pages.show', ['section' => 'posting-data', 'page' => 'kuka-basic-data']) }}"
>
<input type="hidden" name="submenu" value="performance">
<label>
账期
<select name="month" @disabled($months === [])>
@foreach ($months as $month)
<option value="{{ $month }}" @selected($selectedMonth === $month)>
{{ substr($month, 0, 4) }}年{{ (int) substr($month, 5, 2) }}月
</option>
@endforeach
</select>
</label>
<button type="submit">查询</button>
</form>
</div>
@if ($error)
<div class="kuka-performance-alert" role="alert">
<span class="material-icons-outlined" aria-hidden="true">error_outline</span>
<span>{{ $error }}</span>
</div>
@endif
<section class="kuka-performance-cards" aria-label="{{ $performance['month_label'] ?? '当月' }}收入汇总">
<article class="kuka-performance-card kuka-performance-card--primary">
<span>{{ $performance['month_label'] ?? '当月' }}合计收入</span>
<strong>{{ $money($summary['total_income'] ?? 0) }}</strong>
<small>12 家指定店铺的月度总收入</small>
</article>
<article class="kuka-performance-card">
<span>有数据店铺</span>
<strong>{{ number_format((int) ($summary['stores_with_data'] ?? 0)) }} / {{ count($stores) }}</strong>
<small>其余店铺按 0 展示</small>
</article>
<article class="kuka-performance-card">
<span>明细行数</span>
<strong>{{ number_format((int) ($summary['row_count'] ?? 0)) }}</strong>
<small>业绩明细订单级数据</small>
</article>
<article class="kuka-performance-card">
<span>最近同步</span>
<strong>
{{ $summary['imported_at'] ? \Illuminate\Support\Carbon::parse($summary['imported_at'])->format('Y-m-d H:i') : '—' }}
</strong>
<small>共享业务镜像</small>
</article>
</section>
<section class="kuka-performance-components" aria-label="收入构成">
<div class="kuka-performance-component">
<span>账单收入</span>
<strong>{{ $money($summary['income_amount'] ?? 0) }}</strong>
</div>
<div class="kuka-performance-component">
<span>优惠金额</span>
<strong>{{ $money($summary['discount_amount'] ?? 0) }}</strong>
</div>
<div class="kuka-performance-component">
<span>冲减金额</span>
<strong>{{ $money($summary['offset_amount'] ?? 0) }}</strong>
</div>
<div class="kuka-performance-component">
<span>退款金额</span>
<strong>{{ $money($summary['refund_amount'] ?? 0) }}</strong>
</div>
<div class="kuka-performance-component">
<span>违约赔付(冲减收入)</span>
<strong>{{ $money($summary['default_compensation_amount'] ?? 0) }}</strong>
</div>
</section>
<section class="kuka-performance-section" aria-label="月度收入合计">
<header class="kuka-performance-section__head">
<strong>月度收入合计</strong>
<span>12 家指定店铺 · 点击月份查看明细</span>
</header>
@if ($monthlyTotals === [])
<div class="kuka-performance-empty">暂无可汇总的月度业绩明细。</div>
@else
<div class="kuka-performance-table-wrap">
<table class="kuka-performance-table">
<thead>
<tr>
<th>账期</th>
<th>明细行数</th>
<th>合计收入</th>
</tr>
</thead>
<tbody>
@foreach ($monthlyTotals as $monthRow)
<tr @class(['is-selected' => $selectedMonth === $monthRow['month']])>
<td>
<a class="kuka-performance-month-link" href="{{ $monthUrl($monthRow['month']) }}">
{{ $monthRow['label'] }}
</a>
</td>
<td>{{ number_format((int) $monthRow['row_count']) }}</td>
<td>{{ $money($monthRow['total_income']) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</section>
<section class="kuka-performance-section" aria-label="店铺收入明细">
<header class="kuka-performance-section__head">
<strong>{{ $performance['month_label'] ?? '当月' }}店铺收入明细</strong>
<span>金额单位:元</span>
</header>
<div class="kuka-performance-table-wrap">
<table class="kuka-performance-table">
<thead>
<tr>
<th>店铺</th>
<th>账单收入</th>
<th>优惠金额</th>
<th>冲减金额</th>
<th>退款金额</th>
<th>违约赔付(冲减收入)</th>
<th>合计收入</th>
</tr>
</thead>
<tbody>
@foreach ($stores as $store)
<tr>
<td>{{ $store['store_name'] }}</td>
<td>{{ $money($store['income_amount']) }}</td>
<td>{{ $money($store['discount_amount']) }}</td>
<td @class(['is-negative' => (float) $store['offset_amount'] < 0])>{{ $money($store['offset_amount']) }}</td>
<td @class(['is-negative' => (float) $store['refund_amount'] < 0])>{{ $money($store['refund_amount']) }}</td>
<td @class(['is-negative' => (float) $store['default_compensation_amount'] < 0])>{{ $money($store['default_compensation_amount']) }}</td>
<td @class(['is-negative' => (float) $store['total_income'] < 0])><strong>{{ $money($store['total_income']) }}</strong></td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td>合计</td>
<td>{{ $money($summary['income_amount'] ?? 0) }}</td>
<td>{{ $money($summary['discount_amount'] ?? 0) }}</td>
<td>{{ $money($summary['offset_amount'] ?? 0) }}</td>
<td>{{ $money($summary['refund_amount'] ?? 0) }}</td>
<td>{{ $money($summary['default_compensation_amount'] ?? 0) }}</td>
<td>{{ $money($summary['total_income'] ?? 0) }}</td>
</tr>
</tfoot>
</table>
</div>
</section>
</div>