@extends('base.base') @section('base')

1234 权重配置 & 数据统计

配置 1/2/3/4 权重;带 show 只记曝光;每日明细 Redis 保留约 3 天
@php $totalWeight = array_sum($config); @endphp
当前总权重: {{ $totalWeight }} ,前端按权重比例随机返回 1/2/3/4
@foreach([1,2,3,4] as $id) @php $w = intval($config[$id] ?? 0); $percent = $totalWeight > 0 ? round($w / $totalWeight * 100, 2) : 0; @endphp @endforeach
ID 权重 (整数) 占比
{{ $id }} {{ $percent }}%
@php $chartIds = [1, 2, 3, 4]; $chartTodayShows = array_map(fn ($id) => (int) ($todayShows[$id] ?? 0), $chartIds); $chartTodayClicks = array_map(fn ($id) => (int) ($todayClicks[$id] ?? 0), $chartIds); $chartTotalShows = array_map(fn ($id) => (int) ($totalShows[$id] ?? 0), $chartIds); $chartTotalClicks = array_map(fn ($id) => (int) ($totalClicks[$id] ?? 0), $chartIds); @endphp
曝光 & 点击(按 ID)

当天数据 · {{ date('Y-m-d') }}

曝光(show) 点击
总计(Redis 累计)
@php $totalClicksAll = array_sum($totalClicks); $totalShowsAll = array_sum($totalShows); @endphp
@foreach([1,2,3,4] as $id) @php $c = intval($totalClicks[$id] ?? 0); $s = intval($totalShows[$id] ?? 0); $pShow = $totalShowsAll > 0 ? round($s / $totalShowsAll * 100, 2) : 0; $ctrPct = $s > 0 ? round($c / $s * 100, 2) : null; @endphp @endforeach @php $ctrAll = $totalShowsAll > 0 ? round($totalClicksAll / $totalShowsAll * 100, 2) : null; @endphp
ID 曝光 曝光% 点击 点击率(%) 操作
{{ $id }} {{ $s }} {{ $pShow }}% {{ $c }} {{ $ctrPct !== null ? $ctrPct . '%' : '—' }}
合计 {{ $totalShowsAll }} {{ $totalClicksAll }}{{ $ctrAll !== null ? $ctrAll . '%' : '—' }}
最近 3 天每日(曝光 / 点击)
@foreach([1,2,3,4] as $hid) @endforeach @foreach($dailyClicks as $idx => $row) @php $rowS = $dailyShows[$idx] ?? ['date' => $row['date'], 1=>0,2=>0,3=>0,4=>0]; $sumShow = 0; $sumClick = 0; @endphp @foreach([1,2,3,4] as $hid) @php $sv = intval($rowS[$hid] ?? 0); $cv = intval($row[$hid] ?? 0); $sumShow += $sv; $sumClick += $cv; $cellCtr = $sv > 0 ? round($cv / $sv * 100, 2) : null; @endphp @endforeach @php $dayCtr = $sumShow > 0 ? round($sumClick / $sumShow * 100, 2) : null; @endphp @endforeach
日期{{ $hid }}曝光∑ 点击∑ 点击率(%)
{{ $row['date'] }} {{ $sv }} / {{ $cv }} @if($cellCtr !== null)
CTR {{ $cellCtr }}%
@elseif($cv > 0)
CTR —
@endif
{{ $sumShow }} {{ $sumClick }} {{ $dayCtr !== null ? $dayCtr . '%' : '—' }}
@endsection