|  | @@ -840,10 +840,14 @@ DISCOUNT("畅学卡")
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 判断满减
 | 
	
		
			
				|  |  |          if (couponInfo.getUseLimit() != null && amount.compareTo(BigDecimal
 | 
	
		
			
				|  |  | -                .valueOf(couponInfo.getUseLimit()).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
 | 
	
		
			
				|  |  | +                .valueOf(couponInfo.getUseLimit()).setScale(2, BigDecimal.ROUND_HALF_UP)) < 0
 | 
	
		
			
				|  |  | +                && !couponAmountMap.isEmpty()) {
 | 
	
		
			
				|  |  |              throw new BizException("优惠券不可用");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // 总金额扣除优惠金额
 | 
	
		
			
				|  |  | +        amount = amount.subtract(BigDecimal.valueOf(couponInfo.getDiscountPrice()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 根据商品金额比例分摊优惠金额
 | 
	
		
			
				|  |  |          // 剩余金额
 | 
	
		
			
				|  |  |          BigDecimal remainAmount = BigDecimal.valueOf(couponInfo.getDiscountPrice());
 | 
	
	
		
			
				|  | @@ -851,18 +855,24 @@ DISCOUNT("畅学卡")
 | 
	
		
			
				|  |  |              UserPaymentOrderWrapper.OrderGoodsInfo goodsInfo = goodsInfos.get(entry.getKey());
 | 
	
		
			
				|  |  |              UserOrderDetail userOrderDetail = goodsInfo.getUserOrderDetail();
 | 
	
		
			
				|  |  |              BigDecimal actualPrice = entry.getValue();
 | 
	
		
			
				|  |  | -            BigDecimal couponAmount = BigDecimal.valueOf(couponInfo.getDiscountPrice())
 | 
	
		
			
				|  |  | -                    .multiply(userOrderDetail.getActualPrice()).divide(amount, 2, RoundingMode.HALF_DOWN);
 | 
	
		
			
				|  |  | +            BigDecimal couponAmount;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (amount.compareTo(BigDecimal.ZERO) >0) {
 | 
	
		
			
				|  |  | +                couponAmount = BigDecimal.valueOf(couponInfo.getDiscountPrice())
 | 
	
		
			
				|  |  | +                        .multiply(userOrderDetail.getActualPrice()).divide(amount, 2, RoundingMode.HALF_DOWN);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                couponAmount = userOrderDetail.getActualPrice();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              remainAmount = remainAmount.subtract(couponAmount);
 | 
	
		
			
				|  |  |              userOrderDetail.setCouponAmount(couponAmount.add(userOrderDetail.getCouponAmount()));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              userOrderDetail.setDiscountJson(userOrderService.discountJson(EDiscountType.COUPON,
 | 
	
		
			
				|  |  |                      couponAmount,userOrderDetail.getDiscountJson()));
 | 
	
		
			
				|  |  | -            userOrderDetail.setActualPrice(actualPrice.subtract(couponAmount).setScale(2, RoundingMode.HALF_UP));
 | 
	
		
			
				|  |  | +            userOrderDetail.setActualPrice(actualPrice.subtract(couponAmount));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (remainAmount.compareTo(BigDecimal.ZERO) > 0) {
 | 
	
		
			
				|  |  | -            UserOrderDetail userOrderDetail = goodsInfos.get(0).getUserOrderDetail();
 | 
	
		
			
				|  |  | -            userOrderDetail.setActualPrice(userOrderDetail.getActualPrice().add(remainAmount));
 | 
	
		
			
				|  |  | +        if (remainAmount.compareTo(BigDecimal.ZERO) > 0&& amount.compareTo(BigDecimal.ZERO) >0) {
 | 
	
		
			
				|  |  | +            UserOrderDetail userOrderDetail = goodsInfos.get(couponAmountMap.keySet().stream().findFirst().get()).getUserOrderDetail();
 | 
	
		
			
				|  |  | +            userOrderDetail.setActualPrice(userOrderDetail.getActualPrice().subtract(remainAmount));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              userOrderDetail.setDiscountJson(userOrderService.discountJson(EDiscountType.COUPON,
 | 
	
		
			
				|  |  |                      remainAmount,userOrderDetail.getDiscountJson()));
 |