迁移游戏配置手动操作

This commit is contained in:
2026-04-25 13:23:20 +08:00
parent 85a419fe53
commit 4751a5578e
2 changed files with 245 additions and 152 deletions
@@ -157,19 +157,22 @@
<div class="mt-4 pt-4 border-t border-gray-100">
<div class="text-xs font-bold text-gray-600 mb-2">🎯 手动投放箱子</div>
<div class="flex items-center gap-3 flex-wrap">
<button onclick="dropBox('normal', {{ $game->id }})"
style="padding:8px 16px; background:linear-gradient(135deg,#059669,#10b981); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-drop-box-type="normal"
data-game-drop-box-url="{{ route('admin.mystery-box.drop') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#059669,#10b981); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
📦 投放普通箱
</button>
<button onclick="dropBox('rare', {{ $game->id }})"
style="padding:8px 16px; background:linear-gradient(135deg,#7c3aed,#a78bfa); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-drop-box-type="rare"
data-game-drop-box-url="{{ route('admin.mystery-box.drop') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#7c3aed,#a78bfa); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
💎 投放稀有箱
</button>
<button onclick="dropBox('trap', {{ $game->id }})"
style="padding:8px 16px; background:linear-gradient(135deg,#7f1d1d,#ef4444); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-drop-box-type="trap"
data-game-drop-box-url="{{ route('admin.mystery-box.drop') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#7f1d1d,#ef4444); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
☠️ 投放黑化箱
</button>
<span class="text-xs text-gray-400">直接向 #1 房间投放,立即广播暗号</span>
@@ -187,19 +190,19 @@
<span class="text-red-400"> 点击下方「加载期次状态」查看当前状态</span>
</div>
<div class="flex items-center gap-3 flex-wrap">
<button onclick="lotteryLoadStatus()"
style="padding:8px 16px; background:linear-gradient(135deg,#475569,#64748b); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-lottery-current-url="{{ url('/lottery/current') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#475569,#64748b); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
🔄 加载期次状态
</button>
<button onclick="lotteryOpenIssue()"
style="padding:8px 16px; background:linear-gradient(135deg,#059669,#10b981); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-lottery-open-url="{{ route('admin.lottery.open-issue') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#059669,#10b981); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
手动开新期
</button>
<button onclick="lotteryForceDraw()"
style="padding:8px 16px; background:linear-gradient(135deg,#dc2626,#ef4444); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<button type="button" data-game-lottery-force-url="{{ route('admin.lottery.force-draw') }}"
data-game-hover-opacity=".85"
style="padding:8px 16px; background:linear-gradient(135deg,#dc2626,#ef4444); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; transition:opacity .15s;">
🎊 立即强制开奖
</button>
<span class="text-xs text-gray-400">开新期仅在无进行中期次时生效;强制开奖将提前结束当期</span>
@@ -219,140 +222,6 @@
</div>
</div>
<script>
/**
* 管理员手动投放神秘箱子
*
* @param {string} boxType 箱子类型:normal | rare | trap
*/
function dropBox(boxType) {
const typeNames = {
normal: '普通箱',
rare: '稀有箱',
trap: '黑化箱'
};
const typeIcons = {
normal: '📦',
rare: '💎',
trap: '☠️'
};
const name = typeNames[boxType] || boxType;
const icon = typeIcons[boxType] || '📦';
window.adminDialog.confirm(
`确定要向 <b>#1 房间</b> 投放一个「${name}」吗?<br><span style="color:#64748b; font-size:12px;">箱子投放后将立即在公屏广播暗号,用户限时领取。</span>`,
`投放${name}`,
() => {
fetch('/admin/mystery-box/drop', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
box_type: boxType
}),
})
.then(r => r.json())
.then(data => {
window.adminDialog.alert(
data.message || (data.ok ? '投放成功!' : '投放失败'),
data.ok ? '投放成功' : '投放失败',
data.ok ? icon : '❌'
);
})
.catch(() => window.adminDialog.alert('网络错误,请重试', '网络错误', '🌐'));
},
icon
);
}
/**
* 加载双色球当前期次状态
*/
function lotteryLoadStatus() {
const box = document.getElementById('lottery-issue-status');
box.innerHTML = '<span class="text-gray-400">⏳ 加载中…</span>';
fetch('/lottery/current', {
headers: {
'Accept': 'application/json'
}
})
.then(r => r.json())
.then(data => {
if (!data.issue) {
box.innerHTML = '<span class="text-orange-500">⚠️ 当前无进行中期次,可手动开新期</span>';
return;
}
const iss = data.issue;
const pool = Number(iss.pool_amount).toLocaleString();
const statusMap = {
open: '🟢 购票中',
closed: '🔴 已停售',
settled: '✅ 已开奖'
};
const superTag = iss.is_super_issue ? ' 🎊<b>超级期</b>' : '';
const drawAt = iss.draw_at ? iss.draw_at.replace('T', ' ') : '--';
box.innerHTML = ` <b>${iss.issue_no}</b> ${superTag} &nbsp;·&nbsp; 状态:${statusMap[iss.status] || iss.status}
&nbsp;·&nbsp; 奖池:<b style="color:#dc2626">💰 ${pool} 金币</b>
&nbsp;·&nbsp; 预计开奖:${drawAt}
&nbsp;·&nbsp; 已购:${iss.total_tickets || 0} `;
})
.catch(() => {
box.innerHTML = '<span class="text-red-400">❌ 加载失败</span>';
});
}
/**
* 手动开启新一期双色球
*/
function lotteryOpenIssue() {
window.adminDialog.confirm(
'确定要手动开启新一期双色球吗?<br><span style="color:#64748b;font-size:12px;">仅在无进行中期次时生效,开奖时间将使用当前配置的 draw_hour:draw_minute。</span>',
'手动开新期', () => {
fetch('/admin/lottery/open-issue', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
})
.then(r => r.json())
.then(d => {
window.adminDialog.alert(d.message, d.ok ? '操作成功' : '操作失败', d.ok ? '✅' : '❌');
if (d.ok) lotteryLoadStatus();
})
.catch(() => window.adminDialog.alert('网络错误,请重试', '网络错误', '🌐'));
}, ''
);
}
/**
* 强制提前开奖(用于测试或管理需要)
*/
function lotteryForceDraw() {
window.adminDialog.confirm(
'确定要<b style="color:red">立即强制开奖</b>吗?<br><span style="color:#64748b;font-size:12px;">将对当前 closed 或 open 期次立即执行开奖,此操作不可撤销!</span>',
'强制开奖确认', () => {
fetch('/admin/lottery/force-draw', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
})
.then(r => r.json())
.then(d => {
window.adminDialog.alert(d.message, d.ok ? '开奖完成' : '操作失败', d.ok ? '🎊' : '❌');
if (d.ok) lotteryLoadStatus();
})
.catch(() => window.adminDialog.alert('网络错误,请重试', '网络错误', '🌐'));
}, '🎊'
);
}
</script>
@endsection
@php