Просмотр исходного кода

Merge branch 'ticket_notify' into pre

zoujiajian 2 лет назад
Родитель
Сommit
8c31ad7b88

+ 18 - 15
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1678,21 +1678,24 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				couponUser.setCouponId(exists.getPopularizeCouponId());
 				couponUser.setPopularizeId(exists.getPopularizeId());
 			}
-			//非渠道推广 推广优惠码只可使用一次
-			if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
-				CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
-				if (received != null && received.getStatus() != CouponUser.Status.unused) {
-					throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");
-				}
-				couponUser.setUserId(userId);
-				couponUser.setStatus(CouponUser.Status.used);
-				couponUser.setChannel(CouponUser.Channel.exCode);
-				couponFontService.updateCouponUserValidTime(couponUser.getCouponId(), couponUser);
-				try {
-					couponUserMapper.insert(couponUser);
-				} catch (DuplicateKeyException e) {
-					log.info("用户已领取该{}优惠券", couponUser.getCouponId());
-					throw BusinessRuntimeException.getInstance("您已领取该优惠码对应的优惠券,请使用优惠券");
+			//续费优惠码可重复使用
+			if (exists.getUseScope() != Coupon.UseScope.renew) {
+				//非渠道推广 推广优惠码只可使用一次
+				if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
+					CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
+					if (received != null && received.getStatus() != CouponUser.Status.unused) {
+						throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");
+					}
+					couponUser.setUserId(userId);
+					couponUser.setStatus(CouponUser.Status.used);
+					couponUser.setChannel(CouponUser.Channel.exCode);
+					couponFontService.updateCouponUserValidTime(couponUser.getCouponId(), couponUser);
+					try {
+						couponUserMapper.insert(couponUser);
+					} catch (DuplicateKeyException e) {
+						log.info("用户已领取该{}优惠券", couponUser.getCouponId());
+						throw BusinessRuntimeException.getInstance("您已领取该优惠码对应的优惠券,请使用优惠券");
+					}
 				}
 			}
 		} else {

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -633,6 +633,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 				.field("condition", String.format("(gr.expiry_time is null or gr.expiry_time > '%s')", now))
 				.field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
 				.orderBy(RenewalView::getExpiryTime).asc()
+				.onlySelect(RenewalView::getRelationId, RenewalView::getAccount, RenewalView::getGoodsId, RenewalView::getTitle, RenewalView::getLogo, RenewalView::getImg, RenewalView::getGroupId, RenewalView::getSkuId, RenewalView::getSpecVal)
 				.build());
 		if (list.getDataList().size() > 5) {
 			redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
@@ -641,6 +642,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		//提前7天
 		AtomicInteger day = new AtomicInteger(7);
 		List<RenewalView> expiryTickets = list.getDataList().stream().filter(ticket -> {
+			//下架
+			if (!ticket.getGoodsStatus() || !ticket.getSkuStatus()) {
+				return false;
+			}
 			Long skuNum = ticket.getSkuNum();
 			Date expiryTime = ticket.getExpiryTime();
 			//年付 提前一个月