add_farm_remove_reward_examples.sql 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. -- 农场铲除奖励功能示例数据
  2. -- 此文件包含为物品添加农场铲除奖励属性的示例SQL语句
  3. -- ============================================
  4. -- 1. 创建示例奖励组
  5. -- ============================================
  6. -- 创建铲除奖励组:基础奖励
  7. INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES
  8. (1001, '基础铲除奖励', 'farm_remove_basic', '使用基础铲除工具时的奖励', 0, 0, NOW(), NOW());
  9. -- 创建铲除奖励组:高级奖励
  10. INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES
  11. (1002, '高级铲除奖励', 'farm_remove_advanced', '使用高级铲除工具时的奖励', 1, 2, NOW(), NOW());
  12. -- 创建铲除奖励组:稀有奖励
  13. INSERT INTO `kku_game_reward_groups` (`id`, `name`, `code`, `description`, `is_random`, `random_count`, `created_at`, `updated_at`) VALUES
  14. (1003, '稀有铲除奖励', 'farm_remove_rare', '使用稀有铲除工具时的奖励', 1, 3, NOW(), NOW());
  15. -- ============================================
  16. -- 2. 创建奖励项
  17. -- ============================================
  18. -- 基础铲除奖励项(全部发放)
  19. 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
  20. -- 农场币奖励
  21. (1001, 2, 1, 0, 0, 10, 1.0, 1, '{}', NOW(), NOW()),
  22. -- 经验值奖励
  23. (1001, 3, 0, 0, 0, 5, 1.0, 1, '{}', NOW(), NOW());
  24. -- 高级铲除奖励项(随机发放2个)
  25. 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
  26. -- 农场币奖励(权重高)
  27. (1002, 2, 1, 0, 0, 20, 3.0, 0, '{}', NOW(), NOW()),
  28. -- 经验值奖励(权重中)
  29. (1002, 3, 0, 0, 0, 10, 2.0, 0, '{}', NOW(), NOW()),
  30. -- 种子奖励(权重低,假设物品ID为2001)
  31. (1002, 1, 2001, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW()),
  32. -- 肥料奖励(权重低,假设物品ID为2002)
  33. (1002, 1, 2002, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW());
  34. -- 稀有铲除奖励项(随机发放3个)
  35. 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
  36. -- 农场币奖励(权重高)
  37. (1003, 2, 1, 0, 0, 50, 4.0, 0, '{}', NOW(), NOW()),
  38. -- 经验值奖励(权重高)
  39. (1003, 3, 0, 0, 0, 20, 3.0, 0, '{}', NOW(), NOW()),
  40. -- 稀有种子奖励(权重中,假设物品ID为3001)
  41. (1003, 1, 3001, 0, 0, 1, 2.0, 0, '{}', NOW(), NOW()),
  42. -- 高级肥料奖励(权重中,假设物品ID为3002)
  43. (1003, 1, 3002, 0, 0, 1, 2.0, 0, '{}', NOW(), NOW()),
  44. -- 神秘宝箱奖励(权重低,假设物品ID为3003)
  45. (1003, 1, 3003, 0, 0, 1, 1.0, 0, '{}', NOW(), NOW());
  46. -- ============================================
  47. -- 3. 更新物品数值属性示例
  48. -- ============================================
  49. -- 示例:为基础铲子添加基础奖励(假设物品ID为1001)
  50. -- UPDATE `kku_item_items` SET
  51. -- `numeric_attributes` = JSON_SET(
  52. -- COALESCE(`numeric_attributes`, '{}'),
  53. -- '$.fram_remove_reward_group',
  54. -- 1001
  55. -- )
  56. -- WHERE `id` = 1001;
  57. -- 示例:为高级铲子添加高级奖励(假设物品ID为1002)
  58. -- UPDATE `kku_item_items` SET
  59. -- `numeric_attributes` = JSON_SET(
  60. -- COALESCE(`numeric_attributes`, '{}'),
  61. -- '$.fram_remove_reward_group',
  62. -- 1002
  63. -- )
  64. -- WHERE `id` = 1002;
  65. -- 示例:为稀有铲子添加稀有奖励(假设物品ID为1003)
  66. -- UPDATE `kku_item_items` SET
  67. -- `numeric_attributes` = JSON_SET(
  68. -- COALESCE(`numeric_attributes`, '{}'),
  69. -- '$.fram_remove_reward_group',
  70. -- 1003
  71. -- )
  72. -- WHERE `id` = 1003;
  73. -- ============================================
  74. -- 4. 查询验证SQL
  75. -- ============================================
  76. -- 查询奖励组信息
  77. -- SELECT * FROM `kku_game_reward_groups` WHERE `code` LIKE 'farm_remove_%';
  78. -- 查询奖励项信息
  79. -- SELECT
  80. -- g.name as group_name,
  81. -- g.code as group_code,
  82. -- i.reward_type,
  83. -- i.target_id,
  84. -- i.quantity,
  85. -- i.weight,
  86. -- i.is_guaranteed
  87. -- FROM `kku_game_reward_groups` g
  88. -- JOIN `kku_game_reward_items` i ON g.id = i.group_id
  89. -- WHERE g.code LIKE 'farm_remove_%'
  90. -- ORDER BY g.id, i.id;
  91. -- 查询具有铲除奖励属性的物品
  92. -- SELECT
  93. -- id,
  94. -- name,
  95. -- JSON_EXTRACT(numeric_attributes, '$.fram_remove_reward_group') as reward_group_id
  96. -- FROM `kku_item_items`
  97. -- WHERE JSON_EXTRACT(numeric_attributes, '$.fram_remove_reward_group') > 0;