release: 会员码删除

release-2024-08-08
huangyw 4 months ago
parent 0638e946a6
commit d4152a148f

@ -18,59 +18,39 @@ public class ErrorConstants {
public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核"; public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核";
public final static String MUST_OPERATE_IN_PERSON = "必须本人操作"; public final static String MUST_OPERATE_IN_PERSON = "必须本人操作";
public final static String USER_VERIFICATION_FAILURE = "用户校验失败,请重新登录"; public final static String USER_VERIFICATION_FAILURE = "用户校验失败,请重新登录";
public final static String THE_SONG_DOES_NOT_EXIST = "该专辑不存在此歌曲"; public final static String THE_SONG_DOES_NOT_EXIST = "该专辑不存在此歌曲";
public final static String ALBUM_DOES_NOT_EXIST = "专辑不存在,请刷新后重试"; public final static String ALBUM_DOES_NOT_EXIST = "专辑不存在,请刷新后重试";
public final static String CAUSE_OF_FORCE_MAJEURE = "专辑因不可抗力原因无法显示"; public final static String CAUSE_OF_FORCE_MAJEURE = "专辑因不可抗力原因无法显示";
public final static String PRICE_CAN_NOT_BE_EMPTY = "定价不能为空"; public final static String PRICE_CAN_NOT_BE_EMPTY = "定价不能为空";
public final static String PRICING_MUST_BE_GREATER_THAN_0 = "定价必须大于0"; public final static String PRICING_MUST_BE_GREATER_THAN_0 = "定价必须大于0";
public final static String ALBUM_SONG_LIST_IS_EMPTY = "专辑歌曲为空"; public final static String ALBUM_SONG_LIST_IS_EMPTY = "专辑歌曲为空";
public final static String STATE_ERROR = "状态错误"; public final static String STATE_ERROR = "状态错误";
// 用户部分 // 用户部分
public final static String REAL_NAME_APPROVE_IS_EXISTS = "该用户实名认证已存在"; public final static String REAL_NAME_APPROVE_IS_EXISTS = "该用户实名认证已存在";
public final static String REAL_NAME_IS_CHECKED = "该用户实名认证已审核完成"; public final static String REAL_NAME_IS_CHECKED = "该用户实名认证已审核完成";
public final static String REAL_NAME_ERROR = "实名认证错误"; public final static String REAL_NAME_ERROR = "实名认证错误";
public final static String REASONS_FOR_REFUSAL_MUST_BE_GIVEN = "必须填写拒绝理由"; public final static String REASONS_FOR_REFUSAL_MUST_BE_GIVEN = "必须填写拒绝理由";
public final static String THE_BANK_CARD_HAS_BEEN_BOUND = "该银行卡已绑定"; public final static String THE_BANK_CARD_HAS_BEEN_BOUND = "该银行卡已绑定";
public final static String NO_BANK_CARD = "没有绑定银行卡"; public final static String NO_BANK_CARD = "没有绑定银行卡";
public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0"; public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0";
public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核"; public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核";
public final static String USER_STATUS_ERROR = "用户状态错误"; public final static String USER_STATUS_ERROR = "用户状态错误";
public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在"; 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 CAN_NOT_EDIT = "不允许修改";
public static final String NOT_IN_THE_SIGN_UP_PERIOD = "不是报名中,不允许参与"; public static final String NOT_IN_THE_SIGN_UP_PERIOD = "不是报名中,不允许参与";
public static final String NOT_MEMBER = "非会员不能参与"; public static final String NOT_MEMBER = "非会员不能参与";
public static final String NOT_PERMANENT_MEMBER = "非永久会员不能参与"; public static final String NOT_PERMANENT_MEMBER = "非永久会员不能参与";
public static final String NOT_CONTRIBUTOR = "非贡献者不能参与"; public static final String NOT_CONTRIBUTOR = "非贡献者不能参与";
public static final String NOT_ARTIST = "非音乐人不能参与"; public static final String NOT_ARTIST = "非音乐人不能参与";
public static final String ALREADY_PARTICIPATED = "已参与抽奖"; public static final String ALREADY_PARTICIPATED = "已参与抽奖";
public static final String NOT_END_OF_SIGN_UP = "报名未结束,不允许抽奖"; public static final String NOT_END_OF_SIGN_UP = "报名未结束,不允许抽奖";
} }

