|
|
@ -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()]));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|