Переглянути джерело

fix 根据过期时间去决定清理车票

zoujiajian 2 роки тому
батько
коміт
e2ff6518f1

+ 20 - 19
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderCommonServiceImpl.java

@@ -70,34 +70,35 @@ public class OrderCommonServiceImpl implements OrderCommonService {
 			if (relation != null) {
 				Boolean isFlag = true;
 				Date expiryTime = relation.getExpiryTime();
+				OrderDon otherOrder = null;
 				if (orderDon.getOrderType() == 2 || relationIds.size() > 1) {
 					//是否有其他付款订单是否过期
-					OrderDon otherOrder = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
+					otherOrder = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
 							.in(OrderDon::getRelationId, relationIds)
 							.eq(OrderDon::getUserId, orderDon.getUserId())
 							.ne(OrderDon::getId, orderDon.getId())
 							.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
 							.orderByDesc(OrderDon::getId)
 							.last("limit 1"));
-					if (otherOrder != null) {
-						Long otherSkuId = otherOrder.getSkuId();
-						GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
-						DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
-						if (now.isBefore(endTime)) {
-							isFlag = false;
+				}
+				if (otherOrder != null) {
+					Long otherSkuId = otherOrder.getSkuId();
+					GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
+					DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
+					if (now.isBefore(endTime)) {
+						isFlag = false;
+					}
+				} else {
+					//座位 过期时间
+					if (expiryTime != null) {
+						DateTime refundExpiryTime;
+						if (sku.getDays() != null && sku.getDays() > 0) {
+							refundExpiryTime = DateUtil.offsetDay(expiryTime, -sku.getDays() * num);
+						} else {
+							refundExpiryTime = DateUtil.offsetMonth(expiryTime, -sku.getMonths() * num);
 						}
-					} else {
-						//续费更换后的座位 过期时间
-						if (expiryTime != null) {
-							DateTime refundExpiryTime;
-							if (sku.getDays() != null && sku.getDays() > 0) {
-								refundExpiryTime = DateUtil.offsetDay(expiryTime, -sku.getDays() * num);
-							} else {
-								refundExpiryTime = DateUtil.offsetMonth(expiryTime, -sku.getMonths() * num);
-							}
-							if (now.isBefore(refundExpiryTime)) {
-								isFlag = false;
-							}
+						if (now.isBefore(refundExpiryTime)) {
+							isFlag = false;
 						}
 					}
 				}