@ -86,7 +86,7 @@ public class MembershipController extends BaseController {
@GlobalInterceptor(checkAdminLogin = true) @GlobalInterceptor(checkAdminLogin = true)
public Result<PageResult<MembershipCode>> queryMembershipCode( public Result<PageResult<MembershipCode>> queryMembershipCode(
@RequestHeader(value = "Authorization", required = true) String authorization, @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 page,
@ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) {
return Result.success(membershipCodeService.getMembershipCodeList(authorization, page, size, return Result.success(membershipCodeService.getMembershipCodeList(authorization, page, size,
@ -95,9 +95,9 @@ public class MembershipController extends BaseController {
@ApiOperation(value = "4.导出会员码", notes = "仅限admin权限用户调用") @ApiOperation(value = "4.导出会员码", notes = "仅限admin权限用户调用")
@PostMapping("/code/export") @PostMapping("/code/export")
// @GlobalInterceptor(checkAdminLogin = true) @GlobalInterceptor(checkAdminLogin = true)
public void exportMembershipCode( public void exportMembershipCode(
// @RequestHeader(value = "Authorization", required = true) String authorization, @RequestHeader(value = "Authorization", required = true) String authorization,
HttpServletResponse response, HttpServletResponse response,
@RequestBody @ApiParam(value = "查询参数", required = true) MembershipCodeSearchDto membershipCodeSearchDto) { @RequestBody @ApiParam(value = "查询参数", required = true) MembershipCodeSearchDto membershipCodeSearchDto) {
List<MembershipCode> list = membershipCodeService.getMembershipCodeListAll(membershipCodeSearchDto); List<MembershipCode> list = membershipCodeService.getMembershipCodeListAll(membershipCodeSearchDto);
@ -105,5 +105,14 @@ public class MembershipController extends BaseController {
util.exportExcel(response, list, "会员码"); util.exportExcel(response, list, "会员码");
} }
@ApiOperation(value = "5.删除会员码", notes = "仅限admin权限用户调用")
@PostMapping("/code/del")
@GlobalInterceptor(checkAdminLogin = true)
public Result<Void> delMembershipCode(
@RequestHeader(value = "Authorization", required = true) String authorization,
@ApiParam(value = "会员码id", required = true) String id) {
membershipCodeService.delMembershipCode(authorization, id);
return Result.success();
}
} }

@ -1,11 +1,15 @@
package com.luoo.user.dto.memberShip; package com.luoo.user.dto.memberShip;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
/** /**
* DTO for {@link com.luoo.user.pojo.MembershipCode} * DTO for {@link com.luoo.user.pojo.MembershipCode}
@ -31,4 +35,9 @@ public class MembershipCodeSearchDto implements Serializable {
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private String createUser; private String createUser;
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date eventDate;
} }

@ -4,10 +4,9 @@ import api.PageResult;
import com.luoo.user.dao.MembershipCodeDao; import com.luoo.user.dao.MembershipCodeDao;
import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.dto.memberShip.MembershipCodeSearchDto; 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.MembershipCode;
import com.luoo.user.pojo.UserInfo; import com.luoo.user.pojo.UserInfo;
import com.luoo.user.pojo.UserPointLog; import constants.ErrorConstants;
import constants.TaskPointIdConstants; import constants.TaskPointIdConstants;
import dto.UserLoginDto; import dto.UserLoginDto;
import enums.MembershipEnums; import enums.MembershipEnums;
@ -128,7 +127,7 @@ public class MembershipCodeService {
MembershipCode membershipCode = membershipCodeDao.findMembershipCodeByCodeAndStatus(code, MembershipCode membershipCode = membershipCodeDao.findMembershipCodeByCodeAndStatus(code,
MembershipEnums.CREATED.getCode()); MembershipEnums.CREATED.getCode());
if (membershipCode == null) { if (membershipCode == null) {
throw new BizException("会员码不存在"); throw new BizException(ErrorConstants.MEMBERSHIP_CODE_NOT_EXISTS);
} }
// 处理会员码表 // 处理会员码表
membershipCode.setStatus(MembershipEnums.BIND.getCode()); membershipCode.setStatus(MembershipEnums.BIND.getCode());
@ -189,6 +188,28 @@ public class MembershipCodeService {
return membershipCodeDao.findAll(specification); 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<MembershipCode> buildSearchSpecification(MembershipCodeSearchDto param) { private Specification<MembershipCode> buildSearchSpecification(MembershipCodeSearchDto param) {
return (Root<MembershipCode> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> { return (Root<MembershipCode> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<Predicate>(); List<Predicate> predicateList = new ArrayList<Predicate>();
@ -219,6 +240,11 @@ public class MembershipCodeService {
criteriaBuilder.and(criteriaBuilder.equal(root.get("duration"), param.getDuration()))); 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()])); return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
}; };
} }

Loading…
Cancel
Save