zoujiajian 11 月之前
父節點
當前提交
644c872161
共有 1 個文件被更改,包括 32 次插入3 次删除
  1. 32 3
      netflix-service/src/main/java/com/cyksj/service/vip/impl/VipFrontServiceImpl.java

+ 32 - 3
netflix-service/src/main/java/com/cyksj/service/vip/impl/VipFrontServiceImpl.java

@@ -425,15 +425,29 @@ public class VipFrontServiceImpl implements VipFrontService {
 	/**
 	 * 获取普通剩余次数可抵扣金额
 	 */
-	private BigDecimal getGeneralRemainNumDeductMoney(Long relationId,Long goodsId,Long skuId,List<Long> userIdList) {
+	private BigDecimal getGeneralRemainNumDeductMoney(Long relationId, Long goodsId, Long skuId, List<Long> userIdList) {
 		BigDecimal deductMoney = BigDecimal.ZERO;
 		BigDecimal orderTotalMoney = BigDecimal.ZERO;
 		//总次数
 		Integer totalNum = 0;
+		DateTime now = DateTime.now();
 
 		List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getRelationId, relationId).in(OrderDon::getUserId, userIdList).notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
 		for (OrderDon orderDon : orderDonList) {
 			GoodsDonSku sku = skuMapper.selectById(skuId);
+			Date orderCreatedTime = orderDon.getCreatedTime();
+			Integer months = sku.getMonths();
+			Integer days = sku.getDays();
+			Date orderExpiryTime;
+			if (days != null) {
+				orderExpiryTime = DateUtil.offsetDay(orderCreatedTime, days);
+			} else {
+				orderExpiryTime = DateUtil.offsetMonth(orderCreatedTime, months);
+			}
+			//过期的订单不算入
+			if (orderExpiryTime.before(now)) {
+				continue;
+			}
 			if (orderDon.getMoney().compareTo(BigDecimal.ZERO) >= 0) {
 				orderTotalMoney = orderTotalMoney.add(orderDon.getMoney());
 			} else {
@@ -483,18 +497,33 @@ public class VipFrontServiceImpl implements VipFrontService {
 		//总次数
 		Integer fastTotalNum = 0;
 		Integer relaxTotalNum = 0;
+		DateTime now = DateTime.now();
 
 		List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getRelationId, relationId).in(OrderDon::getUserId, userIdList).notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
 		for (OrderDon orderDon : orderDonList) {
 			GoodsDonSku sku = skuMapper.selectById(skuId);
+			Date orderCreatedTime = orderDon.getCreatedTime();
+			Integer months = sku.getMonths();
+			Integer days = sku.getDays();
+			//订单过期时间
+			Date orderExpiryTime;
+			if (days != null) {
+				orderExpiryTime = DateUtil.offsetDay(orderCreatedTime, days);
+			} else {
+				orderExpiryTime = DateUtil.offsetMonth(orderCreatedTime, months);
+			}
+			//过期的订单不算入
+			if (orderExpiryTime.before(now)) {
+				continue;
+			}
 			if (orderDon.getMoney().compareTo(BigDecimal.ZERO) >= 0) {
 				orderTotalMoney = orderTotalMoney.add(orderDon.getMoney());
 			} else {
 				//兑换码订单使用规格价格
 				orderTotalMoney = orderTotalMoney.add(sku.getPrice());
 			}
-			fastTotalNum += sku.getMjFastNum();
-			relaxTotalNum += sku.getMjRelaxNum();
+			fastTotalNum += sku.getMjFastNum() * sku.getMonths();
+			relaxTotalNum += sku.getMjRelaxNum() * sku.getMonths();
 		}
 		Integer upgradeNum = 0;
 		BigDecimal upgradeOrderMoney = BigDecimal.ZERO;