zoujiajian 1 year ago
parent
commit
45feec1907

+ 20 - 2
netflix-dao/src/main/java/com/cyksj/model/entity/VipOrderDon.java

@@ -50,9 +50,29 @@ public class VipOrderDon extends BaseEntity{
 	 */
 	private String openId;
 
+	/**
+	 * 续费月数
+	 */
+	private Integer num;
+
 	/** 金额 */
 	private BigDecimal money;
 
+	/**
+	 * 抵扣金额
+	 */
+	private BigDecimal deductMoney;
+
+	/**
+	 * 实际可抵扣金额(超过)
+	 */
+	private BigDecimal actuallyDeductMoney;
+
+	/**
+	 * 超出抵扣会员可延长多少天
+	 */
+	private Integer extendsDays;
+
 	/**
 	 * 海外支付金额
 	 */
@@ -102,8 +122,6 @@ public class VipOrderDon extends BaseEntity{
 	 */
 	private Boolean isFixedDistribute;
 
-	private Integer num;
-
 	/**
 	 * 支付时间
 	 */

+ 15 - 2
netflix-dao/src/main/java/com/cyksj/model/request/OrderRefundReq.java

@@ -32,7 +32,7 @@ public class OrderRefundReq {
 
 	/**
 	 * 退款类型
-	 * 订单金额、余额
+	 * 订单金额、余额、金额和余额混合bxj
 	 */
 	private String refundType;
 
@@ -69,4 +69,17 @@ public class OrderRefundReq {
 	 * 加购订单退款车票ids
 	 */
 	private List<Long> dpRelationIds;
-}
+
+	@Getter
+	public enum RefundType {
+		balance("余额退款"),
+		money("现金退款"),
+		bxj("余额现金"),
+		;
+		String desc;
+
+		RefundType(String desc) {
+			this.desc = desc;
+		}
+	}
+}

+ 31 - 9
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -602,6 +602,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             }
         });
     }
+
     /**
      * 校验订单是否符合退款操作
      */
@@ -624,18 +625,29 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
 
         BigDecimal refundMoney = refundReq.getRefundMoney();
         BigDecimal money = orderDon.getMoney();
+        BigDecimal balance = orderDon.getBalance();
+        BigDecimal refundBalance = refundReq.getRefundBalance();
         //余额退款
         if (UpgradeOrderDon.Type.BALANCE.getType().equals(refundType)) {
-            BigDecimal balance = orderDon.getBalance();
             refundMoney = orderDonRefundBalance.add(refundMoney);
-            if (UpgradeOrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
-                throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
-            }
             if (UpgradeOrderDon.Type.BALANCE != orderDon.getType() && refundMoney.compareTo(money) > 0) {
                 throw BusinessRuntimeException.getInstance("退款余额大于订单支付金额");
             }
             orderDon.setRefundBalance(refundMoney);
             orderDon.setRefundMoney(BigDecimal.ZERO);
+        } else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
+            balance = balance.add(money);
+            if (refundBalance.compareTo(balance) > 0) {
+                throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
+            }
+            refundBalance = refundBalance.add(orderDonRefundBalance);
+            orderDon.setRefundBalance(refundBalance);
+
+            refundMoney = orderDonRefundMoney.add(refundMoney);
+            if (refundMoney.compareTo(money) > 0) {
+                throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
+            }
+            orderDon.setRefundMoney(refundMoney);
         } else {
             //退金额
             refundMoney = orderDonRefundMoney.add(refundMoney);
@@ -992,19 +1004,29 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             }
         }
         BigDecimal refundMoney = refundReq.getRefundMoney();
+        BigDecimal refundBalance = refundReq.getRefundBalance();
         BigDecimal money = orderDon.getMoney();
