简化婚礼流程:去掉立即/定时选择,同意结婚后直接立即举办婚礼
This commit is contained in:
@@ -19,7 +19,6 @@ use App\Models\WeddingCeremony;
|
|||||||
use App\Services\WeddingService;
|
use App\Services\WeddingService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
|
|
||||||
class WeddingController extends Controller
|
class WeddingController extends Controller
|
||||||
{
|
{
|
||||||
@@ -60,28 +59,24 @@ class WeddingController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $request->validate([
|
$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',
|
'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(
|
$result = $this->wedding->setup(
|
||||||
$marriage,
|
$marriage,
|
||||||
$data['tier_id'] ?? null,
|
$data['tier_id'],
|
||||||
$data['payer_type'],
|
$data['payer_type'],
|
||||||
$data['ceremony_type'],
|
'immediate',
|
||||||
$ceremonyAt,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 立即婚礼:直接触发
|
// 立即触发婚礼庆典并广播
|
||||||
if ($result['ok'] && $data['ceremony_type'] === 'immediate') {
|
if ($result['ok']) {
|
||||||
$ceremony = WeddingCeremony::find($result['ceremony_id']);
|
$ceremony = WeddingCeremony::find($result['ceremony_id']);
|
||||||
if ($ceremony) {
|
if ($ceremony) {
|
||||||
$triggerResult = $this->wedding->trigger($ceremony);
|
$this->wedding->trigger($ceremony);
|
||||||
// 广播全房间婚礼事件
|
|
||||||
broadcast(new WeddingCelebration($ceremony, $marriage));
|
broadcast(new WeddingCelebration($ceremony, $marriage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -582,38 +582,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</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"
|
<div x-show="selectedTier"
|
||||||
@@ -1135,12 +1103,11 @@
|
|||||||
tiers: [],
|
tiers: [],
|
||||||
selectedTier: null,
|
selectedTier: null,
|
||||||
payBy: 'groom',
|
payBy: 'groom',
|
||||||
timing: 'now',
|
|
||||||
scheduledAt: '',
|
|
||||||
loading: false,
|
loading: false,
|
||||||
sending: false,
|
sending: false,
|
||||||
error: '',
|
error: '',
|
||||||
|
|
||||||
|
|
||||||
get myCost() {
|
get myCost() {
|
||||||
if (!this.selectedTier) return 0;
|
if (!this.selectedTier) return 0;
|
||||||
return this.payBy === 'split' ?
|
return this.payBy === 'split' ?
|
||||||
@@ -1152,8 +1119,6 @@
|
|||||||
this.marriageId = marriageId;
|
this.marriageId = marriageId;
|
||||||
this.selectedTier = null;
|
this.selectedTier = null;
|
||||||
this.payBy = 'groom';
|
this.payBy = 'groom';
|
||||||
this.timing = 'now';
|
|
||||||
this.scheduledAt = '';
|
|
||||||
this.error = '';
|
this.error = '';
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.show = true;
|
this.show = true;
|
||||||
@@ -1183,15 +1148,13 @@
|
|||||||
this.error = '';
|
this.error = '';
|
||||||
this.sending = true;
|
this.sending = true;
|
||||||
try {
|
try {
|
||||||
|
// 固定使用立即举办,不再需要用户选择时间
|
||||||
const body = {
|
const body = {
|
||||||
tier_id: this.selectedTier.id,
|
tier_id: this.selectedTier.id,
|
||||||
pay_by: this.payBy,
|
payer_type: this.payBy,
|
||||||
ceremony_type: this.timing,
|
ceremony_type: 'immediate',
|
||||||
room_id: window.chatContext.roomId,
|
room_id: window.chatContext.roomId,
|
||||||
};
|
};
|
||||||
if (this.timing === 'scheduled') {
|
|
||||||
body.scheduled_at = this.scheduledAt;
|
|
||||||
}
|
|
||||||
const res = await fetch(window.chatContext.marriage.weddingSetupUrl(this.marriageId), {
|
const res = await fetch(window.chatContext.marriage.weddingSetupUrl(this.marriageId), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -1204,12 +1167,7 @@
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
this.close();
|
this.close();
|
||||||
window.chatDialog?.alert(
|
window.chatDialog?.alert('🎊 婚礼已开始!红包正在分发给在线用户…', '设置成功', '#f59e0b');
|
||||||
this.timing === 'now' ?
|
|
||||||
'🎊 婚礼已开始!红包正在分发给在线用户…' :
|
|
||||||
'⏰ 婚礼已预约,时间到时将自动举办!',
|
|
||||||
'设置成功', '#f59e0b'
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this.error = data.message || '设置失败';
|
this.error = data.message || '设置失败';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user