2_20240307.sql 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. -- 扩展消费者(会员)“身价”相关修改
  2. -- 为消费者(即会员表)增加当前身价值、预增加的身价值、增加后的身价总值、 直接推荐人id字段等
  3. ALTER TABLE `member_user`
  4. ADD COLUMN `recommenderd_id` bigint COMMENT '直接推荐人id',
  5. ADD COLUMN `current_member_worth_value` bigint COMMENT '当前身价值',
  6. ADD COLUMN `pre_added_member_worth_value` bigint COMMENT '预增加身价值',
  7. ADD COLUMN `future_member_worth_value` bigint COMMENT '未来身价值,未来身价值=当前身价值+预增加身价值',
  8. ADD COLUMN `current_member_worth_level_name` varchar(64) COMMENT '当前身价级别名称',
  9. ADD COLUMN `current_member_worth_level_id` bigint COMMENT '当前身价级别id',
  10. ADD COLUMN `last_sign_in_time` datetime COMMENT '最后签到时间',
  11. ADD COLUMN `continuous_sign_in_days` datetime COMMENT '连续签到天数';
  12. -- 身价级别表设置表
  13. CREATE TABLE `member_worth_level_setting` (
  14. `id` bigint NOT NULL COMMENT '身价级别id',
  15. `level_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '身价级别名称',
  16. `member_worth_value` bigint NOT NULL DEFAULT 0 COMMENT '本级别需达到的身价值',
  17. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  18. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  19. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  20. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  21. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  22. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  23. PRIMARY KEY (`id`) USING BTREE
  24. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '铺身价级别表设置表' ROW_FORMAT = Dynamic;
  25. -- 增加 会员资产变化类别表, 此表主要用于设置各种导致用户资产发生变化的行为的分值变化
  26. -- 字段有id、类别码(数字类型,在java中对应常量)、类别名称、类别描述、变化值(就是签到身价加100那个100)
  27. CREATE TABLE `member_assets_change_category` (
  28. `id` bigint NOT NULL COMMENT '会员资产变化类别id',
  29. `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '类别名称',
  30. `code` int NOT NULL DEFAULT -1 COMMENT '类别码',
  31. `variation_value` int NOT NULL DEFAULT 0 COMMENT '身价、积分、看点在本类别操作的变化值',
  32. `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '描述',
  33. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  34. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  35. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  36. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  37. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  38. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  39. PRIMARY KEY (`id`) USING BTREE
  40. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员资产变化类别表,含身价、积分、看点变化类别' ROW_FORMAT = Dynamic;
  41. -- 会员身价变化日志表
  42. -- 字段有会员资产变化类别id、分值、操作时间、对象名(如 订单表名)、对象id(如 订单id)、是否已生效、计划生效时间、实际生效时间、描述
  43. CREATE TABLE `member_worth_value_change_log` (
  44. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会员身价变化日志id',
  45. `member_assets_change_category_id` bigint NOT NULL COMMENT '会员资产变化类别id',-- 新加字段
  46. `member_worth_value` bigint NOT NULL COMMENT '身价值',
  47. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  48. `object_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作对应业务对象名称',
  49. `object_id` bigint NOT NULL DEFAULT 0 COMMENT '操作对应业务对象id',
  50. `effective` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已生效',
  51. `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '描述',
  52. `plan_effective_time` datetime NULL COMMENT '计划生效时间',
  53. `actual_effective_time` datetime NULL COMMENT '实际生效时间',
  54. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  55. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  56. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  57. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  58. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  59. PRIMARY KEY (`id`) USING BTREE
  60. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;
  61. -- 增加 会员签到表
  62. CREATE TABLE `member_sign_in` (
  63. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会员签到表id',
  64. `member_user_id` bigint NOT NULL DEFAULT 0 COMMENT '会员用户id',
  65. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签到时间',
  66. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  67. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  68. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  69. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  70. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  71. PRIMARY KEY (`id`) USING BTREE
  72. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;
  73. -- 为消费者(即会员表)增加当前的积分值、预增加的积分值、累计消费额(只算人民币)
  74. ALTER TABLE `member_user`
  75. ADD COLUMN `current_member_points` bigint COMMENT '当前积分值',
  76. ADD COLUMN `pre_added_member_worth` bigint COMMENT '预增加积分值'
  77. ;
  78. -- 消费者(即会员表)增加累计消费金额(只算人民币)
  79. ALTER TABLE `member_user`
  80. ADD COLUMN `cumulative_spending` bigint COMMENT '累计消费金额(只算人民币,单位为分)';
  81. /* 会员积分变化日志表:会员资产变化类别id、分值、操作时间、对象名(如 订单表名)、对象id(如 订单id)、
  82. 是否已生效、计划生效时间、实际生效时间、描述。定时器直接扫描本表未生效,且过了计划生效时间的数据进行处理。
  83. */
  84. CREATE TABLE `member_points_change_log` (
  85. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会员积分变化日志id',
  86. `member_assets_change_category_id` bigint NOT NULL COMMENT '会员资产变化类别id',
  87. `member_points` bigint NOT NULL COMMENT '积分值',
  88. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  89. `object_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作对应业务对象名称(如 订单表名)',
  90. `object_id` bigint NOT NULL DEFAULT 0 COMMENT '操作对应业务对象id(如 订单id)',
  91. `effective` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已生效',
  92. `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '描述',
  93. `plan_effective_time` datetime NULL COMMENT '计划生效时间',
  94. `actual_effective_time` datetime NULL COMMENT '实际生效时间',
  95. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  96. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  97. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  98. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  99. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  100. PRIMARY KEY (`id`) USING BTREE
  101. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;