|
|
@ -1,16 +1,30 @@
|
|
|
|
package com.luoo.user.service;
|
|
|
|
package com.luoo.user.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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 dto.UserLoginDto;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import enums.MembershipEnums;
|
|
|
|
import enums.MembershipEnums;
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
import exception.BizException;
|
|
|
|
import exception.BizException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.IdWorker;
|
|
|
@ -128,4 +142,51 @@ public class MembershipCodeService {
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageResult<MembershipCode> getMembershipCodeList(String token, Integer page, Integer size,
|
|
|
|
|
|
|
|
MembershipCodeSearchDto membershipCodeSearchDto) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sort sort = new Sort(Direction.DESC, "createTime");
|
|
|
|
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specification<MembershipCode> specification = buildSearchSpecification(membershipCodeSearchDto);
|
|
|
|
|
|
|
|
Page<MembershipCode> membershipCodePage = membershipCodeDao.findAll(specification, pageRequest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long totalElements = membershipCodePage.getTotalElements();
|
|
|
|
|
|
|
|
return new PageResult<>(totalElements, membershipCodePage.getContent());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Specification<MembershipCode> buildSearchSpecification(MembershipCodeSearchDto param) {
|
|
|
|
|
|
|
|
return (Root<MembershipCode> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> {
|
|
|
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getCode())) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.and(criteriaBuilder.equal(root.get("code"), param.getCode())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getCreateUser())) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.and(
|
|
|
|
|
|
|
|
criteriaBuilder.equal(root.get("createUser"), param.getCreateUser())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getUserId())) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.and(criteriaBuilder.equal(root.get("userId"), param.getUserId())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getStatus() != null) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.and(criteriaBuilder.equal(root.get("status"), param.getStatus())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getDuration() != null) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.and(criteriaBuilder.equal(root.get("duration"), param.getDuration())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|