功能:商店完善戒指板块
迁移:
- 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:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:为 shop_items 表添加戒指属性字段
|
||||
*
|
||||
* intimacy_bonus — 结婚时初始亲密度加成
|
||||
* charm_bonus — 结婚时双方魅力加成
|
||||
* 对非戒指类商品均为 NULL,不影响现有数据。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 添加戒指加成字段。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shop_items', function (Blueprint $table): void {
|
||||
$table->unsignedSmallInteger('intimacy_bonus')->default(0)->after('duration_days')->comment('结婚初始亲密度加成(戒指专用)');
|
||||
$table->unsignedSmallInteger('charm_bonus')->default(0)->after('intimacy_bonus')->comment('结婚魅力加成(戒指专用)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:删除字段。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shop_items', function (Blueprint $table): void {
|
||||
$table->dropColumn(['intimacy_bonus', 'charm_bonus']);
|
||||
});
|
||||
}
|
||||
};
|
||||
92
database/seeders/RingItemsSeeder.php
Normal file
92
database/seeders/RingItemsSeeder.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:初始化商店戒指商品数据
|
||||
*
|
||||
* 共 5 档戒指,对应不同价格、亲密度加成、魅力加成。
|
||||
* 可重复运行(updateOrCreate 幂等)。
|
||||
*/
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\ShopItem;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RingItemsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 写入 5 档结婚戒指数据。
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$rings = [
|
||||
[
|
||||
'slug' => 'ring_silver',
|
||||
'name' => '银质戒指',
|
||||
'icon' => '💍',
|
||||
'description' => '朴素银戒,见证两心相许。',
|
||||
'price' => 500,
|
||||
'type' => 'ring',
|
||||
'intimacy_bonus' => 10,
|
||||
'charm_bonus' => 30,
|
||||
'sort_order' => 101,
|
||||
],
|
||||
[
|
||||
'slug' => 'ring_gold',
|
||||
'name' => '黄金戒指',
|
||||
'icon' => '💛',
|
||||
'description' => '18K黄金,情比金坚。',
|
||||
'price' => 2000,
|
||||
'type' => 'ring',
|
||||
'intimacy_bonus' => 30,
|
||||
'charm_bonus' => 80,
|
||||
'sort_order' => 102,
|
||||
],
|
||||
[
|
||||
'slug' => 'ring_ruby',
|
||||
'name' => '红宝石戒指',
|
||||
'icon' => '❤️',
|
||||
'description' => '鸽血红宝,热烈如初恋。',
|
||||
'price' => 8000,
|
||||
'type' => 'ring',
|
||||
'intimacy_bonus' => 80,
|
||||
'charm_bonus' => 200,
|
||||
'sort_order' => 103,
|
||||
],
|
||||
[
|
||||
'slug' => 'ring_diamond',
|
||||
'name' => '钻石戒指',
|
||||
'icon' => '💎',
|
||||
'description' => '一克拉钻石,誓言永恒。',
|
||||
'price' => 30000,
|
||||
'type' => 'ring',
|
||||
'intimacy_bonus' => 200,
|
||||
'charm_bonus' => 500,
|
||||
'sort_order' => 104,
|
||||
],
|
||||
[
|
||||
'slug' => 'ring_legendary',
|
||||
'name' => '传说神戒',
|
||||
'icon' => '🌟',
|
||||
'description' => '世间仅此一款,天命之环,天作之合。',
|
||||
'price' => 100000,
|
||||
'type' => 'ring',
|
||||
'intimacy_bonus' => 500,
|
||||
'charm_bonus' => 1000,
|
||||
'sort_order' => 105,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rings as $ring) {
|
||||
ShopItem::updateOrCreate(
|
||||
['slug' => $ring['slug']],
|
||||
array_merge($ring, [
|
||||
'is_active' => true,
|
||||
'duration_days' => null,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
$this->command->info('✅ 5 枚结婚戒指已写入 shop_items。');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user