manghe/app/admin/view/Statistics/productsOverview.html
2025-04-19 19:53:16 +08:00

187 lines
12 KiB
HTML

{include file="Public:header2"/}
<body>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-header">
出货概览 - {$boxInfo.title|default='未知盒子'}
</div>
<div class="layui-card-body">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<?php
// 预先计算总出货数量
$totalCount = 0;
$totalValue = 0;
foreach($list as $item) {
$totalCount += isset($item['goods_count']) ? $item['goods_count'] : 0;
$money = isset($item['money']) ? $item['money'] : 0;
$goods_count = isset($item['goods_count']) ? $item['goods_count'] : 0;
$totalValue += $money * $goods_count;
}
?>
<!-- 统计摘要 -->
{if condition="!empty($list)"}
<div class="layui-card" style="margin-bottom: 20px;">
<div class="layui-card-header">统计摘要</div>
<div class="layui-card-body">
<div class="layui-row layui-col-space15">
<div class="layui-col-md6">
<div class="layui-card">
<div class="layui-card-header">总出货数量</div>
<div class="layui-card-body" style="font-size: 24px; color: #01AAED;">
{$totalCount}
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-card">
<div class="layui-card-header">总出货价值</div>
<div class="layui-card-body" style="font-size: 24px; color: #FF5722;">
¥ {$totalValue|round=2}
</div>
</div>
</div>
</div>
<?php if($totalCount > 0): ?>
<div class="layui-row layui-col-space15" style="margin-top: 15px;">
<div class="layui-col-md4">
<div class="layui-card">
<div class="layui-card-header">平均每次出货价值/盒子单价</div>
<div class="layui-card-body" style="font-size: 24px; color: #01AAED;">
¥ <?php echo round($totalValue / $totalCount, 2); ?>/
<?php echo round($boxInfo['price']); ?>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-card">
<div class="layui-card-header">平均出货价值/盒子单价</div>
<div class="layui-card-body" style="font-size: 24px; color: #FF5722;">
<?php
$avgValue = $totalValue / $totalCount;
$boxPrice = isset($boxInfo['price']) ? $boxInfo['price'] : 0;
$ratio = $boxPrice > 0 ? round(($avgValue / $boxPrice), 2) : 0;
echo $ratio . ' 倍';
?>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-card">
<div class="layui-card-header">数据分析</div>
<div class="layui-card-body">
<?php
// 寻找出货金额最多的奖品
$maxValue = 0;
$maxItem = null;
foreach($list as $item) {
$goods_count = isset($item['goods_count']) ? $item['goods_count'] : 0;
$money = isset($item['money']) ? $item['money'] : 0;
$itemValue = $money * $goods_count;
if($itemValue > $maxValue) {
$maxValue = $itemValue;
$maxItem = $item;
}
}
if($maxItem) {
$goods_count = isset($maxItem['goods_count']) ? $maxItem['goods_count'] : 0;
$money = isset($maxItem['money']) ? $maxItem['money'] : 0;
$itemValue = $money * $goods_count;
echo "<p>出货金额最多的奖品: <strong>".$maxItem['title']."</strong> (¥".round($itemValue, 2).")</p>";
// 计算占总金额的百分比
$valuePercent = $totalValue > 0 ? round(($itemValue / $totalValue) * 100, 2) : 0;
echo "<p>占总出货金额的: <span style=\"color: #01AAED; font-weight: bold;\">".$valuePercent."%</span></p>";
}
?>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
{/if}
<table class="layui-table">
<thead>
<tr>
<th>奖品ID</th>
<th>奖品类型</th>
<th>奖品名称</th>
<th>奖品图片</th>
<th>出货数量</th>
<th>奖品单价</th>
<th>兑换金额</th>
<th>理论概率</th>
<th>实际概率</th>
<th>概率偏差</th>
<th>总价值</th>
</tr>
</thead>
<tbody>
{volist name="list" id="vo"}
<tr>
<td>{$vo.goodslist_id}</td>
<td>{$vo.shang_id|default="0"}</td>
<td>{$vo.title}</td>
<td>
<img src="{$vo.imgurl}" style="height:50px;" onerror="this.src='/static/admin/images/nopic.jpg'">
</td>
<td>
<span class="layui-badge layui-bg-blue">{$vo.goods_count}</span>
</td>
<td>¥ {$vo.price|default="0"}</td>
<td>¥ {$vo.money|default="0"}</td>
<td>
<span class="layui-badge layui-bg-green">{$vo.real_pro|default="0"}%</span>
</td>
<td>
<?php
$actual_percent = 0;
if(!empty($totalCount) && $totalCount > 0) {
$goods_count = isset($vo['goods_count']) ? $vo['goods_count'] : 0;
$actual_percent = round(($goods_count / $totalCount) * 100, 2);
}
?>
<span class="layui-badge layui-bg-orange">{$actual_percent}%</span>
</td>
<td>
<?php
$real_pro = isset($vo['real_pro']) ? $vo['real_pro'] : 0;
$diff = round($actual_percent - $real_pro, 2);
$color = $diff >= 0 ? '#5FB878' : '#FF5722';
$sign = $diff > 0 ? '+' : '';
?>
<span style="color: <?php echo $color; ?>; font-weight: bold;"><?php echo $sign.$diff; ?>%</span>
</td>
<td>
<?php
$money = isset($vo['money']) ? $vo['money'] : 0;
$goods_count = isset($vo['goods_count']) ? $vo['goods_count'] : 0;
$total_value = $money * $goods_count;
?>
¥ <?php echo round($total_value, 2); ?>
</td>
</tr>
{/volist}
{if condition="empty($list)"}
<tr>
<td colspan="9" style="text-align:center;">暂时没有数据!</td>
</tr>
{/if}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{include file="Public:footer"/}
</body>
</html>