coupon_center.sql 6.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. CREATE TABLE `coupon_center_platforms` (
  2. `id` varchar(64) NOT NULL COMMENT '平台编码,如 tb/vipshop/tb_flash',
  3. `name` varchar(64) NOT NULL DEFAULT '' COMMENT '平台名称',
  4. `icon_url` varchar(512) NOT NULL DEFAULT '' COMMENT '平台图标',
  5. `sort` int NOT NULL DEFAULT 0 COMMENT '排序,越小越靠前',
  6. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用:1启用,0停用',
  7. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  8. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  9. PRIMARY KEY (`id`),
  10. KEY `idx_status_sort` (`status`, `sort`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='领券中心平台表';
  12. CREATE TABLE `coupon_center_activities` (
  13. `id` varchar(64) NOT NULL COMMENT '活动编码,如 act-tb-all',
  14. `platform_id` varchar(64) NOT NULL DEFAULT '' COMMENT '所属平台ID',
  15. `name` varchar(128) NOT NULL DEFAULT '' COMMENT '活动名称',
  16. `short_desc` varchar(255) NOT NULL DEFAULT '' COMMENT '活动短描述',
  17. `deeplink` varchar(1024) NOT NULL DEFAULT '' COMMENT '活动跳转链接,留空则自动拼 magicchain 链接',
  18. `sort` int NOT NULL DEFAULT 0 COMMENT '排序,越小越靠前',
  19. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用:1启用,0停用',
  20. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  21. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  22. PRIMARY KEY (`id`),
  23. KEY `idx_platform_status_sort` (`platform_id`, `status`, `sort`),
  24. KEY `idx_status_sort` (`status`, `sort`)
  25. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='领券中心活动表';
  26. CREATE TABLE `coupon_center_coupons` (
  27. `id` varchar(64) NOT NULL COMMENT '券编码,如 cp-tb-max-666',
  28. `activity_id` varchar(64) NOT NULL DEFAULT '' COMMENT '所属活动ID',
  29. `value` varchar(64) NOT NULL DEFAULT '' COMMENT '券面额展示值',
  30. `expire_time` varchar(64) NOT NULL DEFAULT '' COMMENT '过期时间展示文案',
  31. `category` varchar(128) NOT NULL DEFAULT '' COMMENT '分类',
  32. `threshold` varchar(128) NOT NULL DEFAULT '' COMMENT '门槛说明',
  33. `coupon_status` varchar(32) NOT NULL DEFAULT 'available' COMMENT '业务状态,如 available/soldout/expired',
  34. `sort` int NOT NULL DEFAULT 0 COMMENT '排序,越小越靠前',
  35. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用:1启用,0停用',
  36. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  37. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  38. PRIMARY KEY (`id`),
  39. KEY `idx_activity_status_sort` (`activity_id`, `status`, `sort`),
  40. KEY `idx_status_sort` (`status`, `sort`)
  41. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='领券中心券表';
  42. INSERT INTO `coupon_center_platforms` (`id`, `name`, `icon_url`, `sort`, `status`)
  43. VALUES
  44. ('tb', '淘宝', 'http://doc.molilian.com/images/taobao.webp', 10, 1),
  45. ('vipshop', '唯品会', 'http://doc.molilian.com/images/tmall.webp', 20, 1),
  46. ('tb_flash', '淘宝闪购', 'http://doc.molilian.com/images/shangou.webp', 30, 1)
  47. ON DUPLICATE KEY UPDATE
  48. `name` = VALUES(`name`),
  49. `icon_url` = VALUES(`icon_url`),
  50. `sort` = VALUES(`sort`),
  51. `status` = VALUES(`status`),
  52. `update_time` = CURRENT_TIMESTAMP;
  53. INSERT INTO `coupon_center_activities` (`id`, `platform_id`, `name`, `short_desc`, `deeplink`, `sort`, `status`)
  54. VALUES
  55. ('act-tb-all', 'tb', '淘宝领券中心', '全平台', 'magicchain://coupon-center/activity?activityId=act-tb-all', 10, 1),
  56. ('act-tb-home', 'tb', '淘宝居家券场', '居家日用', 'magicchain://coupon-center/activity?activityId=act-tb-home', 20, 1),
  57. ('act-vipshop-all', 'vipshop', '唯品会领券中心', '全平台', 'magicchain://coupon-center/activity?activityId=act-vipshop-all', 10, 1),
  58. ('act-vipshop-beauty', 'vipshop', '唯品会美妆券场', '美妆个护', 'magicchain://coupon-center/activity?activityId=act-vipshop-beauty', 20, 1),
  59. ('act-tb-flash-medicine', 'tb_flash', '淘宝闪购领券中心', '医药', 'magicchain://coupon-center/activity?activityId=act-tb-flash-medicine', 10, 1),
  60. ('act-tb-flash-food', 'tb_flash', '淘宝闪购夜宵券场', '美食', 'magicchain://coupon-center/activity?activityId=act-tb-flash-food', 20, 1)
  61. ON DUPLICATE KEY UPDATE
  62. `platform_id` = VALUES(`platform_id`),
  63. `name` = VALUES(`name`),
  64. `short_desc` = VALUES(`short_desc`),
  65. `deeplink` = VALUES(`deeplink`),
  66. `sort` = VALUES(`sort`),
  67. `status` = VALUES(`status`),
  68. `update_time` = CURRENT_TIMESTAMP;
  69. INSERT INTO `coupon_center_coupons` (`id`, `activity_id`, `value`, `expire_time`, `category`, `threshold`, `coupon_status`, `sort`, `status`)
  70. VALUES
  71. ('cp-tb-max-666', 'act-tb-all', '最高666元', '3月31日23:59', '全平台', '无门槛', 'available', 10, 1),
  72. ('cp-tb-88', 'act-tb-all', '88元', '3月25日23:59', '数码家电', '满599元减88元', 'available', 20, 1),
  73. ('cp-tb-home-30', 'act-tb-home', '30元', '3月29日23:59', '居家', '满199元减30元', 'available', 10, 1),
  74. ('cp-tb-home-15', 'act-tb-home', '15元', '3月24日23:59', '日用百货', '满99元减15元', 'available', 20, 1),
  75. ('cp-vipshop-max-30', 'act-vipshop-all', '最高减30', '3月28日23:59', '全平台', '无门槛', 'available', 10, 1),
  76. ('cp-vipshop-80', 'act-vipshop-all', '80元', '3月26日23:59', '服饰', '满500元减80元', 'available', 20, 1),
  77. ('cp-vipshop-beauty-50', 'act-vipshop-beauty', '50元', '3月30日23:59', '美妆', '满299元减50元', 'available', 10, 1),
  78. ('cp-vipshop-beauty-20', 'act-vipshop-beauty', '20元', '3月27日23:59', '个护', '满159元减20元', 'available', 20, 1),
  79. ('cp-tb-flash-8', 'act-tb-flash-medicine', '8元', '3月22日23:59', '医药', '满8元减8元', 'available', 10, 1),
  80. ('cp-tb-flash-20', 'act-tb-flash-medicine', '20元', '3月23日23:59', '保健', '满99元减20元', 'available', 20, 1),
  81. ('cp-tb-flash-food-10', 'act-tb-flash-food', '10元', '3月21日23:59', '美食', '满39元减10元', 'available', 10, 1),
  82. ('cp-tb-flash-food-5', 'act-tb-flash-food', '5元', '3月20日23:59', '夜宵', '满20元减5元', 'available', 20, 1)
  83. ON DUPLICATE KEY UPDATE
  84. `activity_id` = VALUES(`activity_id`),
  85. `value` = VALUES(`value`),
  86. `expire_time` = VALUES(`expire_time`),
  87. `category` = VALUES(`category`),
  88. `threshold` = VALUES(`threshold`),
  89. `coupon_status` = VALUES(`coupon_status`),
  90. `sort` = VALUES(`sort`),
  91. `status` = VALUES(`status`),
  92. `update_time` = CURRENT_TIMESTAMP;