diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index fdac576..5afd99a 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -18,59 +18,39 @@ public class ErrorConstants { public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核"; public final static String MUST_OPERATE_IN_PERSON = "必须本人操作"; - public final static String USER_VERIFICATION_FAILURE = "用户校验失败,请重新登录"; - public final static String THE_SONG_DOES_NOT_EXIST = "该专辑不存在此歌曲"; - public final static String ALBUM_DOES_NOT_EXIST = "专辑不存在,请刷新后重试"; - public final static String CAUSE_OF_FORCE_MAJEURE = "专辑因不可抗力原因无法显示"; - public final static String PRICE_CAN_NOT_BE_EMPTY = "定价不能为空"; - public final static String PRICING_MUST_BE_GREATER_THAN_0 = "定价必须大于0"; - public final static String ALBUM_SONG_LIST_IS_EMPTY = "专辑歌曲为空"; - public final static String STATE_ERROR = "状态错误"; // 用户部分 public final static String REAL_NAME_APPROVE_IS_EXISTS = "该用户实名认证已存在"; - public final static String REAL_NAME_IS_CHECKED = "该用户实名认证已审核完成"; - public final static String REAL_NAME_ERROR = "实名认证错误"; - public final static String REASONS_FOR_REFUSAL_MUST_BE_GIVEN = "必须填写拒绝理由"; - public final static String THE_BANK_CARD_HAS_BEEN_BOUND = "该银行卡已绑定"; - public final static String NO_BANK_CARD = "没有绑定银行卡"; - public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0"; - public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核"; - public final static String USER_STATUS_ERROR = "用户状态错误"; - public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在"; + // 会员部分 + public static final String MEMBERSHIP_CODE_NOT_EXISTS = "会员码不存在"; + public static final String MEMBERSHIP_CODE_ALREADY_USED = "会员码已使用,禁止删除"; + // 抽奖部分 public static final String CAN_NOT_EDIT = "不允许修改"; - public static final String NOT_IN_THE_SIGN_UP_PERIOD = "不是报名中,不允许参与"; - public static final String NOT_MEMBER = "非会员不能参与"; - public static final String NOT_PERMANENT_MEMBER = "非永久会员不能参与"; - public static final String NOT_CONTRIBUTOR = "非贡献者不能参与"; - public static final String NOT_ARTIST = "非音乐人不能参与"; - public static final String ALREADY_PARTICIPATED = "已参与抽奖"; - public static final String NOT_END_OF_SIGN_UP = "报名未结束,不允许抽奖"; } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MembershipController.java b/luoo_user/src/main/java/com/luoo/user/controller/MembershipController.java index 817542c..5a88df3 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MembershipController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MembershipController.java @@ -86,7 +86,7 @@ public class MembershipController extends BaseController { @GlobalInterceptor(checkAdminLogin = true) public Result> queryMembershipCode( @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody @ApiParam(value = "查询参数", required = true) MembershipCodeSearchDto membershipCodeSearchDto, + @ApiParam(value = "查询参数", required = true) MembershipCodeSearchDto membershipCodeSearchDto, @ApiParam(value = "页码", required = true) @PathVariable Integer page, @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { return Result.success(membershipCodeService.getMembershipCodeList(authorization, page, size, @@ -95,9 +95,9 @@ public class MembershipController extends BaseController { @ApiOperation(value = "4.导出会员码", notes = "仅限admin权限用户调用") @PostMapping("/code/export") -// @GlobalInterceptor(checkAdminLogin = true) + @GlobalInterceptor(checkAdminLogin = true) public void exportMembershipCode( -// @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestHeader(value = "Authorization", required = true) String authorization, HttpServletResponse response, @RequestBody @ApiParam(value = "查询参数", required = true) MembershipCodeSearchDto membershipCodeSearchDto) { List list = membershipCodeService.getMembershipCodeListAll(membershipCodeSearchDto); @@ -105,5 +105,14 @@ public class MembershipController extends BaseController { util.exportExcel(response, list, "会员码"); } + @ApiOperation(value = "5.删除会员码", notes = "仅限admin权限用户调用") + @PostMapping("/code/del") + @GlobalInterceptor(checkAdminLogin = true) + public Result delMembershipCode( + @RequestHeader(value = "Authorization", required = true) String authorization, + @ApiParam(value = "会员码id", required = true) String id) { + membershipCodeService.delMembershipCode(authorization, id); + return Result.success(); + } } diff --git a/luoo_user/src/main/java/com/luoo/user/dto/memberShip/MembershipCodeSearchDto.java b/luoo_user/src/main/java/com/luoo/user/dto/memberShip/MembershipCodeSearchDto.java index a2c3f03..1be0e3a 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/memberShip/MembershipCodeSearchDto.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/memberShip/MembershipCodeSearchDto.java @@ -1,11 +1,15 @@ package com.luoo.user.dto.memberShip; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; +import java.util.Date; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; /** * DTO for {@link com.luoo.user.pojo.MembershipCode} @@ -31,4 +35,9 @@ public class MembershipCodeSearchDto implements Serializable { @ApiModelProperty(value = "创建人") private String createUser; + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date eventDate; + } \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/service/MembershipCodeService.java b/luoo_user/src/main/java/com/luoo/user/service/MembershipCodeService.java index cf31fad..c6aac16 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/MembershipCodeService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/MembershipCodeService.java @@ -4,10 +4,9 @@ import api.PageResult; import com.luoo.user.dao.MembershipCodeDao; import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dto.memberShip.MembershipCodeSearchDto; -import com.luoo.user.dto.point.UserPointLogSearchDto; import com.luoo.user.pojo.MembershipCode; import com.luoo.user.pojo.UserInfo; -import com.luoo.user.pojo.UserPointLog; +import constants.ErrorConstants; import constants.TaskPointIdConstants; import dto.UserLoginDto; import enums.MembershipEnums; @@ -128,7 +127,7 @@ public class MembershipCodeService { MembershipCode membershipCode = membershipCodeDao.findMembershipCodeByCodeAndStatus(code, MembershipEnums.CREATED.getCode()); if (membershipCode == null) { - throw new BizException("会员码不存在"); + throw new BizException(ErrorConstants.MEMBERSHIP_CODE_NOT_EXISTS); } // 处理会员码表 membershipCode.setStatus(MembershipEnums.BIND.getCode()); @@ -142,14 +141,14 @@ public class MembershipCodeService { UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get(); String result = ""; - if(userInfo.getVipStatus() == UserVipStatusEnum.INITIAL.getCode()) { + if (userInfo.getVipStatus() == UserVipStatusEnum.INITIAL.getCode()) { // 首次开通会员 Integer point = userPointLogService.addByTaskNew(TaskPointIdConstants.BUY_MEMBER, token); result = "首次开通会员,积分增加" + point + "分"; } // 永久会员码 - if(Objects.equals(membershipCode.getLife(), PointEnums.MEMBERSHIP_LIFE.getCode())) { + if (Objects.equals(membershipCode.getLife(), PointEnums.MEMBERSHIP_LIFE.getCode())) { userInfo.setVipStatus(UserVipStatusEnum.LIFE.getCode()); } else { // 非永久会员码 @@ -189,6 +188,28 @@ public class MembershipCodeService { return membershipCodeDao.findAll(specification); } + /** + * 删除会员码 + * + * @param token token + * @param id 会员码id + */ + @Transactional(rollbackFor = Exception.class) + public void delMembershipCode(String token, String id) { + UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); + + MembershipCode membershipCode = membershipCodeDao.findById(id).get(); + if (!Objects.equals(membershipCode.getStatus(), MembershipEnums.CREATED.getCode())) { + // 已使用,禁止删除 + throw new BizException(ErrorConstants.MEMBERSHIP_CODE_ALREADY_USED); + } + + membershipCode.setStatus(MembershipEnums.DISCARD.getCode()); + membershipCode.setUpdateUser(userLoginDto.getUserId()); + membershipCode.setUpdateUserName(userLoginDto.getNickName()); + membershipCodeDao.save(membershipCode); + } + private Specification buildSearchSpecification(MembershipCodeSearchDto param) { return (Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) -> { List predicateList = new ArrayList(); @@ -219,6 +240,11 @@ public class MembershipCodeService { criteriaBuilder.and(criteriaBuilder.equal(root.get("duration"), param.getDuration()))); } + if (param.getEventDate() != null) { + predicateList.add( + criteriaBuilder.and(criteriaBuilder.equal(criteriaBuilder.function("DATE", LocalDate.class, root.get("createTime")), param.getEventDate()))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); }; }