diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java index ef207075c..7745599bf 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java @@ -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 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 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> getRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { - PageResult pageResult = recordService.getRecordPage(pageVO); - return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult)); + public CommonResult > getRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { + //根据用户昵称查询出用户ids + List userIds = null; + if (StringUtils.isNotBlank(pageVO.getNickName())) { + List 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 pageResult = recordService.getRecordPage(pageVO); + //根据查询的userId转换成nickName + List result = pageResult.getList(); + List users = null; + if (!CollectionUtils.isEmpty(result)) { + List ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList()); + users = memberUserApi.getUsers(ids); + } + return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult,users)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java index 4d7de8d42..1af043be0 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/config/MemberPointConfigBaseVO.java @@ -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") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordBaseVO.java index 9d0c2604a..bae11b281 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordBaseVO.java @@ -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 = "冻结时间不能为空") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordCreateReqVO.java deleted file mode 100644 index d0214c2cc..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordCreateReqVO.java +++ /dev/null @@ -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 { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordExportReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordExportReqVO.java deleted file mode 100644 index 0858bbd4f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordExportReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java index 7275314cd..3f24ec5b7 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java @@ -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 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; + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java index d48cf6de8..851fc9396 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java @@ -16,4 +16,7 @@ public class MemberPointRecordRespVO extends MemberPointRecordBaseVO { @Schema(description = "发生时间") private LocalDateTime createTime; + //昵称 + private String nickName; + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordUpdateReqVO.java deleted file mode 100644 index 6da3e7688..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordUpdateReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java index d8abba748..5a8438980 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java @@ -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 > getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { + //请求中如果有nickName,需要根据nickName查询出userId + if(StringUtils.isNotBlank(pageVO.getNickName())){ + List 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 pageResult = memberSignInRecordService.getSignInRecordPage(pageVO); List result = pageResult.getList(); //设置获取的用户信息 - List users = null; + List users = null; if (!CollectionUtils.isEmpty(result)) { List 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)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java index eace459f9..11dd6d69c 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java @@ -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 ListuserIds; @Schema(description = "第几天签到") private Integer day; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointConfigConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointConfigConvert.java index d1cdd1d49..bd0d44281 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointConfigConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointConfigConvert.java @@ -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; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java index 4a771884b..d83d45e22 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java @@ -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 convertPage(PageResult page, List users) { + if (page == null) { + return null; + } - MemberPointRecordDO convert(MemberPointRecordUpdateReqVO bean); + PageResult pageResult = new PageResult (); - MemberPointRecordRespVO convert(MemberPointRecordDO bean); + pageResult.setList(memberPointRecordDOListToMemberPointRecordRespVOList(page.getList(), users)); + pageResult.setTotal(page.getTotal()); + + return pageResult; + } + + default List memberPointRecordDOListToMemberPointRecordRespVOList(List list, List users) { + if (list == null) { + return null; + } + Map maps = null; + //是否需要转换用户标志 + boolean userNickFlag = !CollectionUtils.isEmpty(users); + if (userNickFlag) { + maps = users.stream() + .collect(Collectors.toMap(MemberUserRespDTO::getId, MemberUserRespDTO::getNickname, (key1, key2) -> key2)); + } + List list1 = new ArrayList (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 convertPage(PageResult page); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java index c8b0cba98..13b24b392 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java @@ -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 convertPage(PageResult page, List userRespDTOS) { + default PageResult convertPage(PageResult page, List userRespDTOS) { if (page == null) { return null; } @@ -53,7 +54,7 @@ public interface MemberSignInRecordConvert { return pageResult; } - default List memberSignInRecordDOListToMemberSignInRecordRespVOList(List list,List userRespDTOS) { + default List memberSignInRecordDOListToMemberSignInRecordRespVOList(List list,List 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 list1 = new ArrayList (list.size()); for (MemberSignInRecordDO memberSignInRecordDO : list) { diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java index a7d54219f..f88bda2e5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointConfigDO.java @@ -27,7 +27,7 @@ public class MemberPointConfigDO extends BaseDO { * 自增主键 */ @TableId - private Integer id; + private Long id; /** * 积分抵扣开关 */ diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java index 895aea458..40df4d4a6 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java @@ -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; /** * 冻结时间 */ diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java index 095aa37f7..f3d42d078 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java @@ -17,7 +17,7 @@ public interface MemberPointRecordMapper extends BaseMapperX selectPage(MemberPointRecordPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .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()) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java index 532efa362..5e1cbb1d2 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java @@ -17,7 +17,7 @@ public interface MemberSignInRecordMapper extends BaseMapperX selectPage(MemberSignInRecordPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserId()) + .inIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserIds()) .eqIfPresent(MemberSignInRecordDO::getDay, reqVO.getDay()) .betweenIfPresent(MemberSignInRecordDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(MemberSignInRecordDO::getId)); diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointConfigServiceImpl.java index ebec0b579..0d5731c3b 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointConfigServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointConfigServiceImpl.java @@ -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 list = pointConfigMapper.selectList(); - // TODO @xiaqing:可以使用 CollUtil.getFirst() - return list == null ? null : list.get(0); + return CollectionUtils.getFirst(list); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java index 37ac5ea2d..4c6fb0cb4 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java @@ -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); /** * 获得用户积分记录分页 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java index e1d675723..c0d5bc896 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java @@ -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 getRecordPage(MemberPointRecordPageReqVO pageReqVO) { return recordMapper.selectPage(pageReqVO);