commit
4177071758
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : docer-master-root(3308)
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80030
|
||||
Source Host : 10.211.55.5:3308
|
||||
Source Schema : mall
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80030
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 09/08/2023 22:41:36
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_point_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_point_config`;
|
||||
CREATE TABLE `member_point_config` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||
`trade_deduct_enable` bit(1) DEFAULT NULL COMMENT '1 开启积分抵扣\n0 关闭积分抵扣',
|
||||
`trade_deduct_unit_price` int DEFAULT NULL COMMENT '积分抵扣(单位:分)',
|
||||
`trade_deduct_max_price` int DEFAULT NULL COMMENT '积分抵扣最大值',
|
||||
`trade_give_point` int DEFAULT NULL COMMENT '1元赠送多少分',
|
||||
`creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`updater` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
|
||||
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
|
||||
`deleted` bit(1) DEFAULT b'0' COMMENT '是否被删除 0 未删除 1已删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='会员积分配置表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of member_point_config
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
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');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_point_record
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_point_record`;
|
||||
CREATE TABLE `member_point_record` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||
`biz_id` varchar(255) DEFAULT NULL COMMENT '业务编码',
|
||||
`biz_type` varchar(255) DEFAULT NULL COMMENT '业务类型',
|
||||
`title` varchar(255) DEFAULT NULL COMMENT '积分标题',
|
||||
`description` varchar(5000) DEFAULT NULL COMMENT '积分描述',
|
||||
`point` int DEFAULT NULL COMMENT '积分',
|
||||
`total_point` int NOT NULL COMMENT '变动后的积分',
|
||||
`status` int DEFAULT NULL COMMENT '状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款)\n',
|
||||
`user_id` bigint DEFAULT NULL COMMENT '用户id',
|
||||
`freezing_time` datetime DEFAULT NULL COMMENT '冻结时间',
|
||||
`thawing_time` datetime DEFAULT NULL COMMENT '解冻时间',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '发生时间',
|
||||
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户',
|
||||
`deleted` int DEFAULT '0' COMMENT '是否删除',
|
||||
`creator` varchar(255) DEFAULT NULL COMMENT '创建用户',
|
||||
`updater` varchar(255) DEFAULT NULL COMMENT '更新用户',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `index_userId` (`user_id`),
|
||||
KEY `index_title` (`title`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户积分记录';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of member_point_record
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
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');
|
||||
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');
|
||||
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');
|
||||
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');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_sign_in_config
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_sign_in_config`;
|
||||
CREATE TABLE `member_sign_in_config` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '规则自增主键',
|
||||
`day` int DEFAULT NULL COMMENT '签到第x天',
|
||||
`point` int DEFAULT NULL COMMENT '签到天数对应分数',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
|
||||
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
|
||||
`is_enable` tinyint(1) DEFAULT NULL COMMENT '是否启用 1启用,0未启动',
|
||||
`deleted` int DEFAULT '0' COMMENT '是否删除',
|
||||
`creator` varchar(255) DEFAULT NULL COMMENT '创建人',
|
||||
`updater` varchar(255) DEFAULT NULL COMMENT '变更人',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='积分签到规则';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of member_sign_in_config
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `is_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');
|
||||
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `is_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');
|
||||
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `is_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');
|
||||
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `is_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');
|
||||
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `is_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');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_sign_in_record
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_sign_in_record`;
|
||||
CREATE TABLE `member_sign_in_record` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '签到自增id',
|
||||
`user_id` bigint DEFAULT NULL COMMENT '签到用户',
|
||||
`day` int DEFAULT NULL COMMENT '第几天签到',
|
||||
`point` int DEFAULT NULL COMMENT '签到的分数',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '签到时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
|
||||
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
|
||||
`deleted` int DEFAULT '0' COMMENT '是否删除',
|
||||
`creator` varchar(255) DEFAULT NULL COMMENT '创建人',
|
||||
`updater` varchar(255) DEFAULT NULL COMMENT '更新人',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户签到积分';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of member_sign_in_record
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
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');
|
||||
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');
|
||||
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');
|
||||
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');
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
|
@ -2,22 +2,28 @@ package cn.iocoder.yudao.module.member.controller.admin.point;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 用户积分记录")
|
||||
|
@ -28,31 +34,34 @@ public class MemberPointRecordController {
|
|||
|
||||
@Resource
|
||||
private MemberPointRecordService recordService;
|
||||
|
||||
// TODO @xiaqing:积分应该没有更新操作呀?可以删除哈;
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户积分记录")
|
||||
@PreAuthorize("@ss.hasPermission('point:record:update')")
|
||||
public CommonResult<Boolean> updateRecord(@Valid @RequestBody MemberPointRecordUpdateReqVO updateReqVO) {
|
||||
recordService.updateRecord(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户积分记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('point:record:query')")
|
||||
public CommonResult<MemberPointRecordRespVO> getRecord(@RequestParam("id") Long id) {
|
||||
MemberPointRecordDO record = recordService.getRecord(id);
|
||||
return success(MemberPointRecordConvert.INSTANCE.convert(record));
|
||||
}
|
||||
@Resource
|
||||
MemberUserApi memberUserApi;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户积分记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('point:record:query')")
|
||||
public CommonResult <PageResult <MemberPointRecordRespVO>> getRecordPage(@Valid MemberPointRecordPageReqVO pageVO) {
|
||||
//根据用户昵称查询出用户ids
|
||||
List <Long> userIds = null;
|
||||
if (StringUtils.isNotBlank(pageVO.getNickName())) {
|
||||
List <MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageVO.getNickName());
|
||||
//如果查询用户结果为空直接返回无需继续查询
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
return success(new PageResult <>());
|
||||
}
|
||||
userIds=users.stream().map(user->user.getId()).collect(Collectors.toList());
|
||||
pageVO.setUserIds(userIds);
|
||||
}
|
||||
|
||||
PageResult <MemberPointRecordDO> pageResult = recordService.getRecordPage(pageVO);
|
||||
return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult));
|
||||
//根据查询的userId转换成nickName
|
||||
List <MemberPointRecordDO> result = pageResult.getList();
|
||||
List <MemberUserRespDTO> users = null;
|
||||
if (!CollectionUtils.isEmpty(result)) {
|
||||
List <Long> ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList());
|
||||
users = memberUserApi.getUsers(ids);
|
||||
}
|
||||
return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult,users));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ public class MemberPointConfigBaseVO {
|
|||
private Boolean tradeDeductEnable;
|
||||
|
||||
@Schema(description = "积分抵扣,单位:分", example = "13506")
|
||||
private BigDecimal tradeDeductUnitPrice;
|
||||
private Integer tradeDeductUnitPrice;
|
||||
|
||||
@Schema(description = "积分抵扣最大值", example = "32428")
|
||||
private Long tradeDeductMaxPrice;
|
||||
private Integer tradeDeductMaxPrice;
|
||||
|
||||
@Schema(description = "1 元赠送多少分")
|
||||
private Long tradeGivePoint;
|
||||
private Integer tradeGivePoint;
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,6 @@ public class MemberPointRecordBaseVO {
|
|||
@NotNull(message = "业务类型不能为空")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "1增加 0扣减", example = "1")
|
||||
@NotNull(message = "操作类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "积分标题")
|
||||
@NotNull(message = "积分标题不能为空")
|
||||
private String title;
|
||||
|
@ -47,10 +43,6 @@ public class MemberPointRecordBaseVO {
|
|||
@NotNull(message = "积分状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "用户id", example = "31169")
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "冻结时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@NotNull(message = "冻结时间不能为空")
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "管理后台 - 用户积分记录创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MemberPointRecordCreateReqVO extends MemberPointRecordBaseVO {
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "管理后台 - 用户积分记录 Excel 导出 Request VO,参数和 PointRecordPageReqVO 是一致的")
|
||||
@Data
|
||||
public class MemberPointRecordExportReqVO {
|
||||
|
||||
@Schema(description = "业务编码", example = "22706")
|
||||
private String bizId;
|
||||
|
||||
@Schema(description = "业务类型", example = "1")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "1增加 0扣减", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "积分标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款) ", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -4,25 +4,28 @@ import lombok.*;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 用户积分记录分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MemberPointRecordPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "业务编码", example = "22706")
|
||||
private String bizId;
|
||||
@Schema(description = "用户昵称", example = "张三")
|
||||
private String nickName;
|
||||
|
||||
//用户id集合,用户将nickName查询转换成user_ids查询
|
||||
private List<Long> userIds;
|
||||
|
||||
@Schema(description = "业务类型", example = "1")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "1增加 0扣减", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "积分标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款) ", example = "1")
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,4 +16,7 @@ public class MemberPointRecordRespVO extends MemberPointRecordBaseVO {
|
|||
@Schema(description = "发生时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
//昵称
|
||||
private String nickName;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户积分记录更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MemberPointRecordUpdateReqVO extends MemberPointRecordBaseVO {
|
||||
|
||||
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457")
|
||||
@NotNull(message = "自增主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.member.controller.admin.signin;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert;
|
||||
|
@ -19,6 +18,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 积分签到规则")
|
||||
|
@ -63,12 +64,12 @@ public class MemberSignInConfigController {
|
|||
return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得积分签到规则分页")
|
||||
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
|
||||
public CommonResult<PageResult<MemberSignInConfigRespVO>> getSignInConfigPage(@Valid MemberSignInConfigPageReqVO pageVO) {
|
||||
PageResult<MemberSignInConfigDO> pageResult = memberSignInConfigService.getSignInConfigPage(pageVO);
|
||||
return success(MemberSignInConfigConvert.INSTANCE.convertPage(pageResult));
|
||||
public CommonResult<List<MemberSignInConfigRespVO>> getSignInConfigPage() {
|
||||
List<MemberSignInConfigDO> pageResult = memberSignInConfigService.getSignInConfigList();
|
||||
return success(MemberSignInConfigConvert.INSTANCE.convertList(pageResult));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,21 +2,30 @@ package cn.iocoder.yudao.module.member.controller.admin.signin;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordRespVO;
|
||||
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||
import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 用户签到积分")
|
||||
|
@ -27,31 +36,33 @@ public class MemberSignInRecordController {
|
|||
|
||||
@Resource
|
||||
private MemberSignInRecordService memberSignInRecordService;
|
||||
@Resource
|
||||
MemberUserApi memberUserApi;
|
||||
|
||||
// TODO @xiaqing:签到是不是不用删除?
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户签到积分")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('point:sign-in-record:delete')")
|
||||
public CommonResult<Boolean> deleteSignInRecord(@RequestParam("id") Long id) {
|
||||
memberSignInRecordService.deleteSignInRecord(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户签到积分")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
|
||||
public CommonResult<MemberSignInRecordRespVO> getSignInRecord(@RequestParam("id") Long id) {
|
||||
MemberSignInRecordDO signInRecord = memberSignInRecordService.getSignInRecord(id);
|
||||
return success(MemberSignInRecordConvert.INSTANCE.convert(signInRecord));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户签到积分分页")
|
||||
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
|
||||
public CommonResult <PageResult <MemberSignInRecordRespVO>> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) {
|
||||
//请求中如果有nickName,需要根据nickName查询出userId
|
||||
if(StringUtils.isNotBlank(pageVO.getNickName())){
|
||||
List<Long> users= memberUserApi.getUserListByNickname(pageVO.getNickName()).stream()
|
||||
.map(user->user.getId()).collect(Collectors.toList());
|
||||
//如果根据昵称查出来的用户为空,则无需继续查找
|
||||
if(CollectionUtils.isEmpty(users)){
|
||||
return success(new PageResult <>());
|
||||
}
|
||||
pageVO.setUserIds(users);
|
||||
}
|
||||
//处理查询结果首先将数据信息查询,然后将userId转换为nickName
|
||||
PageResult <MemberSignInRecordDO> pageResult = memberSignInRecordService.getSignInRecordPage(pageVO);
|
||||
return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult));
|
||||
List <MemberSignInRecordDO> result = pageResult.getList();
|
||||
//设置获取的用户信息
|
||||
List <MemberUserRespDTO> users = null;
|
||||
if (!CollectionUtils.isEmpty(result)) {
|
||||
List <Long> ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList());
|
||||
users = memberUserApi.getUsers(ids);
|
||||
}
|
||||
return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,8 @@ public class MemberSignInConfigBaseVO {
|
|||
@Schema(description = "签到天数对应分数", example = "10")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "是否启用", example = "1")
|
||||
private Boolean isEnable;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.signin.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
@Schema(description = "管理后台 - 积分签到规则分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MemberSignInConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "签到第x天", example = "7")
|
||||
private Integer day;
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import lombok.Data;
|
|||
public class MemberSignInRecordBaseVO {
|
||||
|
||||
@Schema(description = "签到用户", example = "6507")
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "第几天签到")
|
||||
private Integer day;
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.ToString;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
|
@ -17,8 +18,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
|||
@ToString(callSuper = true)
|
||||
public class MemberSignInRecordPageReqVO extends PageParam {
|
||||
|
||||
//用户前台模糊查询
|
||||
@Schema(description = "签到用户", example = "6507")
|
||||
private Integer userId;
|
||||
private String nickName;
|
||||
|
||||
private List<Long>userIds;
|
||||
|
||||
@Schema(description = "第几天签到")
|
||||
private Integer day;
|
||||
|
|
|
@ -19,4 +19,7 @@ public class MemberSignInRecordRespVO extends MemberSignInRecordBaseVO {
|
|||
@Schema(description = "签到时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
//昵称,用于前台展示
|
||||
private String nickName;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.member.convert.point;
|
|||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.config.MemberPointConfigRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.config.MemberPointConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package cn.iocoder.yudao.module.member.convert.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户积分记录 Convert
|
||||
|
@ -18,12 +23,62 @@ public interface MemberPointRecordConvert {
|
|||
|
||||
MemberPointRecordConvert INSTANCE = Mappers.getMapper(MemberPointRecordConvert.class);
|
||||
|
||||
MemberPointRecordDO convert(MemberPointRecordCreateReqVO bean);
|
||||
default PageResult <MemberPointRecordRespVO> convertPage(PageResult <MemberPointRecordDO> page, List <MemberUserRespDTO> users) {
|
||||
if (page == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MemberPointRecordDO convert(MemberPointRecordUpdateReqVO bean);
|
||||
PageResult <MemberPointRecordRespVO> pageResult = new PageResult <MemberPointRecordRespVO>();
|
||||
|
||||
MemberPointRecordRespVO convert(MemberPointRecordDO bean);
|
||||
pageResult.setList(memberPointRecordDOListToMemberPointRecordRespVOList(page.getList(), users));
|
||||
pageResult.setTotal(page.getTotal());
|
||||
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
default List <MemberPointRecordRespVO> memberPointRecordDOListToMemberPointRecordRespVOList(List <MemberPointRecordDO> list, List <MemberUserRespDTO> users) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
Map <Long, String> maps = null;
|
||||
//是否需要转换用户标志
|
||||
boolean userNickFlag = !CollectionUtils.isEmpty(users);
|
||||
if (userNickFlag) {
|
||||
maps = users.stream()
|
||||
.collect(Collectors.toMap(MemberUserRespDTO::getId, MemberUserRespDTO::getNickname, (key1, key2) -> key2));
|
||||
}
|
||||
List <MemberPointRecordRespVO> list1 = new ArrayList <MemberPointRecordRespVO>(list.size());
|
||||
for (MemberPointRecordDO memberPointRecordDO : list) {
|
||||
MemberPointRecordRespVO recordRespVO = memberPointRecordDOToMemberPointRecordRespVO(memberPointRecordDO);
|
||||
recordRespVO.setNickName(maps.get(memberPointRecordDO.getUserId()));
|
||||
list1.add(recordRespVO);
|
||||
}
|
||||
|
||||
return list1;
|
||||
}
|
||||
|
||||
default MemberPointRecordRespVO memberPointRecordDOToMemberPointRecordRespVO(MemberPointRecordDO memberPointRecordDO) {
|
||||
if (memberPointRecordDO == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MemberPointRecordRespVO memberPointRecordRespVO = new MemberPointRecordRespVO();
|
||||
|
||||
memberPointRecordRespVO.setBizId(memberPointRecordDO.getBizId());
|
||||
memberPointRecordRespVO.setBizType(memberPointRecordDO.getBizType());
|
||||
memberPointRecordRespVO.setType(memberPointRecordDO.getType());
|
||||
memberPointRecordRespVO.setTitle(memberPointRecordDO.getTitle());
|
||||
memberPointRecordRespVO.setDescription(memberPointRecordDO.getDescription());
|
||||
memberPointRecordRespVO.setPoint(memberPointRecordDO.getPoint());
|
||||
memberPointRecordRespVO.setTotalPoint(memberPointRecordDO.getTotalPoint());
|
||||
memberPointRecordRespVO.setStatus(memberPointRecordDO.getStatus());
|
||||
memberPointRecordRespVO.setFreezingTime(memberPointRecordDO.getFreezingTime());
|
||||
memberPointRecordRespVO.setThawingTime(memberPointRecordDO.getThawingTime());
|
||||
memberPointRecordRespVO.setId(memberPointRecordDO.getId());
|
||||
memberPointRecordRespVO.setCreateTime(memberPointRecordDO.getCreateTime());
|
||||
|
||||
return memberPointRecordRespVO;
|
||||
}
|
||||
|
||||
PageResult<MemberPointRecordRespVO> convertPage(PageResult<MemberPointRecordDO> page);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package cn.iocoder.yudao.module.member.convert.signin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户签到积分 Convert
|
||||
|
@ -18,12 +25,57 @@ public interface MemberSignInRecordConvert {
|
|||
|
||||
MemberSignInRecordConvert INSTANCE = Mappers.getMapper(MemberSignInRecordConvert.class);
|
||||
|
||||
MemberSignInRecordDO convert(MemberSignInRecordCreateReqVO bean);
|
||||
default public MemberSignInRecordRespVO convert(MemberSignInRecordDO bean) {
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MemberSignInRecordDO convert(MemberSignInRecordUpdateReqVO bean);
|
||||
MemberSignInRecordRespVO memberSignInRecordRespVO = new MemberSignInRecordRespVO();
|
||||
|
||||
MemberSignInRecordRespVO convert(MemberSignInRecordDO bean);
|
||||
memberSignInRecordRespVO.setUserId(bean.getUserId());
|
||||
memberSignInRecordRespVO.setDay(bean.getDay());
|
||||
memberSignInRecordRespVO.setPoint(bean.getPoint());
|
||||
memberSignInRecordRespVO.setId(bean.getId());
|
||||
memberSignInRecordRespVO.setCreateTime(bean.getCreateTime());
|
||||
|
||||
return memberSignInRecordRespVO;
|
||||
}
|
||||
|
||||
default PageResult <MemberSignInRecordRespVO> convertPage(PageResult <MemberSignInRecordDO> page, List <MemberUserRespDTO> userRespDTOS) {
|
||||
if (page == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PageResult <MemberSignInRecordRespVO> pageResult = new PageResult <MemberSignInRecordRespVO>();
|
||||
|
||||
pageResult.setList(memberSignInRecordDOListToMemberSignInRecordRespVOList(page.getList(),userRespDTOS));
|
||||
pageResult.setTotal(page.getTotal());
|
||||
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
default List <MemberSignInRecordRespVO> memberSignInRecordDOListToMemberSignInRecordRespVOList(List <MemberSignInRecordDO> list,List <MemberUserRespDTO> userRespDTOS) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
Map <Long, String> maps=null;
|
||||
//是否需要转换用户标志
|
||||
boolean userNickFlag = !CollectionUtils.isEmpty(userRespDTOS);
|
||||
if(userNickFlag){
|
||||
maps = userRespDTOS.stream()
|
||||
.collect(Collectors.toMap(MemberUserRespDTO::getId, MemberUserRespDTO::getNickname, (key1, key2) -> key2));
|
||||
}
|
||||
List <MemberSignInRecordRespVO> list1 = new ArrayList <MemberSignInRecordRespVO>(list.size());
|
||||
for (MemberSignInRecordDO memberSignInRecordDO : list) {
|
||||
MemberSignInRecordRespVO recordRespVO = convert(memberSignInRecordDO);
|
||||
if(userNickFlag){
|
||||
recordRespVO.setNickName(maps.get(recordRespVO.getUserId()));
|
||||
}
|
||||
list1.add(recordRespVO);
|
||||
}
|
||||
|
||||
return list1;
|
||||
}
|
||||
|
||||
PageResult<MemberSignInRecordRespVO> convertPage(PageResult<MemberSignInRecordDO> page);
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class MemberPointConfigDO extends BaseDO {
|
|||
* 自增主键
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
private Long id;
|
||||
/**
|
||||
* 积分抵扣开关
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ public class MemberPointConfigDO extends BaseDO {
|
|||
*
|
||||
* 1 积分抵扣多少分
|
||||
*/
|
||||
private BigDecimal tradeDeductUnitPrice;
|
||||
private Integer tradeDeductUnitPrice;
|
||||
/**
|
||||
* 积分抵扣最大值
|
||||
*/
|
||||
|
|
|
@ -38,11 +38,6 @@ public class MemberPointRecordDO extends BaseDO {
|
|||
* 枚举 {@link TODO biz_type 对应枚举,然后改成 int 类型哈}
|
||||
*/
|
||||
private String bizType;
|
||||
/**
|
||||
* 1增加 0扣减
|
||||
*/
|
||||
// TODO @xiaqing:要不把 type 合并到 point 里?增加 point 是正数,减少 point 是负数?
|
||||
private String type;
|
||||
/**
|
||||
* 积分标题
|
||||
*/
|
||||
|
@ -52,7 +47,7 @@ public class MemberPointRecordDO extends BaseDO {
|
|||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 积分
|
||||
* 积分 正数表示获得积分 负数表示消耗积分
|
||||
*/
|
||||
private Integer point;
|
||||
/**
|
||||
|
@ -62,13 +57,13 @@ public class MemberPointRecordDO extends BaseDO {
|
|||
/**
|
||||
* 状态:1-订单创建,2-冻结期,3-完成,4-失效(订单退款)
|
||||
*
|
||||
* 枚举 {@link TODO point_status 对应的类}
|
||||
* 枚举 {@link point_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
/**
|
||||
* 冻结时间
|
||||
*/
|
||||
|
|
|
@ -34,5 +34,8 @@ public class MemberSignInConfigDO extends BaseDO {
|
|||
* 签到天数对应分数
|
||||
*/
|
||||
private Integer point;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class MemberSignInRecordDO extends BaseDO {
|
|||
/**
|
||||
* 签到用户
|
||||
*/
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
/**
|
||||
* 第几天签到
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface MemberPointRecordMapper extends BaseMapperX<MemberPointRecordDO
|
|||
|
||||
default PageResult<MemberPointRecordDO> selectPage(MemberPointRecordPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MemberPointRecordDO>()
|
||||
.eqIfPresent(MemberPointRecordDO::getBizId, reqVO.getBizId())
|
||||
.inIfPresent(MemberPointRecordDO::getUserId,reqVO.getUserIds())
|
||||
.eqIfPresent(MemberPointRecordDO::getBizType, reqVO.getBizType())
|
||||
.eqIfPresent(MemberPointRecordDO::getType, reqVO.getType())
|
||||
.eqIfPresent(MemberPointRecordDO::getTitle, reqVO.getTitle())
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package cn.iocoder.yudao.module.member.dal.mysql.signin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分签到规则 Mapper
|
||||
*
|
||||
|
@ -16,18 +16,32 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfigDO> {
|
||||
|
||||
default PageResult<MemberSignInConfigDO> selectPage(MemberSignInConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MemberSignInConfigDO>()
|
||||
.eqIfPresent(MemberSignInConfigDO::getDay, reqVO.getDay())
|
||||
.orderByAsc(MemberSignInConfigDO::getDay));
|
||||
/**
|
||||
* 描述 :选择性更新对象属性,如果不为空则更新。
|
||||
* Author :xiaqing
|
||||
* Date :2023-08-08 23:38:48
|
||||
*/
|
||||
default int updateIfPresent(MemberSignInConfigDO updateObj){
|
||||
LambdaUpdateWrapper <MemberSignInConfigDO> wrapper = new LambdaUpdateWrapper <>();
|
||||
wrapper.eq(MemberSignInConfigDO::getId, updateObj.getId())
|
||||
.set(updateObj.getDay() != null, MemberSignInConfigDO::getDay, updateObj.getDay())
|
||||
.set(updateObj.getPoint() != null, MemberSignInConfigDO::getPoint, updateObj.getPoint())
|
||||
.set(updateObj.getIsEnable() != null, MemberSignInConfigDO::getIsEnable, updateObj.getIsEnable());
|
||||
return update(null,wrapper);
|
||||
}
|
||||
|
||||
//
|
||||
default long selectSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO){
|
||||
return selectCount(new LambdaQueryWrapperX <MemberSignInConfigDO>()
|
||||
.ne(MemberSignInConfigDO::getId, reqVO.getId())
|
||||
.eq(MemberSignInConfigDO::getDay,reqVO.getDay())
|
||||
);
|
||||
default List <MemberSignInConfigDO> getList(){
|
||||
return selectList(new LambdaQueryWrapperX <MemberSignInConfigDO>().orderByAsc(MemberSignInConfigDO::getDay));
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 :根据天数查询对应记录
|
||||
* Date :2023-08-09 00:07:11
|
||||
*/
|
||||
default MemberSignInConfigDO selectByDay(Integer day){
|
||||
return selectOne(new LambdaQueryWrapperX <MemberSignInConfigDO>()
|
||||
.eq(MemberSignInConfigDO::getDay,day));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface MemberSignInRecordMapper extends BaseMapperX<MemberSignInRecord
|
|||
|
||||
default PageResult<MemberSignInRecordDO> selectPage(MemberSignInRecordPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MemberSignInRecordDO>()
|
||||
.eqIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserId())
|
||||
.inIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserIds())
|
||||
.eqIfPresent(MemberSignInRecordDO::getDay, reqVO.getDay())
|
||||
.betweenIfPresent(MemberSignInRecordDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MemberSignInRecordDO::getId));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.yudao.module.member.service.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.config.MemberPointConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.point.MemberPointConfigConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
||||
|
@ -24,13 +26,15 @@ public class MemberPointConfigServiceImpl implements MemberPointConfigService {
|
|||
|
||||
@Override
|
||||
public void saveConfig(MemberPointConfigSaveReqVO saveReqVO) {
|
||||
// TODO @xiaqing:直接 getConfig() 查询,如果不存在,则插入;存在,则进行更新;
|
||||
long total = pointConfigMapper.selectCount();
|
||||
//获取当前记录
|
||||
MemberPointConfigDO configDO = getConfig();
|
||||
MemberPointConfigDO pointConfigDO = MemberPointConfigConvert.INSTANCE.convert(saveReqVO);
|
||||
//大于0存在记录,则更新,否则插入
|
||||
if (total > 0) {
|
||||
//当前存在记录,则更新,否则插入
|
||||
if (configDO != null) {
|
||||
pointConfigDO.setId(configDO.getId());
|
||||
pointConfigMapper.updateById(pointConfigDO);
|
||||
} else {
|
||||
pointConfigDO.setId(null);
|
||||
pointConfigMapper.insert(pointConfigDO);
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +42,7 @@ public class MemberPointConfigServiceImpl implements MemberPointConfigService {
|
|||
@Override
|
||||
public MemberPointConfigDO getConfig() {
|
||||
List <MemberPointConfigDO> list = pointConfigMapper.selectList();
|
||||
// TODO @xiaqing:可以使用 CollUtil.getFirst()
|
||||
return list == null ? null : list.get(0);
|
||||
return CollectionUtils.getFirst(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.member.service.point;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -13,23 +12,6 @@ import javax.validation.Valid;
|
|||
* @author QingX
|
||||
*/
|
||||
public interface MemberPointRecordService {
|
||||
// TODO @xiaqing:方法和方法之间,是空一行哈;
|
||||
|
||||
/**
|
||||
* 更新用户积分记录
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateRecord(@Valid MemberPointRecordUpdateReqVO updateReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 获得用户积分记录
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户积分记录
|
||||
*/
|
||||
MemberPointRecordDO getRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户积分记录分页
|
||||
|
|
|
@ -2,19 +2,12 @@ package cn.iocoder.yudao.module.member.service.point;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.point.MemberPointRecordMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -29,26 +22,6 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
|||
@Resource
|
||||
private MemberPointRecordMapper recordMapper;
|
||||
|
||||
@Override
|
||||
public void updateRecord(MemberPointRecordUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateRecordExists(updateReqVO.getId());
|
||||
// 更新
|
||||
MemberPointRecordDO updateObj = MemberPointRecordConvert.INSTANCE.convert(updateReqVO);
|
||||
recordMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void validateRecordExists(Long id) {
|
||||
if (recordMapper.selectById(id) == null) {
|
||||
throw exception(ErrorCodeConstants.RECORD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberPointRecordDO getRecord(Long id) {
|
||||
return recordMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MemberPointRecordDO> getRecordPage(MemberPointRecordPageReqVO pageReqVO) {
|
||||
return recordMapper.selectPage(pageReqVO);
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package cn.iocoder.yudao.module.member.service.signin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分签到规则 Service 接口
|
||||
|
@ -48,9 +47,8 @@ public interface MemberSignInConfigService {
|
|||
/**
|
||||
* 获得积分签到规则分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 积分签到规则分页
|
||||
*/
|
||||
PageResult<MemberSignInConfigDO> getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO);
|
||||
List<MemberSignInConfigDO> getSignInConfigList();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
package cn.iocoder.yudao.module.member.service.signin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_EXISTS;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
|
||||
|
@ -28,30 +31,28 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
|
|||
@Resource
|
||||
private MemberSignInConfigMapper memberSignInConfigMapper;
|
||||
|
||||
// TODO @xiaqing:这种写的逻辑,最好按照 校验 - 更新这样的顺序写;类似这里,37 要放到 34 前面;updateSignInConfig 也是一样的思路
|
||||
@Override
|
||||
public Integer createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) {
|
||||
// 判断是否重复插入签到天数
|
||||
validateSignInConfigExistsDay(createReqVO.getDay());
|
||||
|
||||
// 插入
|
||||
MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO);
|
||||
// 判断是否重复插入签到天数
|
||||
validateSignInConfigExistsDay(signInConfig.getDay());
|
||||
memberSignInConfigMapper.insert(signInConfig);
|
||||
// 返回
|
||||
return signInConfig.getId();
|
||||
}
|
||||
|
||||
// TODO @xiaqing:这个逻辑的空行要注意;52 到 53 是没必要的空行;而 49 和 50 之间有个空行会好点,可以区分出是 校验 - 更新这样的逻辑间隔
|
||||
@Override
|
||||
public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateSignInConfigExists(updateReqVO.getId());
|
||||
//判断是否重复插入签到天数
|
||||
validateSignInConfigSameDayNotSelf(updateReqVO);
|
||||
// 判断更新的
|
||||
|
||||
// 判断更新
|
||||
MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO);
|
||||
|
||||
|
||||
memberSignInConfigMapper.updateById(updateObj);
|
||||
memberSignInConfigMapper.updateIfPresent(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,18 +69,18 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
|
|||
}
|
||||
}
|
||||
|
||||
// TODO @xiaqing:这个唯一判断,也可以参考下别的模块哈;
|
||||
//根据签到天数判断是否存在一个相同的天数
|
||||
private void validateSignInConfigExistsDay(Integer day) {
|
||||
if (memberSignInConfigMapper.selectCount(MemberSignInConfigDO::getDay,day)>0) {
|
||||
MemberSignInConfigDO configDO = memberSignInConfigMapper.selectByDay(day);
|
||||
if (configDO != null) {
|
||||
throw exception(SIGN_IN_CONFIG_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @xiaqing:参考下别的模块,判断唯一,排除自己怎么写的哈;
|
||||
// 更新天数时判断是否有重复的天数,需要去除自己
|
||||
private void validateSignInConfigSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO) {
|
||||
if (memberSignInConfigMapper.selectSameDayNotSelf(reqVO)>0) {
|
||||
MemberSignInConfigDO configDO = memberSignInConfigMapper.selectByDay(reqVO.getDay());
|
||||
if (configDO != null && configDO.getId() != reqVO.getId()) {
|
||||
throw exception(SIGN_IN_CONFIG_EXISTS);
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +91,8 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
|
|||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MemberSignInConfigDO> getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO) {
|
||||
return memberSignInConfigMapper.selectPage(pageReqVO);
|
||||
public List <MemberSignInConfigDO> getSignInConfigList() {
|
||||
return memberSignInConfigMapper.getList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,20 +11,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO
|
|||
*/
|
||||
public interface MemberSignInRecordService {
|
||||
|
||||
/**
|
||||
* 删除用户签到积分
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSignInRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户签到积分
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户签到积分
|
||||
*/
|
||||
MemberSignInRecordDO getSignInRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户签到积分分页
|
||||
|
@ -34,4 +21,5 @@ public interface MemberSignInRecordService {
|
|||
*/
|
||||
PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
|
@ -23,25 +24,10 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
|
|||
|
||||
@Resource
|
||||
private MemberSignInRecordMapper memberSignInRecordMapper;
|
||||
@Resource
|
||||
AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public void deleteSignInRecord(Long id) {
|
||||
// 校验存在
|
||||
validateSignInRecordExists(id);
|
||||
// 删除
|
||||
memberSignInRecordMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateSignInRecordExists(Long id) {
|
||||
if (memberSignInRecordMapper.selectById(id) == null) {
|
||||
throw exception(SIGN_IN_RECORD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberSignInRecordDO getSignInRecord(Long id) {
|
||||
return memberSignInRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) {
|
||||
|
|
|
@ -51,24 +51,24 @@ spring:
|
|||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
|
||||
username: root
|
||||
password: 123456
|
||||
password: 1qaz!QAZ
|
||||
# username: sa
|
||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||
slave: # 模拟从库,可根据自己需要修改
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
|
||||
username: root
|
||||
password: 123456
|
||||
password: 1qaz!QAZ
|
||||
# username: sa
|
||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
redis:
|
||||
host: 127.0.0.1 # 地址
|
||||
host: 10.211.55.5 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 0 # 数据库索引
|
||||
# password: dev # 密码,建议生产环境开启
|
||||
|
|
Loading…
Reference in New Issue