| | |
| | | DistributionRedundVo distributionRedundVo; |
| | | OrderItem orderItem; |
| | | |
| | | //子单的支付方式 |
| | | List<OrderPayMethodDto> refundPayMethodItemList; |
| | | OrderPayMethodDto refundPayMethodItem; |
| | | |
| | | //计算每个条目需要退多少钱 |
| | | for (OrderItemRefundDto orderItemRefundDto : refundList) { |
| | | if(StringUtils.isEmpty(orderItemRefundDto.getOrderItemId())){ |
| | |
| | | if(!orderItem.getOrderId().equals(ordersTotal.getId())){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到退款项[012]"); |
| | | } |
| | | refundPayMethodItemList = new ArrayList<>(); |
| | | |
| | | //判断这个项目能不能显示处理 |
| | | switch (orderItem.getType()) { |
| | |
| | | orderPayMethodDto = orderPayMethodDtoMap.computeIfAbsent(refundPaymentMethodVo.getNumberNo(), |
| | | k->new OrderPayMethodDto(refundPaymentMethodVo.getNumberNo(),refundPaymentMethodVo.getName(),BigDecimal.ZERO,refundPaymentMethodVo.getIsMoneyPay(),refundPaymentMethodVo.getIsExecute())); |
| | | orderPayMethodDto.setPayTotal(orderPayMethodDto.getPayTotal().add(refundPaymentMethodVo.getRefundTotal()).setScale(2,RoundingMode.HALF_UP)); |
| | | |
| | | //子单的支付方式 |
| | | refundPayMethodItem = new OrderPayMethodDto(refundPaymentMethodVo.getNumberNo(),refundPaymentMethodVo.getName(),refundPaymentMethodVo.getRefundTotal(),refundPaymentMethodVo.getIsMoneyPay(),refundPaymentMethodVo.getIsExecute()); |
| | | refundPayMethodItemList.add(refundPayMethodItem); |
| | | } |
| | | orderItemRefundDto.setRefundPayMethodList(refundPayMethodItemList); |
| | | } |
| | | |
| | | for(Map.Entry<String, OrderPayMethodDto> entry : orderPayMethodDtoMap.entrySet()) { |
| | |
| | | Map<String,DistributionRedundMethodVo> refundPaymentMethodVoMap = new HashMap<>(); |
| | | DistributionRedundMethodVo refundPaymentMethodVo; |
| | | |
| | | //子单的支付方式 |
| | | List<OrderPayMethodDto> refundPayMethodItemList; |
| | | OrderPayMethodDto refundPayMethodItem; |
| | | |
| | | DistributionRedundVo distributionRedundVoSon; |
| | | for (OrderItemSourceRefundDto orderItemSourceRefundDto : orderItemSourceRefundDtos) { |
| | | if(StringUtils.isEmpty(orderItemSourceRefundDto.getOrderItemSonId())){ |
| | |
| | | if (!orderItemSon.getOrderItemId().equals(orderItem.getId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到退款项[54]"); |
| | | } |
| | | |
| | | refundPayMethodItemList = new ArrayList<>(); |
| | | |
| | | switch (orderItemSon.getType()) { |
| | | case OrderGoodsConstants.TYPE_PROJECT: |
| | |
| | | refundPaymentMethodVo = refundPaymentMethodVoMap.computeIfAbsent(paymentMethodVo.getNumberNo() |
| | | ,k-> new DistributionRedundMethodVo(paymentMethodVo.getNumberNo(),paymentMethodVo.getName(),BigDecimal.ZERO,paymentMethodVo.getIsMoneyPay(),paymentMethodVo.getIsExecute())); |
| | | refundPaymentMethodVo.setRefundTotal(refundPaymentMethodVo.getRefundTotal().add(paymentMethodVo.getRefundTotal()).setScale(2,RoundingMode.HALF_UP)); |
| | | } |
| | | |
| | | //子单的支付方式 |
| | | refundPayMethodItem = new OrderPayMethodDto(paymentMethodVo.getNumberNo(),paymentMethodVo.getName(),paymentMethodVo.getRefundTotal(),paymentMethodVo.getIsMoneyPay(),paymentMethodVo.getIsExecute()); |
| | | refundPayMethodItemList.add(refundPayMethodItem); |
| | | } |
| | | orderItemSourceRefundDto.setRefundPayMethodList(refundPayMethodItemList); |
| | | } |
| | | |
| | | //返回结构数据填充 |
| | |
| | | throw new TipsException("退款积分分配错误[01]!"); |
| | | } |
| | | |
| | | //客户退款的支付方式,后面的校验会用到的 |
| | | Set<String> payMonthNoSet = new HashSet<>(); |
| | | for(OrderPayMethodDto orderPayMethodDto:orderRefundDto.getPayMethodList()){ |
| | | if(orderPayMethodDto.getMoney().compareTo(BigDecimal.ZERO) < 1){ |
| | | continue; |
| | | } |
| | | //积分的也跳出 |
| | | if(PayMethodTypeConstants.PAY_INTEGRAL.equals(orderPayMethodDto.getPayMethodNo())){ |
| | | continue; |
| | | } |
| | | payMonthNoSet.add(orderPayMethodDto.getPayMethodNo()); |
| | | } |
| | | |
| | | //-----退款金额处理 |
| | | //计算金额占比,客户选择退款总金额和可退总金额占比 |
| | | if(orderRefundDto.getTotalAmount().compareTo(BigDecimal.ZERO) < 1){ |
| | |
| | | /////引用参数 |
| | | RefundRecordItem refundRecordItem; |
| | | OrderItem orderItem; |
| | | BigDecimal payMonthTotal; |
| | | for(int i = 0;i < refundList.size();i++){ |
| | | orderItemRefundDto = refundList.get(i); |
| | | |
| | |
| | | if(refundRecordItem.getRefundMoney().compareTo(refundTotal) > 0){ |
| | | refundRecordItem.setRefundMoney(refundTotal); |
| | | } |
| | | //重点,这里还是要校验一下和支付总额是否对得上 |
| | | payMonthTotal = BigDecimal.ZERO; |
| | | for(OrderPayMethodDto orderPayMethodDto:orderItemRefundDto.getRefundPayMethodList()){ |
| | | if(payMonthNoSet.contains(orderPayMethodDto.getPayMethodNo())){ |
| | | payMonthTotal = payMonthTotal.add(orderPayMethodDto.getPayTotal()); |
| | | } |
| | | } |
| | | if(refundRecordItem.getRefundMoney().compareTo(payMonthTotal) > 0){ |
| | | refundRecordItem.setRefundMoney(payMonthTotal); |
| | | } |
| | | |
| | | refundRecordItem.setRealRefundNum(refundRecordItem.getRefundNum()); |
| | | refundRecordItem.setRealRefundTotal(refundRecordItem.getRefundMoney()); |
| | |
| | | |
| | | if(PartialRefundUtil.CONTAIN_SON_TYPE_SET.contains(orderItem.getType())){ |
| | | //子单子项处理 |
| | | insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos()); |
| | | insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos(),payMonthNoSet); |
| | | } |
| | | //虚拟商品退款时需校验一下,对应关联的优惠券码有没有被使用或 |
| | | if(OrderItemConstants.TYPE_COUPON.equals(orderItem.getType())){ |
| | |
| | | } |
| | | |
| | | /**二级子单处理*/ |
| | | public void insertRefundRecordItemTwo(RefundRecordItem recordItem,RefundRecord refundRecord,List<OrderItemSourceRefundDto> orderItemSourceRefundDtos){ |
| | | public void insertRefundRecordItemTwo(RefundRecordItem recordItem,RefundRecord refundRecord,List<OrderItemSourceRefundDto> orderItemSourceRefundDtos,Set<String> payMonthNoSet){ |
| | | if(orderItemSourceRefundDtos == null || orderItemSourceRefundDtos.size() == 0){ |
| | | return; |
| | | } |
| | |
| | | BigDecimal refundTotal = recordItem.getRefundMoney(); |
| | | OrderItemSon orderItemSon; |
| | | RefundRecordItemSource refundRecordItemSource; |
| | | BigDecimal payMonthTotal; |
| | | for(int i = 0;i<orderItemSourceRefundDtos.size();i++){ |
| | | orderItemSourceRefundDto = orderItemSourceRefundDtos.get(i); |
| | | |
| | |
| | | if(refundRecordItemSource.getRefundMoney().compareTo(refundTotal) > 0){ |
| | | refundRecordItemSource.setRefundMoney(refundTotal); |
| | | } |
| | | //重点,这里还是要校验一下和支付总额是否对得上 |
| | | payMonthTotal = BigDecimal.ZERO; |
| | | for(OrderPayMethodDto orderPayMethodDto:orderItemSourceRefundDto.getRefundPayMethodList()){ |
| | | if(payMonthNoSet.contains(orderPayMethodDto.getPayMethodNo())){ |
| | | payMonthTotal = payMonthTotal.add(orderPayMethodDto.getPayTotal()); |
| | | } |
| | | } |
| | | if(refundRecordItemSource.getRefundMoney().compareTo(payMonthTotal) > 0){ |
| | | refundRecordItemSource.setRefundMoney(payMonthTotal); |
| | | } |
| | | |
| | | refundRecordItemSource.setRealRefundNum(refundRecordItemSource.getRefundNum()); |
| | | refundRecordItemSource.setRealRefundTotal(refundRecordItemSource.getRefundMoney()); |