功能:商店完善戒指板块

迁移:
- 2026_03_01_153959:shop_items 增加 intimacy_bonus/charm_bonus 字段

Seeder(RingItemsSeeder):
- 银质戒指 500金  亲密+10 魅力+30
- 黄金戒指 2000金 亲密+30 魅力+80
- 红宝石戒指 8000金 亲密+80 魅力+200
- 钻石戒指 30000金 亲密+200 魅力+500
- 传说神戒 100000金 亲密+500 魅力+1000

ShopService:
- buyItem() 分支加 ring 类型
- buyRing():扣金币 + 写入 active UserPurchase(背包持有)

ShopController::items():
- 返回 intimacy_bonus/charm_bonus
- 统计 ring_counts(各戒指持有数量)

shop-panel.blade.php:
- 新增「💍 求婚戒指」分组(排在最后)
- 图标右上角红色数字徽章(持有时)
- 卡片下方显示亲密度/魅力加成
- 购买按钮与现有逻辑复用
This commit is contained in:
2026-03-01 15:42:25 +08:00
parent 1f33013216
commit 29e43507ac
5 changed files with 209 additions and 2 deletions

View File

@@ -42,13 +42,26 @@ class ShopController extends Controller
'price' => $item->price,
'type' => $item->type,
'duration_days' => $item->duration_days,
'intimacy_bonus' => $item->intimacy_bonus,
'charm_bonus' => $item->charm_bonus,
]);
// 统计背包中各戒指持有数量
$ringCounts = \App\Models\UserPurchase::query()
->where('user_id', $user->id)
->where('status', 'active')
->whereHas('item', fn ($q) => $q->where('type', 'ring'))
->selectRaw('shop_item_id, count(*) as qty')
->groupBy('shop_item_id')
->pluck('qty', 'shop_item_id')
->toArray();
return response()->json([
'items' => $items,
'user_jjb' => $user->jjb ?? 0,
'active_week_effect' => $this->shopService->getActiveWeekEffect($user),
'has_rename_card' => $this->shopService->hasRenameCard($user),
'ring_counts' => $ringCounts, // [item_id => qty]
]);
}