fhx
2024-08-02 877df89dc54fcded5ffe6f8a440445b6f66ff58f
1.完善退款可退其他支付方式逻辑
2个文件已修改
44 ■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/refund/OrderRefundController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/refund/OrderRefundController.java
@@ -19,6 +19,7 @@
import com.hx.phip.tool.payment.ConsumeTool;
import com.hx.resultTool.Result;
import com.hx.util.StringUtils;
import com.hz.his.dto.order.OrderPayMethodDto;
import com.hz.his.dto.order.OrderRefundDto;
import com.hz.his.dto.refund.RefundPreferentialDto;
import com.hz.his.vo.order.refund.RefundCancelVo;
@@ -156,6 +157,9 @@
        OrderRefundDto returnMap = orderRefundService.nextStep(ordersTotal,orderRefundDto);
        returnMap.setRefundPayMethod(returnMap.getPayMethodList());
        returnMap.setCouponList(returnMap.getPayCouponList());
        //处理其他现金退款支付方式列表
        handleOtherCashRefundMethodList(returnMap.getRefundPayMethod());
        return Result.success(returnMap);
    }
@@ -432,11 +436,11 @@
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /** 获取其他现金退款支付方式列表 */
    private List<Map<String, Object>> getOtherCashRefundMethodList(){
    /** 处理其他现金退款支付方式列表 */
    private void handleOtherCashRefundMethodList(List<OrderPayMethodDto> refundPayMethodList){
        SystemParameter sp = systemParameterService.selectOneByName(SystemParameter.KEY_REFUND_CONFIG);
        if(sp == null || StringUtils.isEmpty(sp.getParamValue())){
            return null;
            return;
        }
        //转换vo
@@ -444,12 +448,11 @@
        if(refundConfig == null || refundConfig.getIsEnableSocrm() == null
                || refundConfig.getIsEnableSocrm() != BaseEntity.YES
                || StringUtils.isEmpty(refundConfig.getOtherCashRefundMethodNos())){
            return null;
            return;
        }
        String [] noArr = refundConfig.getOtherCashRefundMethodNos().split(",");
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> dataMap;
        List<OrderPayMethodDto> otherRefundMethodList = new ArrayList<>();
        //遍历查询对应支付编号的支付方式
        for(String numberNo : noArr){
            PaymentMethod paymentMethod = paymentMethodService.selectNumberNo(numberNo);
@@ -459,12 +462,20 @@
            }
            //支付方式是现金和执行金额
            if(paymentMethod.getIsMoneyPay() == BaseEntity.YES && paymentMethod.getIsExecute() == BaseEntity.YES){
                dataMap = new HashMap<>();
                dataMap.put("payMethodNo", paymentMethod.getNumberNo());
                dataMap.put("payMethodName", paymentMethod.getName());
                list.add(dataMap);
                OrderPayMethodDto orderPayMethodDto = new OrderPayMethodDto();
                orderPayMethodDto.setPayMethodNo(paymentMethod.getNumberNo());
                orderPayMethodDto.setPayMethodName(paymentMethod.getName());
                orderPayMethodDto.setIsMoneyPay(paymentMethod.getIsMoneyPay());
                orderPayMethodDto.setIsExecute(paymentMethod.getIsExecute());
                otherRefundMethodList.add(orderPayMethodDto);
            }
        }
        return list;
        //再遍历原支付方式,是现金和执行金额才赋值其他配置的支付方式退款
        for(OrderPayMethodDto payMethodDto : refundPayMethodList){
            if(payMethodDto.getIsMoneyPay() == BaseEntity.YES && payMethodDto.getIsExecute() == BaseEntity.YES){
                payMethodDto.setOtherRefundMethodList(otherRefundMethodList);
            }
        }
    }
}
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
@@ -83,6 +83,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -945,6 +946,16 @@
                if (orderPayMethodDto.getMoney().compareTo(payMethodDto.getPayTotal()) > 0){
                    throw new TipsException("当前退款方式["+orderPayMethodDto.getPayMethodName()+"]金额超出可退金额!");
                }
                //判断如果原支付方式是:现在和执行金额时
                if(payMethodDto.getIsMoneyPay() == BaseEntity.YES && payMethodDto.getIsExecute() ==BaseEntity.YES){
                    //退款方式非储值金时,则判断退款方式是否也是:现在和执行金额
                    if(!PayMethodTypeConstants.PAY_STORED.equals(refundMethod.getNumberNo())){
                        if(refundMethod.getIsMoneyPay() != BaseEntity.YES || refundMethod.getIsExecute() != BaseEntity.YES){
                            throw new TipsException(MessageFormat.format("原支付方式[{0}]是现金和执行金额类型,退款方式[{1}]非现金和执行金额类型!", payMethodDto.getPayMethodName(), refundMethod.getName()));
                        }
                    }
                }
            }
            //退款金额是0元,去掉退款方式