zoujiajian 8 месяцев назад
Родитель
Сommit
3d21b509a4

+ 20 - 9
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -2478,7 +2478,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			}
 			GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
 			GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
-			OrderRefundDto orderRefundDto = getYoutubeRefundInfo(orderDon, sku);
+			OrderRefundDto orderRefundDto = getYoutubeRefundInfo(relationView, orderDon, sku);
 			BigDecimal refundBalance = orderRefundDto.getRefundBalance();
 			BigDecimal refundMoney = orderRefundDto.getRefundMoney();
 			//超过订单金额 让联系客服退款
@@ -2523,10 +2523,21 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 	}
 
-	private OrderRefundDto getYoutubeRefundInfo(OrderDon orderDon, GoodsDonSku sku) {
+	private OrderRefundDto getYoutubeRefundInfo(GroupsRelationView relationView, OrderDon orderDon, GoodsDonSku sku) {
 		OrderRefundDto orderRefundDto = new OrderRefundDto();
-		//该订单月份
-		int month = DateUtil.month(orderDon.getCreatedTime()) + 1;
+		Date expiryTime = relationView.getExpiryTime();
+		if (relationView.getIsFrozen()) {
+			expiryTime = DateUtil.offsetDay(DateTime.now(), relationView.getReservedDays());
+		}
+		if (expiryTime == null) {
+			if (sku.getDays() != null) {
+				expiryTime = DateUtil.offsetDay(DateTime.now(), sku.getDays());
+			} else {
+				expiryTime = DateUtil.offsetMonth(DateTime.now(), sku.getMonths());
+			}
+		}
+		//剩余几个月
+		Long remainMonths = DateUtil.betweenMonth(DateTime.now(), expiryTime, false) + 1;
 		BigDecimal refundBalance = BigDecimal.ZERO;
 		BigDecimal refundMoney = BigDecimal.ZERO;
 		//订单金额
@@ -2535,8 +2546,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		BigDecimal orderTotalMoney = money.add(balance);
 		//2年
 		if ((sku.getDays() != null && sku.getDays() == 730) || (sku.getMonths() != null && sku.getMonths() == 24)) {
-			//第二年未生效
-			if (orderDon.getCreatedTime().after(DateUtil.offsetMonth(DateTime.now(), -12))) {
+			if (remainMonths > 12) {
 				//兑换码订单
 				if (orderTotalMoney.compareTo(BigDecimal.ZERO) == 0) {
 					orderTotalMoney = sku.getPrice();
@@ -2550,12 +2560,13 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 						refundBalance = thisRefundMoney.subtract(money);
 					}
 				}
+				remainMonths = remainMonths - 12;
 			}
 		}
-		if (month >= 1 && month <= 6) {
+		if (remainMonths >= 1 && remainMonths <= 6) {
 			//1-6月买的 退100余额
 			refundBalance = refundBalance.add(BigDecimal.valueOf(10000));
-		} else if (month >= 7 && month <= 11) {
+		} else if (remainMonths >= 7 && remainMonths <= 11) {
 			//7-11月买的 退150余额
 			refundBalance = refundBalance.add(BigDecimal.valueOf(15000));
 		} else {
@@ -2599,7 +2610,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getUserId, userIdList).eq(OrderDon::getRelationId, relationId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).orderByDesc(OrderDon::getId).last("limit 1"));
 			if (orderDon != null) {
 				GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
-				OrderRefundDto orderRefundDto = getYoutubeRefundInfo(orderDon, sku);
+				OrderRefundDto orderRefundDto = getYoutubeRefundInfo(relationView, orderDon, sku);
 				return orderRefundDto;
 			}
 		}