+        BigDecimal balance = orderDon.getBalance();
         //余额退款
         if (OrderDon.Type.BALANCE.getType().equals(refundType)) {
-            BigDecimal balance = orderDon.getBalance();
             refundMoney = orderDonRefundBalance.add(refundMoney);
-            if (OrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
-                throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
-            }
             if (OrderDon.Type.BALANCE != orderDon.getType() && refundMoney.compareTo(money) > 0) {
                 throw BusinessRuntimeException.getInstance("退款余额大于订单支付金额");
             }
             orderDon.setRefundBalance(refundMoney);
-            orderDon.setRefundMoney(BigDecimal.ZERO);
+        } else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
+            balance = balance.add(money);
+            if (refundBalance.compareTo(balance) > 0) {
+                throw BusinessRuntimeException.getInstance("退款余额大于订单总金额");
+            }
+            refundBalance = refundBalance.add(orderDonRefundBalance);
+            orderDon.setRefundBalance(refundBalance);
+
+            refundMoney = orderDonRefundMoney.add(refundMoney);
+            if (refundMoney.compareTo(money) > 0) {
+                throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
+            }
+            orderDon.setRefundMoney(refundMoney);
         } else {
             //退金额
             refundMoney = orderDonRefundMoney.add(refundMoney);

+ 20 - 7
netflix-service/src/main/java/com/cyksj/service/mange/vip/impl/CmsVipOrderServiceImpl.java

@@ -231,9 +231,10 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
 			throw BusinessRuntimeException.getInstance("订单状态异常");
 		}
 		Long userId = orderDon.getUserId();
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		//会员是否已过期
 		VipUser vipUser = vipUserMapper.selectOne(Wrappers.lambdaQuery(VipUser.class)
-				.eq(VipUser::getUserId, userId)
+				.in(VipUser::getUserId, userIdList)
 				.gt(VipUser::getExpiryTime, DateTime.now())
 				.last("limit 1"));
 		if (vipUser == null) {
@@ -241,22 +242,34 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
 		}
 		String refundType = refundReq.getRefundType();
 		BigDecimal refundMoney = refundReq.getRefundMoney();
+		BigDecimal refundBalance = refundReq.getRefundBalance();
 		BigDecimal money = orderDon.getMoney();
+		BigDecimal balance = orderDon.getBalance();
 		BigDecimal orderDonRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
 		BigDecimal orderDonRefundBalance = Optional.ofNullable(orderDon.getRefundBalance()).orElse(BigDecimal.ZERO);
 		//余额退款
 		if (OrderDon.Type.BALANCE.getType().equals(refundType)) {
-			BigDecimal balance = orderDon.getBalance();
 			refundMoney = orderDonRefundBalance.add(refundMoney);
-			if (VipOrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
-				throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
-			}
 			if (VipOrderDon.Type.BALANCE != orderDon.getType() && refundMoney.compareTo(money) > 0) {
 				throw BusinessRuntimeException.getInstance("退款余额大于订单支付金额");
 			}
 			orderDon.setRefundBalance(refundMoney);
-			orderDon.setRefundMoney(BigDecimal.ZERO);
-		} else {
+		} else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
+			//该订单实际可抵扣金额 可退成余额
+			BigDecimal actuallyDeductMoney = Optional.ofNullable(orderDon.getActuallyDeductMoney()).orElse(BigDecimal.ZERO);
+			balance = balance.add(actuallyDeductMoney).add(money);
+			refundBalance = refundBalance.add(orderDonRefundBalance);
+			if (refundBalance.compareTo(balance) > 0) {
+				throw BusinessRuntimeException.getInstance("退款余额大于订单总金额");
+			}
+			orderDon.setRefundBalance(refundBalance);
+
+			refundMoney = orderDonRefundMoney.add(refundMoney);
+			if (refundMoney.compareTo(money) > 0) {
+				throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
+			}
+			orderDon.setRefundMoney(refundMoney);
+		}else {
 			//退金额
 			refundMoney = orderDonRefundMoney.add(refundMoney);
 			if (refundMoney.compareTo(money) > 0) {