Commit 4257cad46af4bdc768c486e5784759d0d34ea060

Authored by YunaiV
1 parent c7285da9

code review:会员积分

sql/mysql/member_poinit_20230809积分四张表结构调整.sql deleted
1   -/*
2   - Navicat Premium Data Transfer
3   -
4   - Source Server : docer-master-root(3308)
5   - Source Server Type : MySQL
6   - Source Server Version : 80030
7   - Source Host : 10.211.55.5:3308
8   - Source Schema : mall
9   -
10   - Target Server Type : MySQL
11   - Target Server Version : 80030
12   - File Encoding : 65001
13   -
14   - Date: 09/08/2023 22:41:36
15   -*/
16   -
17   -SET NAMES utf8mb4;
18   -SET FOREIGN_KEY_CHECKS = 0;
19   -
20   --- ----------------------------
21   --- Table structure for member_point_config
22   --- ----------------------------
23   -DROP TABLE IF EXISTS `member_point_config`;
24   -CREATE TABLE `member_point_config` (
25   - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
26   - `trade_deduct_enable` bit(1) DEFAULT NULL COMMENT '1 开启积分抵扣\n0 关闭积分抵扣',
27   - `trade_deduct_unit_price` int DEFAULT NULL COMMENT '积分抵扣(单位:分)',
28   - `trade_deduct_max_price` int DEFAULT NULL COMMENT '积分抵扣最大值',
29   - `trade_give_point` int DEFAULT NULL COMMENT '1元赠送多少分',
30   - `creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人',
31   - `create_time` datetime DEFAULT NULL COMMENT '创建时间',
32   - `updater` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '更新人',
33   - `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
34   - `tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
35   - `deleted` bit(1) DEFAULT b'0' COMMENT '是否被删除 0 未删除 1已删除',
36   - PRIMARY KEY (`id`)
37   -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='会员积分配置表';
38   -
39   --- ----------------------------
40   --- Records of member_point_config
41   --- ----------------------------
42   -BEGIN;
43   -INSERT INTO `member_point_config` (`id`, `trade_deduct_enable`, `trade_deduct_unit_price`, `trade_deduct_max_price`, `trade_give_point`, `creator`, `create_time`, `updater`, `update_time`, `tenant_id`, `deleted`) VALUES (5, b'1', 12504, 1234, 1234, '1', '2023-08-09 22:27:42', '1', '2023-08-09 22:32:55', '1', b'0');
44   -COMMIT;
45   -
46   --- ----------------------------
47   --- Table structure for member_point_record
48   --- ----------------------------
49   -DROP TABLE IF EXISTS `member_point_record`;
50   -CREATE TABLE `member_point_record` (
51   - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
52   - `biz_id` varchar(255) DEFAULT NULL COMMENT '业务编码',
53   - `biz_type` varchar(255) DEFAULT NULL COMMENT '业务类型',
54   - `title` varchar(255) DEFAULT NULL COMMENT '积分标题',
55   - `description` varchar(5000) DEFAULT NULL COMMENT '积分描述',
56   - `point` int DEFAULT NULL COMMENT '积分',
57   - `total_point` int NOT NULL COMMENT '变动后的积分',
58   - `status` int DEFAULT NULL COMMENT '状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款)\n',
59   - `user_id` bigint DEFAULT NULL COMMENT '用户id',
60   - `freezing_time` datetime DEFAULT NULL COMMENT '冻结时间',
61   - `thawing_time` datetime DEFAULT NULL COMMENT '解冻时间',
62   - `create_time` datetime DEFAULT NULL COMMENT '发生时间',
63   - `tenant_id` varchar(255) DEFAULT NULL COMMENT '租户',
64   - `deleted` int DEFAULT '0' COMMENT '是否删除',
65   - `creator` varchar(255) DEFAULT NULL COMMENT '创建用户',
66   - `updater` varchar(255) DEFAULT NULL COMMENT '更新用户',
67   - `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
68   - PRIMARY KEY (`id`),
69   - KEY `index_userId` (`user_id`),
70   - KEY `index_title` (`title`) USING BTREE
71   -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户积分记录';
72   -
73   --- ----------------------------
74   --- Records of member_point_record
75   --- ----------------------------
76   -BEGIN;
77   -INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (1, '1', '1', '12', NULL, 212, 12, 1, 247, '2023-06-13 00:00:00', '2023-06-20 00:00:00', '2023-06-10 12:38:48', '1', 1, '1', '1', '2023-08-09 12:30:36');
78   -INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (2, '12', '1', '这是一个测试', '我是描述', 1212, 12, 2, 247, '2023-06-28 00:00:00', NULL, '2023-06-10 12:42:48', '1', 0, '1', '1', '2023-08-09 12:31:45');
79   -INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (3, '12', '1', '12', '我是一个描述', 12, 12, 1, 248, '2023-06-27 00:00:00', '2023-06-23 00:00:00', '2023-06-10 20:06:48', '1', 0, '1', '1', '2023-08-09 12:31:41');
80   -INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (4, '12', '1', '描述2', '我是一个描述', -12, 12, 1, 248, '2023-08-09 11:21:00', '2023-09-13 00:00:00', '2023-06-10 20:06:48', '1', 0, '1', '1', '2023-08-09 12:57:28');
81   -COMMIT;
82   -
83   --- ----------------------------
84   --- Table structure for member_sign_in_config
85   --- ----------------------------
86   -DROP TABLE IF EXISTS `member_sign_in_config`;
87   -CREATE TABLE `member_sign_in_config` (
88   - `id` int NOT NULL AUTO_INCREMENT COMMENT '规则自增主键',
89   - `day` int DEFAULT NULL COMMENT '签到第x天',
90   - `point` int DEFAULT NULL COMMENT '签到天数对应分数',
91   - `create_time` datetime DEFAULT NULL COMMENT '创建时间',
92   - `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
93   - `tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
94   - `enable` tinyint(1) DEFAULT NULL COMMENT '是否启用 1启用,0未启动',
95   - `deleted` int DEFAULT '0' COMMENT '是否删除',
96   - `creator` varchar(255) DEFAULT NULL COMMENT '创建人',
97   - `updater` varchar(255) DEFAULT NULL COMMENT '变更人',
98   - PRIMARY KEY (`id`)
99   -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='积分签到规则';
100   -
101   --- ----------------------------
102   --- Records of member_sign_in_config
103   --- ----------------------------
104   -BEGIN;
105   -INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `enable`, `deleted`, `creator`, `updater`) VALUES (1, 4, 10, '2023-06-10 11:34:43', '2023-08-08 15:10:03', '1', 1, 0, '1', '1');
106   -INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `enable`, `deleted`, `creator`, `updater`) VALUES (2, 2, 20, '2023-06-10 11:34:59', '2023-08-08 13:39:54', '1', 1, 1, '1', '1');
107   -INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `enable`, `deleted`, `creator`, `updater`) VALUES (3, 7, 1001, '2023-06-10 17:47:45', '2023-08-08 15:09:55', '1', 0, 0, '1', '1');
108   -INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `enable`, `deleted`, `creator`, `updater`) VALUES (4, 6, 12121, '2023-06-10 17:47:55', '2023-08-08 15:09:47', '1', 0, 0, '1', '1');
109   -INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `enable`, `deleted`, `creator`, `updater`) VALUES (5, 2, 12, '2023-06-10 19:54:52', '2023-08-08 15:10:03', '1', 1, 0, '1', '1');
110   -COMMIT;
111   -
112   --- ----------------------------
113   --- Table structure for member_sign_in_record
114   --- ----------------------------
115   -DROP TABLE IF EXISTS `member_sign_in_record`;
116   -CREATE TABLE `member_sign_in_record` (
117   - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '签到自增id',
118   - `user_id` bigint DEFAULT NULL COMMENT '签到用户',
119   - `day` int DEFAULT NULL COMMENT '第几天签到',
120   - `point` int DEFAULT NULL COMMENT '签到的分数',
121   - `create_time` datetime DEFAULT NULL COMMENT '签到时间',
122   - `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
123   - `tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
124   - `deleted` int DEFAULT '0' COMMENT '是否删除',
125   - `creator` varchar(255) DEFAULT NULL COMMENT '创建人',
126   - `updater` varchar(255) DEFAULT NULL COMMENT '更新人',
127   - PRIMARY KEY (`id`)
128   -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户签到积分';
129   -
130   --- ----------------------------
131   --- Records of member_sign_in_record
132   --- ----------------------------
133   -BEGIN;
134   -INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (1, 247, 1, 123, '2023-06-10 12:58:18', '2023-08-09 08:51:31', '1', 1, '1', '1');
135   -INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (2, 247, 12, 12, '2023-06-10 19:56:39', '2023-08-09 08:51:32', '1', 1, '1', '1');
136   -INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (3, 1, 12, 1212, '2023-06-10 20:01:17', '2023-08-09 08:05:07', '1', 1, '1', '1');
137   -INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (4, 247, 12, 1212, '2023-06-10 20:01:27', '2023-08-09 08:51:34', '1', 0, '1', '1');
138   -COMMIT;
139   -
140   -SET FOREIGN_KEY_CHECKS = 1;
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.member.enums.point;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
  4 +import lombok.AllArgsConstructor;
  5 +import lombok.Getter;
  6 +
  7 +/**
  8 + * 会员积分的业务类型枚举
  9 + *
  10 + * @author 芋道源码
  11 + */
  12 +@AllArgsConstructor
  13 +@Getter
  14 +public enum MemberPointBizTypeEnum implements IntArrayValuable {
  15 +
  16 + SIGN(1, "签到"),
  17 + ORDER_BUY(10, "订单消费"),
  18 + ORDER_CANCEL(11, "订单取消"); // 退回积分
  19 +
  20 + /**
  21 + * 类型
  22 + */
  23 + private final Integer type;
  24 + /**
  25 + * 名字
  26 + */
  27 + private final String name;
  28 +
  29 + @Override
  30 + public int[] array() {
  31 + return new int[0];
  32 + }
  33 +
  34 +}
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java
... ... @@ -16,12 +16,9 @@ public class MemberPointRecordPageReqVO extends PageParam {
16 16 private String nickname;
17 17  
18 18 @Schema(description = "业务类型", example = "1")
19   - private String bizType;
  19 + private Integer bizType;
20 20  
21 21 @Schema(description = "积分标题", example = "呵呵")
22 22 private String title;
23 23  
24   - @Schema(description = "积分状态", example = "1")
25   - private Integer status;
26   -
27 24 }
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java
1 1 package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.*;
5   -import org.springframework.format.annotation.DateTimeFormat;
  4 +import lombok.Data;
6 5  
7   -import javax.validation.constraints.NotNull;
8 6 import java.time.LocalDateTime;
9 7  
10   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11   -
12 8 @Schema(description = "管理后台 - 用户积分记录 Response VO")
13 9 @Data
14 10 public class MemberPointRecordRespVO {
... ... @@ -26,7 +22,7 @@ public class MemberPointRecordRespVO {
26 22 private String bizId;
27 23  
28 24 @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
29   - private String bizType;
  25 + private Integer bizType;
30 26  
31 27 @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
32 28 private String title;
... ... @@ -40,17 +36,6 @@ public class MemberPointRecordRespVO {
40 36 @Schema(description = "变动后的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
41 37 private Integer totalPoint;
42 38  
43   - @Schema(description = "积分状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
44   - private Integer status;
45   -
46   - @Schema(description = "冻结时间")
47   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
48   - private LocalDateTime freezingTime;
49   -
50   - @Schema(description = "解冻时间")
51   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
52   - private LocalDateTime thawingTime;
53   -
54 39 @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
55 40 private LocalDateTime createTime;
56 41  
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java
1 1 package cn.iocoder.yudao.module.member.dal.dataobject.point;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
4 5 import com.baomidou.mybatisplus.annotation.KeySequence;
5 6 import com.baomidou.mybatisplus.annotation.TableId;
6 7 import com.baomidou.mybatisplus.annotation.TableName;
7 8 import lombok.*;
8 9  
9   -import java.time.LocalDateTime;
10   -
11 10 /**
12 11 * 用户积分记录 DO
13 12 *
... ... @@ -42,10 +41,10 @@ public class MemberPointRecordDO extends BaseDO {
42 41 /**
43 42 * 业务类型
44 43 *
45   - * 枚举 {@link TODO biz_type 对应枚举,然后改成 int 类型哈}
46   - * TODO @qingxia:这个改成 Integer,然后搞个枚举
  44 + * 枚举 {@link MemberPointBizTypeEnum}
47 45 */
48   - private String bizType;
  46 + private Integer bizType;
  47 +
49 48 /**
50 49 * 积分标题
51 50 */
... ... @@ -54,29 +53,17 @@ public class MemberPointRecordDO extends BaseDO {
54 53 * 积分描述
55 54 */
56 55 private String description;
  56 +
57 57 /**
58   - * 积分 正数表示获得积分 负数表示消耗积分
  58 + * 变动积分
  59 + *
  60 + * 1、正数表示获得积分
  61 + * 2、负数表示消耗积分
59 62 */
60 63 private Integer point;
61 64 /**
62 65 * 变动后的积分
63 66 */
64 67 private Integer totalPoint;
65   - /**
66   - * 状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款)
67   - *
68   - * 枚举 {@link point_status 对应的类}
69   - * TODO @qingxia:搞个枚举
70   - */
71   - private Integer status;
72   -
73   - /**
74   - * 冻结时间
75   - */
76   - private LocalDateTime freezingTime;
77   - /**
78   - * 解冻时间
79   - */
80   - private LocalDateTime thawingTime;
81 68  
82 69 }
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java
... ... @@ -22,7 +22,6 @@ public interface MemberPointRecordMapper extends BaseMapperX<MemberPointRecordDO
22 22 .inIfPresent(MemberPointRecordDO::getUserId, userIds)
23 23 .eqIfPresent(MemberPointRecordDO::getBizType, reqVO.getBizType())
24 24 .likeIfPresent(MemberPointRecordDO::getTitle, reqVO.getTitle())
25   - .eqIfPresent(MemberPointRecordDO::getStatus, reqVO.getStatus())
26 25 .orderByDesc(MemberPointRecordDO::getId));
27 26 }
28 27  
... ...