parent
33323c1483
commit
bae94d06ac
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MemberPointConfigBaseVO {
|
|||
@Schema(description = "积分抵扣开关", required = true, example = "true")
|
||||
private Boolean tradeDeductEnable;
|
||||
|
||||
@Schema(description = "积分抵扣,单位:分", example = "13506")
|
||||
@Schema(description = "积分抵扣,单位:元", example = "13506")
|
||||
private BigDecimal tradeDeductUnitPrice;
|
||||
|
||||
@Schema(description = "积分抵扣最大值", example = "32428")
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -2,6 +2,8 @@ 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;
|
||||
|
@ -12,6 +14,7 @@ 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;
|
||||
|
@ -34,20 +37,31 @@ public class MemberSignInRecordController {
|
|||
@Resource
|
||||
private MemberSignInRecordService memberSignInRecordService;
|
||||
@Resource
|
||||
AdminUserApi adminUserApi;
|
||||
MemberUserApi memberUserApi;
|
||||
|
||||
|
||||
@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);
|
||||
List <MemberSignInRecordDO> result = pageResult.getList();
|
||||
//设置获取的用户信息
|
||||
List <AdminUserRespDTO> users = null;
|
||||
List <MemberUserRespDTO> users = null;
|
||||
if (!CollectionUtils.isEmpty(result)) {
|
||||
List <Long> ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList());
|
||||
users = adminUserApi.getUserList(ids);
|
||||
users = memberUserApi.getUsers(ids);
|
||||
}
|
||||
return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users));
|
||||
}
|
||||
|
|
|
@ -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 Long userId;
|
||||
private String nickName;
|
||||
|
||||
private List<Long>userIds;
|
||||
|
||||
@Schema(description = "第几天签到")
|
||||
private Integer day;
|
||||
|
|
|
@ -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,6 +1,7 @@
|
|||
package cn.iocoder.yudao.module.member.convert.signin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
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.dal.dataobject.signin.MemberSignInRecordDO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
|
@ -40,7 +41,7 @@ public interface MemberSignInRecordConvert {
|
|||
return memberSignInRecordRespVO;
|
||||
}
|
||||
|
||||
default PageResult <MemberSignInRecordRespVO> convertPage(PageResult <MemberSignInRecordDO> page, List<AdminUserRespDTO> userRespDTOS) {
|
||||
default PageResult <MemberSignInRecordRespVO> convertPage(PageResult <MemberSignInRecordDO> page, List <MemberUserRespDTO> userRespDTOS) {
|
||||
if (page == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ public interface MemberSignInRecordConvert {
|
|||
return pageResult;
|
||||
}
|
||||
|
||||
default List <MemberSignInRecordRespVO> memberSignInRecordDOListToMemberSignInRecordRespVOList(List <MemberSignInRecordDO> list,List<AdminUserRespDTO> userRespDTOS) {
|
||||
default List <MemberSignInRecordRespVO> memberSignInRecordDOListToMemberSignInRecordRespVOList(List <MemberSignInRecordDO> list,List <MemberUserRespDTO> userRespDTOS) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -62,7 +63,7 @@ public interface MemberSignInRecordConvert {
|
|||
boolean userNickFlag = !CollectionUtils.isEmpty(userRespDTOS);
|
||||
if(userNickFlag){
|
||||
maps = userRespDTOS.stream()
|
||||
.collect(Collectors.toMap(AdminUserRespDTO::getId, AdminUserRespDTO::getNickname, (key1, key2) -> key2));
|
||||
.collect(Collectors.toMap(MemberUserRespDTO::getId, MemberUserRespDTO::getNickname, (key1, key2) -> key2));
|
||||
}
|
||||
List <MemberSignInRecordRespVO> list1 = new ArrayList <MemberSignInRecordRespVO>(list.size());
|
||||
for (MemberSignInRecordDO memberSignInRecordDO : list) {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class MemberPointConfigDO extends BaseDO {
|
|||
* 自增主键
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
private Long id;
|
||||
/**
|
||||
* 积分抵扣开关
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
/**
|
||||
* 冻结时间
|
||||
*/
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue