-- 农场铲除奖励功能示例数据 -- 此文件包含为物品添加农场铲除奖励属性的示例SQL语句 -- ============================================ -- 1. 创建示例奖励组 -- ============================================ -- 创建铲除奖励组:基础奖励 INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES (1001, '基础铲除奖励', 'farm_remove_basic', '使用基础铲除工具时的奖励', 0, 0, NOW(), NOW()); -- 创建铲除奖励组:高级奖励 INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES (1002, '高级铲除奖励', 'farm_remove_advanced', '使用高级铲除工具时的奖励', 1, 2, NOW(), NOW()); -- 创建铲除奖励组:稀有奖励 INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES (1003, '稀有铲除奖励', 'farm_remove_rare', '使用稀有铲除工具时的奖励', 1, 3, NOW(), NOW()); -- ============================================ -- 2. 创建奖励项 -- ============================================ -- 基础铲除奖励项(全部发放) INSERT INTO `kku_game_reward_items` (`group_id`, `reward_type`, `target_id`, `param1`, `param2`, `quantity`, `weight`, `is_guaranteed`, `extra_data`, `created_at`, `updated_at`) VALUES -- 农场币奖励 (1001, 2, 1, 0, 0, 10, 1.0, 1, '{}', NOW(), NOW()), -- 经验值奖励 (1001, 3, 0, 0, 0, 5, 1.0, 1, '{}', NOW(), NOW()); -- 高级铲除奖励项(随机发放2个) INSERT INTO `kku_game_reward_items` (`group_id`, `reward_type`, `target_id`, `param1`, `param2`, `quantity`, `weight`, `is_guaranteed`, `extra_data`, `created_at`, `updated_at`) VALUES -- 农场币奖励(权重高) (1002, 2, 1, 0, 0, 20, 3.0, 0, '{}', NOW(), NOW()), -- 经验值奖励(权重中) (1002, 3, 0, 0, 0, 10, 2.0, 0, '{}', NOW(), NOW()), -- 种子奖励(权重低,假设物品ID为2001) (1002, 1, 2001, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW()), -- 肥料奖励(权重低,假设物品ID为2002) (1002, 1, 2002, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW()); -- 稀有铲除奖励项(随机发放3个) INSERT INTO `kku_game_reward_items` (`group_id`, `reward_type`, `target_id`, `param1`, `param2`, `quantity`, `weight`, `is_guaranteed`, `extra_data`, `created_at`, `updated_at`) VALUES -- 农场币奖励(权重高) (1003, 2, 1, 0, 0, 50, 4.0, 0, '{}', NOW(), NOW()), -- 经验值奖励(权重高) (1003, 3, 0, 0, 0, 20, 3.0, 0, '{}', NOW(), NOW()), -- 稀有种子奖励(权重中,假设物品ID为3001) (1003, 1, 3001, 0, 0, 1, 2.0, 0, '{}', NOW(), NOW()), -- 高级肥料奖励(权重中,假设物品ID为3002) (1003, 1, 3002, 0, 0, 1, 2.0, 0, '{}', NOW(), NOW()), -- 神秘宝箱奖励(权重低,假设物品ID为3003) (1003, 1, 3003, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW()); -- ============================================ -- 3. 更新物品数值属性示例 -- ============================================ -- 示例:为基础铲子添加基础奖励(假设物品ID为1001) -- UPDATE `kku_item_items` SET -- `numeric_attributes` = JSON_SET( -- COALESCE(`numeric_attributes`, '{}'), -- '$.fram_remove_reward_group', -- 1001 -- ) -- WHERE `id` = 1001; -- 示例:为高级铲子添加高级奖励(假设物品ID为1002) -- UPDATE `kku_item_items` SET -- `numeric_attributes` = JSON_SET( -- COALESCE(`numeric_attributes`, '{}'), -- '$.fram_remove_reward_group', -- 1002 -- ) -- WHERE `id` = 1002; -- 示例:为稀有铲子添加稀有奖励(假设物品ID为1003) -- UPDATE `kku_item_items` SET -- `numeric_attributes` = JSON_SET( -- COALESCE(`numeric_attributes`, '{}'), -- '$.fram_remove_reward_group', -- 1003 -- ) -- WHERE `id` = 1003; -- ============================================ -- 4. 查询验证SQL -- ============================================ -- 查询奖励组信息 -- SELECT * FROM `kku_game_reward_groups` WHERE `code` LIKE 'farm_remove_%'; -- 查询奖励项信息 -- SELECT -- g.name as group_name, -- g.code as group_code, -- i.reward_type, -- i.target_id, -- i.quantity, -- i.weight, -- i.is_guaranteed -- FROM `kku_game_reward_groups` g -- JOIN `kku_game_reward_items` i ON g.id = i.group_id -- WHERE g.code LIKE 'farm_remove_%' -- ORDER BY g.id, i.id; -- 查询具有铲除奖励属性的物品 -- SELECT -- id, -- name, -- JSON_EXTRACT(numeric_attributes, '$.fram_remove_reward_group') as reward_group_id -- FROM `kku_item_items` -- WHERE JSON_EXTRACT(numeric_attributes, '$.fram_remove_reward_group') > 0;