|  | @@ -351,59 +351,6 @@ public class OrderRefundController {
 | 
	
		
			
				|  |  |              newOrderRefund.setDistributionTotalAmount(orderService.sumTotalDistributionAmountByOrderItem(orderItemList));
 | 
	
		
			
				|  |  |              // 计算平台退款金额(退款时将这部分钱退回给平台,所以商家要扣除从平台这里获取的金额)
 | 
	
		
			
				|  |  |              newOrderRefund.setPlatformRefundAmount(order.getPlatformAmount());
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            // 部分物品退款
 | 
	
		
			
				|  |  | -            OrderItem orderItem = orderItemService.getOne(new LambdaQueryWrapper<OrderItem>()
 | 
	
		
			
				|  |  | -                    .eq(OrderItem::getOrderItemId, orderRefundParam.getOrderItemId())
 | 
	
		
			
				|  |  | -                    .eq(OrderItem::getOrderNumber, orderRefundParam.getOrderNumber()));
 | 
	
		
			
				|  |  | -            if (orderItem == null) {
 | 
	
		
			
				|  |  | -                throw new GlobalException("该物品在订单中不存在");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            boolean isCanRefund = false;
 | 
	
		
			
				|  |  | -            //  查看是否有支付金额和积分都为空的订单,有则抛出异常
 | 
	
		
			
				|  |  | -            for (OrderItem item : orderItemList) {
 | 
	
		
			
				|  |  | -                if (item.getActualTotal() <= 0.0 && item.getUseScore() <= 0.0) {
 | 
	
		
			
				|  |  | -                    isCanRefund = true;
 | 
	
		
			
				|  |  | -                    break;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (isCanRefund) {
 | 
	
		
			
				|  |  | -                throw new GlobalException("该订单部分订单项支付金额和积分为0,无法使用部分退款!");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (order.getPlatformAmount() > 0 && !Arith.isEquals(orderRefundParam.getRefundAmount(), orderItem.getActualTotal())) {
 | 
	
		
			
				|  |  | -                throw new GlobalException("该订单有使用平台优惠,无法使用部分退款!");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            // 计算该订单项的分销金额
 | 
	
		
			
				|  |  | -            newOrderRefund.setDistributionTotalAmount(orderService.sumTotalDistributionAmountByOrderItem(Collections.singletonList(orderItem)));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 计算平台退款金额(退款时将这部分钱退回给平台,所以商家要扣除从平台这里获取的金额)
 | 
	
		
			
				|  |  | -            //此处设置实际平台抵现金额
 | 
	
		
			
				|  |  | -            newOrderRefund.setPlatformRefundAmount(orderItem.getPlatformShareReduce());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 退款物品数量为null或者0时,则为退款全部数量
 | 
	
		
			
				|  |  | -            if (orderRefundParam.getGoodsNum() <= 0) {
 | 
	
		
			
				|  |  | -                orderRefundParam.setGoodsNum(orderItem.getProdCount());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 判断退款数量是否溢出
 | 
	
		
			
				|  |  | -            if (orderRefundParam.getGoodsNum() > orderItem.getProdCount()) {
 | 
	
		
			
				|  |  | -                throw new GlobalException("退款物品数量已超出订单中的数量,不允许申请");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 判断退款金额是否超出订单金额
 | 
	
		
			
				|  |  | -            double refundSingleAmount = Arith.div(orderRefundParam.getRefundAmount(), orderRefundParam.getGoodsNum(), 3);
 | 
	
		
			
				|  |  | -            double singleAmount = Arith.div(orderItem.getActualTotal(), orderItem.getProdCount(), 3);
 | 
	
		
			
				|  |  | -            if (refundSingleAmount > orderItem.getProductTotalAmount() || refundSingleAmount > singleAmount) {
 | 
	
		
			
				|  |  | -                throw new GlobalException("退款金额已超出订单金额,无法申请");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 一个订单项只能申请一次退款
 | 
	
		
			
				|  |  | -//            for (OrderRefund orderRefund : orderRefunds) {
 | 
	
		
			
				|  |  | -//                if (Objects.equals(orderRefund.getOrderId(), orderItem.getOrderItemId())) {
 | 
	
		
			
				|  |  | -//                    throw new GlobalException("退款订单项已处理,请勿重复申请");
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          newOrderRefund.setShopId(order.getShopId());
 |