简化婚礼流程:去掉立即/定时选择,同意结婚后直接立即举办婚礼
This commit is contained in:
@@ -19,7 +19,6 @@ use App\Models\WeddingCeremony;
|
||||
use App\Services\WeddingService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class WeddingController extends Controller
|
||||
{
|
||||
@@ -60,28 +59,24 @@ class WeddingController extends Controller
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'tier_id' => 'nullable|integer|exists:wedding_tiers,id',
|
||||
'tier_id' => 'required|integer|exists:wedding_tiers,id',
|
||||
'payer_type' => 'required|in:groom,joint',
|
||||
'ceremony_type' => 'required|in:immediate,scheduled',
|
||||
'ceremony_at' => 'nullable|date|after:now',
|
||||
]);
|
||||
|
||||
$ceremonyAt = isset($data['ceremony_at']) ? Carbon::parse($data['ceremony_at']) : null;
|
||||
|
||||
// 固定立即举办,不再接受 scheduled 选项
|
||||
$result = $this->wedding->setup(
|
||||
$marriage,
|
||||
$data['tier_id'] ?? null,
|
||||
$data['tier_id'],
|
||||
$data['payer_type'],
|
||||
$data['ceremony_type'],
|
||||
$ceremonyAt,
|
||||
'immediate',
|
||||
null,
|
||||
);
|
||||
|
||||
// 立即婚礼:直接触发
|
||||
if ($result['ok'] && $data['ceremony_type'] === 'immediate') {
|
||||
// 立即触发婚礼庆典并广播
|
||||
if ($result['ok']) {
|
||||
$ceremony = WeddingCeremony::find($result['ceremony_id']);
|
||||
if ($ceremony) {
|
||||
$triggerResult = $this->wedding->trigger($ceremony);
|
||||
// 广播全房间婚礼事件
|
||||
$this->wedding->trigger($ceremony);
|
||||
broadcast(new WeddingCelebration($ceremony, $marriage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,38 +582,6 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{{-- 时间选择 --}}
|
||||
<div style="font-size:13px; font-weight:bold; color:#374151; margin-bottom:10px;">举办时间</div>
|
||||
<div style="display:flex; gap:10px; margin-bottom:16px;">
|
||||
<label
|
||||
style="flex:1; display:flex; align-items:center; gap:8px; padding:10px;
|
||||
border-radius:10px; cursor:pointer;"
|
||||
:style="timing === 'now' ? 'border:2px solid #ec4899; background:#fff1f2;' :
|
||||
'border:2px solid #e2e8f0;'">
|
||||
<input type="radio" x-model="timing" value="now" style="accent-color:#ec4899;">
|
||||
<div>
|
||||
<div style="font-size:12px; font-weight:bold;">🎊 立即举办</div>
|
||||
<div style="font-size:10px; color:#9ca3af;">随机红包即刻发出</div>
|
||||
</div>
|
||||
</label>
|
||||
<label
|
||||
style="flex:1; display:flex; align-items:center; gap:8px; padding:10px;
|
||||
border-radius:10px; cursor:pointer;"
|
||||
:style="timing === 'scheduled' ? 'border:2px solid #ec4899; background:#fff1f2;' :
|
||||
'border:2px solid #e2e8f0;'">
|
||||
<input type="radio" x-model="timing" value="scheduled" style="accent-color:#ec4899;">
|
||||
<div>
|
||||
<div style="font-size:12px; font-weight:bold;">⏰ 定时举办</div>
|
||||
<div style="font-size:10px; color:#9ca3af;">选一个吉时</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div x-show="timing === 'scheduled'" style="display:none; margin-bottom:16px;">
|
||||
<input type="datetime-local" x-model="scheduledAt"
|
||||
style="width:100%; padding:10px; border:1px solid #fcd34d; border-radius:8px;
|
||||
font-size:13px; box-sizing:border-box;">
|
||||
</div>
|
||||
|
||||
{{-- 费用摘要 --}}
|
||||
<div x-show="selectedTier"
|
||||
@@ -1135,12 +1103,11 @@
|
||||
tiers: [],
|
||||
selectedTier: null,
|
||||
payBy: 'groom',
|
||||
timing: 'now',
|
||||
scheduledAt: '',
|
||||
loading: false,
|
||||
sending: false,
|
||||
error: '',
|
||||
|
||||
|
||||
get myCost() {
|
||||
if (!this.selectedTier) return 0;
|
||||
return this.payBy === 'split' ?
|
||||
@@ -1152,8 +1119,6 @@
|
||||
this.marriageId = marriageId;
|
||||
this.selectedTier = null;
|
||||
this.payBy = 'groom';
|
||||
this.timing = 'now';
|
||||
this.scheduledAt = '';
|
||||
this.error = '';
|
||||
this.loading = true;
|
||||
this.show = true;
|
||||
@@ -1183,15 +1148,13 @@
|
||||
this.error = '';
|
||||
this.sending = true;
|
||||
try {
|
||||
// 固定使用立即举办,不再需要用户选择时间
|
||||
const body = {
|
||||
tier_id: this.selectedTier.id,
|
||||
pay_by: this.payBy,
|
||||
ceremony_type: this.timing,
|
||||
payer_type: this.payBy,
|
||||
ceremony_type: 'immediate',
|
||||
room_id: window.chatContext.roomId,
|
||||
};
|
||||
if (this.timing === 'scheduled') {
|
||||
body.scheduled_at = this.scheduledAt;
|
||||
}
|
||||
const res = await fetch(window.chatContext.marriage.weddingSetupUrl(this.marriageId), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -1204,12 +1167,7 @@
|
||||
const data = await res.json();
|
||||
if (data.status === 'success') {
|
||||
this.close();
|
||||
window.chatDialog?.alert(
|
||||
this.timing === 'now' ?
|
||||
'🎊 婚礼已开始!红包正在分发给在线用户…' :
|
||||
'⏰ 婚礼已预约,时间到时将自动举办!',
|
||||
'设置成功', '#f59e0b'
|
||||
);
|
||||
window.chatDialog?.alert('🎊 婚礼已开始!红包正在分发给在线用户…', '设置成功', '#f59e0b');
|
||||
} else {
|
||||
this.error = data.message || '设置失败';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user