diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index 269cb6c..3ae2bee 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -62,6 +62,7 @@ public class ErrorConstants { public static final String APPLY_END_TIME_CANNOT_BE_BEFORE_APPLY_START_TIME = "报名结束时间不能在报名开始时间之前"; public static final String POINT_NOT_ENOUGH = "积分不足"; public static final String ONLY_ONE_CITY = "只能填写一个城市"; + public static final String SHIPPING_ADDRESS_IS_REQUIRED = "请先填写收货地址再参与抽奖"; // 积分部分 public static final String DAILY_SIGN_ALREADY = "今日已签到"; diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index 467f0a2..b0629cc 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -1,6 +1,7 @@ package com.luoo.user.service; import api.PageResult; +import cn.hutool.core.util.ObjectUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.luoo.user.Scheduler.DrawLotteryScheduler; 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.pojo.*; import com.luoo.user.vo.point.*; +import com.luoo.user.vo.userinfo.UserinfoShippingAddressAppVO; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.Expressions; @@ -89,7 +91,9 @@ public class LotteryService { 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.jwtUtil = jwtUtil; this.idWorker = idWorker; @@ -102,6 +106,7 @@ public class LotteryService { this.drawLotteryScheduler = drawLotteryScheduler; this.jpaQueryFactory = jpaQueryFactory; this.envConfig = envConfig; + this.userinfoShippingAddressService = userinfoShippingAddressService; } @@ -374,6 +379,13 @@ public class LotteryService { lottery.getApplyEndTime().isBefore(LocalDateTime.now())) { throw new BizException(ErrorConstants.NOT_IN_THE_SIGN_UP_TIME); } + if (ObjectUtil.equals(PointEnums.LOTTERY_REAL.getCode(), lottery.getType())) { + // 实物抽奖报名必须要已填写抽奖地址 + List userinfoShippingAddressList = userinfoShippingAddressService.getUserinfoShippingAddressList(); + if (userinfoShippingAddressList.isEmpty()) { + throw new BizException(ErrorConstants.SHIPPING_ADDRESS_IS_REQUIRED); + } + } // 校验用户是否可参与 UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get();