release- 实物抽奖必须要先填写收货地址

release-2024-04-25
huangyawei 1 month ago
parent 70fe7a1d54
commit 69c7c004b4

@ -62,6 +62,7 @@ public class ErrorConstants {
public static final String APPLY_END_TIME_CANNOT_BE_BEFORE_APPLY_START_TIME = "报名结束时间不能在报名开始时间之前"; public static final String APPLY_END_TIME_CANNOT_BE_BEFORE_APPLY_START_TIME = "报名结束时间不能在报名开始时间之前";
public static final String POINT_NOT_ENOUGH = "积分不足"; public static final String POINT_NOT_ENOUGH = "积分不足";
public static final String ONLY_ONE_CITY = "只能填写一个城市"; public static final String ONLY_ONE_CITY = "只能填写一个城市";
public static final String SHIPPING_ADDRESS_IS_REQUIRED = "请先填写收货地址再参与抽奖";
// 积分部分 // 积分部分
public static final String DAILY_SIGN_ALREADY = "今日已签到"; public static final String DAILY_SIGN_ALREADY = "今日已签到";

@ -1,6 +1,7 @@
package com.luoo.user.service; package com.luoo.user.service;
import api.PageResult; import api.PageResult;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.Scheduler.DrawLotteryScheduler; import com.luoo.user.Scheduler.DrawLotteryScheduler;
import com.luoo.user.config.EnvConfig; import com.luoo.user.config.EnvConfig;
@ -13,6 +14,7 @@ import com.luoo.user.dto.point.LotteryParticipatedSearchDto;
import com.luoo.user.dto.point.LotterySearchDto; import com.luoo.user.dto.point.LotterySearchDto;
import com.luoo.user.pojo.*; import com.luoo.user.pojo.*;
import com.luoo.user.vo.point.*; import com.luoo.user.vo.point.*;
import com.luoo.user.vo.userinfo.UserinfoShippingAddressAppVO;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.Expressions;
@ -89,7 +91,9 @@ public class LotteryService {
private final EnvConfig envConfig; private final EnvConfig envConfig;
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig) { private final UserinfoShippingAddressService userinfoShippingAddressService;
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService) {
this.lotteryDao = lotteryDao; this.lotteryDao = lotteryDao;
this.jwtUtil = jwtUtil; this.jwtUtil = jwtUtil;
this.idWorker = idWorker; this.idWorker = idWorker;
@ -102,6 +106,7 @@ public class LotteryService {
this.drawLotteryScheduler = drawLotteryScheduler; this.drawLotteryScheduler = drawLotteryScheduler;
this.jpaQueryFactory = jpaQueryFactory; this.jpaQueryFactory = jpaQueryFactory;
this.envConfig = envConfig; this.envConfig = envConfig;
this.userinfoShippingAddressService = userinfoShippingAddressService;
} }
@ -374,6 +379,13 @@ public class LotteryService {
lottery.getApplyEndTime().isBefore(LocalDateTime.now())) { lottery.getApplyEndTime().isBefore(LocalDateTime.now())) {
throw new BizException(ErrorConstants.NOT_IN_THE_SIGN_UP_TIME); throw new BizException(ErrorConstants.NOT_IN_THE_SIGN_UP_TIME);
} }
if (ObjectUtil.equals(PointEnums.LOTTERY_REAL.getCode(), lottery.getType())) {
// 实物抽奖报名必须要已填写抽奖地址
List<UserinfoShippingAddressAppVO> userinfoShippingAddressList = userinfoShippingAddressService.getUserinfoShippingAddressList();
if (userinfoShippingAddressList.isEmpty()) {
throw new BizException(ErrorConstants.SHIPPING_ADDRESS_IS_REQUIRED);
}
}
// 校验用户是否可参与 // 校验用户是否可参与
UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get(); UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get();

Loading…
Cancel
Save