From 69c7c004b42087a8a4ee6558d20c141f674ae12c Mon Sep 17 00:00:00 2001 From: huangyawei Date: Fri, 18 Oct 2024 19:34:10 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E5=AE=9E=E7=89=A9=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E8=A6=81=E5=85=88=E5=A1=AB=E5=86=99=E6=94=B6?= =?UTF-8?q?=E8=B4=A7=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/constants/ErrorConstants.java | 1 + .../java/com/luoo/user/service/LotteryService.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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();