chenjiahe
2023-04-01 510678fe2f81501914ea4905fb7026b9c7be414f
退款重构
6个文件已修改
159 ■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java
@@ -7,10 +7,10 @@
import java.util.List;
public interface RefundMapper {
    /**总支付方式记录返回*/
    /**总支付方式记录返回-支付编号求和*/
    List<PayMethodVo> selectConsumePayList(@Param("orderId") String orderId);
    /**一级支付方式记录返回*/
    /**一级支付方式记录返回-支付编号求和*/
    List<PayMethodVo> selectConsumePayOneList(@Param("typeId") String typeId);
    /**二级支付方式记录返回*/
    /**二级支付方式记录返回-支付编号求和*/
    List<PayMethodVo> selectConsumePayTwoList(@Param("typeId") String typeId);
}
phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java
@@ -13,7 +13,7 @@
@Data
public class RefundCarryVo {
    /**退款的退款方式金额-该参数一开始就携带*/
    /**退款的退款方式金额-该参数一开始就携带,全局使用*/
    private List<RefundRecordMethod> refundRecordMethodList;
    //***************内部携带作用参数,全程变化,注意使用********************
phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml
@@ -5,7 +5,7 @@
<!-- namespace:该mapper.xml映射文件的 唯一标识 -->
<mapper namespace="com.hx.phip.dao.mapper.RefundMapper">
    <!--一级支付方式记录返回-->
    <!--一级支付方式记录返回-支付编号求和-->
    <select id="selectConsumePayList" resultType="com.hx.phip.vo.order.payment.PayMethodVo">
        SELECT ANY_VALUE(name) AS name
             ,numberNo
@@ -17,7 +17,7 @@
    </select>
    <!--一级支付方式记录返回-->
    <!--一级支付方式记录返回-支付编号求和-->
    <select id="selectConsumePayOneList" resultType="com.hx.phip.vo.order.payment.PayMethodVo">
        SELECT ANY_VALUE(name) AS name
             ,numberNo
@@ -27,7 +27,7 @@
        WHERE isDel = 0 AND typeId = #{typeId} GROUP BY numberNo
    </select>
    <!--二级支付方式记录返回-->
    <!--二级支付方式记录返回-支付编号求和-->
    <select id="selectConsumePayTwoList" resultType="com.hx.phip.vo.order.payment.PayMethodVo" >
        SELECT ANY_VALUE(name) AS name
             ,numberNo
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
@@ -873,22 +873,27 @@
    /**保存退款信息
     * 保存退款信息,并没有真正退款
     */
    public RefundRecord insertRefundInfo(OrderRefundDto orderRefundDto,OrdersTotal ordersTotal,StringBuilder orderNodeBuilder
            , ThirtApplication thirtApplication){
    public RefundRecord insertRefundInfo(OrderRefundDto orderRefundDto,OrdersTotal ordersTotal
            ,StringBuilder orderNodeBuilder, ThirtApplication thirtApplication){
        //操作人
        Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId());
        if(employee == null){
            throw new TipsException("操作人标识错误!");
        }
        ///////退款总表数据填充
        //生成退款编号
        String totalCode = createNoService.createNo("R",System.currentTimeMillis()+"",8);
        RefundRecord refundRecord=new RefundRecord(totalCode,ordersTotal.getShopId(),ordersTotal.getShopName(),orderRefundDto.getRefundTotal()
                , RefundStatus.STATUS_APPLY_REFUND,0, RefundSoruceConstants.TYPE_SOURCE_ORDER,orderRefundDto.getRemarks(),ordersTotal.getId(),ordersTotal.getUserId());
        //操作人信息
        refundRecord.setOperatorType(RefundRecord.OPERATOR_TYPE_EMPLOYEE);
        Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId());
        if(employee == null){
            throw new TipsException("操作人标识错误!");
        }
        refundRecord.setOperatorId(employee.getId());
        refundRecord.setRefundOperationType(orderRefundDto.getRefundOperationType());
        refundRecord.setOperatorNo(employee.getEmployeeNo());
        refundRecord.setOperatorName(employee.getCnName());
        refundRecord.setRefundOperationType(orderRefundDto.getRefundOperationType());
        /////退款的备注
        refundRecord.setRemarks(orderRefundDto.getRemarks());
        refundRecord.setRefundReason(orderRefundDto.getRefundReason());
@@ -898,14 +903,13 @@
        refundRecordService.insert(refundRecord);
        //退款方式处理
        List<RefundRecordMethod> refundRecordMethodList = null;
        if(orderRefundDto.getRefundPayMethod() !=null && orderRefundDto.getRefundPayMethod().size() > 0){
            refundRecordMethodList = handleRefundPayMethod(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord);
            handleRefundPayMethod(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord);
        }
        //退款的子项处理
        if(orderRefundDto.getRefundList()!=null && orderRefundDto.getRefundList().size()>0){
            insertRefundRecordItem(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord,refundRecordMethodList);
            insertRefundRecordItem(orderRefundDto,orderNodeBuilder,refundRecord);
        }
        //回退的优惠卷处理
        if(orderRefundDto.getCouponList() != null && orderRefundDto.getCouponList().size()>0){
@@ -1117,23 +1121,22 @@
    public List<RefundRecordMethod> handleRefundPayMethod(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord){
        orderNodeBuilder.append("-记录退款方式:");
        //获取订单可退款方式
        //获取订单可退款方式,就是支付方式总表的信息,已经支付编号求和
        List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayList(ordersTotal.getId());
        Map<String, PayMethodVo> payMethodVoMap = payMethodVoList.stream().collect(
                Collectors.toMap(PayMethodVo::getNumberNo,(a) -> a));
        //用map装载,后面根据支付编号直接获取便可
        Map<String, PayMethodVo> payMethodVoMap = payMethodVoList.stream().collect(Collectors.toMap(PayMethodVo::getNumberNo,(a) -> a));
        List<RefundRecordMethod> refundRecordMethodList = new ArrayList<>();
        PayMethodVo payMethodVo;
        RefundRecordMethod refundRecordMethod=null;
        RefundMethodTransformation refundMethodTransformation=null;
        RefundRecordMethod refundRecordMethod;
        for (OrderPayMethodDto orderPayMethodDto : orderRefundDto.getRefundPayMethod()) {
            payMethodVo = payMethodVoMap.get(orderPayMethodDto.getPayMethodNo());
            //判断是不是在支付方式里面的
            if (payMethodVo == null){
                throw new PlatTipsException(PlatformCode.ERROR_TIPS,"可退支付方式未找到对应的支付:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]");
                throw new PlatTipsException(PlatformCode.ERROR_TIPS,"可退支付方式未找到:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]");
            }
            //判断支付方式
            PaymentMethod payMethod = paymentMethodService.selectNumberNoUncheckUp(orderPayMethodDto.getPayMethodNo());
@@ -1153,32 +1156,26 @@
                throw new PlatTipsException(PlatformCode.ERROR_TIPS,"退款金额错误:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]");
            }
            //新增转换表记录
            refundMethodTransformation = new RefundMethodTransformation();
            BeanUtils.copyProperties(orderPayMethodDto, refundMethodTransformation);
            refundMethodTransformation.setRefundTotal(orderPayMethodDto.getMoney());
            refundMethodTransformation.setRefundRecordId(refundRecord.getId());
            refundMethodTransformationMapper.insert(refundMethodTransformation);
            //退回客户的支付方式
            ////退款方式数据填充
            refundRecordMethod = new RefundRecordMethod();
            refundRecordMethod.setType(refundRecord.getSourceType());
            refundRecordMethod.setActualTotal(orderPayMethodDto.getMoney());
            //支付方式信息
            refundRecordMethod.setNumberNo(payMethod.getNumberNo());
            refundRecordMethod.setPaymentMethodId(payMethod.getId());
            refundRecordMethod.setName(payMethod.getName());
            refundRecordMethod.setIsMoneyPay(payMethodVo.getIsMoneyPay());
            refundRecordMethod.setIsExecute(payMethodVo.getIsExecute());
            //退款方式信息
            refundRecordMethod.setRefundNumberNo(refundMethod.getNumberNo());
            refundRecordMethod.setRefundName(refundMethod.getName());
            refundRecordMethod.setRefundMethodId(refundMethod.getId());
            refundRecordMethod.setActualTotal(orderPayMethodDto.getMoney());
            refundRecordMethod.setRefundMethodId(refundMethod.getId());
            refundRecordMethod.setIsMoneyPayRefund(refundMethod.getIsMoneyPay());
            refundRecordMethod.setIsExecuteRefund(refundMethod.getIsExecute());
            refundRecordMethod.setRefundMethodTransId(refundMethodTransformation.getId());
            refundRecordMethod.setRemarks(orderPayMethodDto.getRemarks());
            //refundRecordMethod.setRemarks(orderPayMethodDto.getRemarks());
            refundRecordMethodService.insert(refundRecordMethod);
            refundRecordMethodList.add(refundRecordMethod);
@@ -1189,7 +1186,7 @@
    /**
     * 退款记录子项
     */
    public void insertRefundRecordItem(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord,List<RefundRecordMethod> refundRecordMethodList){
    public void insertRefundRecordItem(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,RefundRecord refundRecord){
        orderNodeBuilder.append("-记录退款详情");
@@ -1255,9 +1252,8 @@
                refundRecordItem.setRefundMoney(refundTotal);
            }
            refundRecordItemService.insert(refundRecordItem);
            //计算剩余要分配的退款总金额
            //减去已经分配的退款金额
            refundTotal = refundTotal.subtract(refundRecordItem.getRefundMoney()).setScale(2,RoundingMode.HALF_UP);
            //子单子项处理
            insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos());
        }
@@ -1336,7 +1332,6 @@
            refundRecordItemSourceMapper.insert(refundRecordItemSource);
            //减去已经分配退款金额
            refundTotal = refundTotal.subtract(refundRecordItemSource.getRefundMoney()).setScale(2,RoundingMode.HALF_UP);
        }
        if(refundTotal.compareTo(BigDecimal.ZERO) > 0){
@@ -1349,12 +1344,12 @@
     * 记录退款记录优惠卷
     */
    public void handleOrderCouponRefunDto(List<OrderCouponRefunDto> couponList,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord){
        CouponOrderDiscountLog couponOrderDiscountLog=null;
        RefundRecordCoupon refundRecordCoupon=null;
        CouponOrderDiscountLog couponOrderDiscountLog;
        RefundRecordCoupon refundRecordCoupon;
        orderNodeBuilder.append("-处理退款优惠卷");
        for (OrderCouponRefunDto orderCouponRefunDto : couponList) {
            couponOrderDiscountLog=couponOrderDiscountLogMapper.selectOneByKey(orderCouponRefunDto.getOrderCouponId());
            if(couponOrderDiscountLog==null){
            if( couponOrderDiscountLog == null){
                throw new PlatTipsException(PlatformCode.ERROR_TIPS,"订单优惠卷标识不正确");
            }
            refundRecordCoupon=new  RefundRecordCoupon(ordersTotal.getId(),refundRecord.getId(),ordersTotal.getUserId(),1,1,couponOrderDiscountLog.getId(),
@@ -1376,7 +1371,7 @@
        orderNodeBuilder.append("-处理退款支付方式,用户待执行项目");
        //处理主业务
        ordersTotal=  PartialRefundUtil.refundProcess(commonService, operationId, operatorName, refundRecord.getId());
        ordersTotal =  PartialRefundUtil.refundProcess(commonService, operationId, operatorName, refundRecord.getId());
        //返回数据
        Map<String,Object> data=new HashMap<>();
phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java
@@ -489,7 +489,6 @@
            refundRecordMethod.setIsPay(BaseEntity.NO);
            refundRecordMethod.setType(ConsumePayConstants.STATUS_WITHDRAW);
            refundRecordMethod.setRefundRecordId(refundRecord.getId());
            refundRecordMethod.setRefundMethodTransId(refundMethodTransformation.getId());
            refundRecordMethod.setPayee(refundFundsDto.getPayee());
            refundRecordMethod.setOpenBank(refundFundsDto.getOpenBank());
            refundRecordMethod.setOpenBranch(refundFundsDto.getOpenBranch());
phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java
@@ -71,7 +71,7 @@
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作失败,退款单状态已改变!");
        }
        //回去订单信息
        //获取订单信息
        OrdersTotal ordersTotal = commonService.selectOneByKeyBlob(OrdersTotalMapper.class,refundRecord.getOrderId());
        if(ordersTotal == null ){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到订单信息!");
@@ -259,22 +259,37 @@
        List<RefundRecordMethod> refundRecordMethodList = refundCarryVo.getRefundRecordMethodList();
        //装载分配好的支付方式记录的金额数据
        List<RefundRecordConsumePay> refundConsumePayList = new ArrayList<>();
        RefundRecordConsumePay refundRecordConsumePay;
        //引用对象
        List<ConsumePay> consumePayList;
        ///////获取订单支付方式记录
        map.put("orderId",refundRecord.getOrderId());
        sqlSentence.sqlSentence("SELECT *,ROUND(actualTotal-refundTotal,2) AS pTotal FROM consume_pay WHERE isDel = 0 AND orderId = #{m.orderId} ORDER BY pTotal ASC",map);
        List<ConsumePay> consumePayList = commonService.selectList(ConsumePayMapper.class,sqlSentence);
        //根据支付编号进行区分,key值:支付编号
        Map<String,List<ConsumePay>> consumePayMap = new HashMap<>();
        List<ConsumePay> consumePays;
        for(ConsumePay consumePay:consumePayList){
            consumePays = consumePayMap.computeIfAbsent(consumePay.getNumberNo(),k->new ArrayList<>());
            consumePays.add(consumePay);
        }
        ////引用对象
        //退款方式的金额
        BigDecimal mothedTotal;
        //分配支付方式金额
        BigDecimal mothedCutTotal;
        for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){
            if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO) < 1){
                continue;
            }
            mothedTotal = refundRecordMethod.getActualTotal();
            //获取支付方式
            map.put("orderId",refundRecord.getOrderId());
            map.put("numberNo",refundRecordMethod.getNumberNo());
            sqlSentence.sqlSentence("SELECT *,ROUND(actualTotal-refundTotal,2) AS pTotal FROM consume_pay WHERE isDel = 0 AND orderId = #{m.orderId} AND numberNo = #{m.numberNo} ORDER BY pTotal ASC",map);
            consumePayList = commonService.selectList(ConsumePayMapper.class,sqlSentence);
            for(ConsumePay consumePay:consumePayList){
            consumePays = consumePayMap.get(refundRecordMethod.getNumberNo());
            if(consumePays == null){
                throw new TipsException("没有找到该支付记录:"+refundRecordMethod.getName()+"["+refundRecordMethod.getNumberNo()+"]");
            }
            for(ConsumePay consumePay:consumePays){
                if(consumePay.getpTotal().compareTo(BigDecimal.ZERO) < 1){
                    continue;
                }
@@ -321,7 +336,7 @@
    public static RefundCarryVo refundRecordMotnedItemHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItem refundRecordItem
            ,RefundCarryVo refundCarryVo,CommonService commonService){
        //没有退款方式,跳过当前处理
        //没有退款方式,跳过当前处理,因为这里是处理退款方式金额的,如果没有退款金额,那么可以跳过该环节
        if(refundCarryVo.getRefundRecordMethodList().size() == 0){
            return refundCarryVo;
        }
@@ -341,7 +356,7 @@
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        //更新现金和划扣金额保存
        //更新退款子单的信息,更新现金和划扣金额保存
        values.put("deductionTotal",refundCarryVo.getDeductionTotal());
        values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser);
        values.put("cashTotal",refundCarryVo.getCashTotal());
@@ -419,23 +434,25 @@
        //进行升序排序,避免后面不够分配
        refundRecordMethodList = refundRecordMethodList.stream().sorted(Comparator.comparing(RefundRecordMethod::getpTotal)).collect(Collectors.toList());
        //获取子单的支付方式,子单支付记录,计算可退款金额
        //获取子单的支付方式记录,计算可退款金额
        List<ConsumePayItem> consumePayItemList;
        if(OrderSourceConstans.TYPE_PROJECT.equals(orderItemType)){
            //一级订单
            consumePayItemList = getOrderItemOneConsumePay(orderItemId,commonService);
        }else{
            //二级订单
            consumePayItemList = getOrderItemTwoConsumePay(orderItemId,commonService);
        }
        ////存储支付方式编号的可退款金额,根据支付编号求和,后面的判断会用到,key值:支付编号,value:可退金额
        ////存储支付方式编号的可退款金额,根据支付编号求和,后面的业务判断会用到,key值:支付编号,value:可退金额
        Map<String,BigDecimal> noMap = new HashMap<>();
        BigDecimal surplusTotal;
        ////存储支付方式编号的支付方式记录,根据支付编号整合,后面的判断会用到,key值:支付编号,value:支付记录集合
        ////存储支付方式编号的支付方式记录,根据支付编号整合,后面的业务会用到,key值:支付编号,value:支付记录集合
        Map<String,List<ConsumePayItem>> noPayItemMap = new HashMap<>();
        List<ConsumePayItem> noPayItemList;
        ////////填充支付方式记录的退款金额,计算剩余可退金额,支付方式记录的退款金额需要去查询计算获取
        //获取已经退款的退款方式金额,根据支付方式记录的标识求和返回
        //获取订单子单已经退款的退款方式金额,根据支付方式记录的标识求和返回
        List<RefundRecordConsumePay> refundRecordConsumePayList = getRefundRecordConsumePay(orderItemId,null,false,true,commonService);
        //转化成map,可以根据支付方式记录的标识直接获取到数据
        Map<String, RefundRecordConsumePay> refundRecordConsumePayMap = refundRecordConsumePayList.stream().collect(
@@ -454,10 +471,6 @@
            surplusTotal = surplusTotal.add(consumePayItem.getpTotal()).setScale(2,RoundingMode.HALF_UP);
            noMap.put(consumePayItem.getNumberNo(),surplusTotal);
        }
        //进行升序排序,避免后面不够分配
        consumePayItemList = consumePayItemList.stream().sorted(Comparator.comparing(ConsumePayItem::getpTotal)).collect(Collectors.toList());
        for(ConsumePayItem consumePayItem:consumePayItemList){
            //支付编码集合整合
            noPayItemList = noPayItemMap.computeIfAbsent(consumePayItem.getNumberNo(),k->new ArrayList<>());
            noPayItemList.add(consumePayItem);
@@ -533,7 +546,10 @@
            noMap.put(refundRecordItemMethod.getNumberNo(),surplusTotal);
            ///////生成关联支付方式记录和退款方式关联
            //根据支付编号获取支付方式记录
            noPayItemList = noPayItemMap.computeIfAbsent(refundRecordItemMethod.getNumberNo(),k->new ArrayList<>());
            //进行升序排序,避免后面不够分配
            noPayItemList = noPayItemList.stream().sorted(Comparator.comparing(ConsumePayItem::getpTotal)).collect(Collectors.toList());
            mothedTotal = refundRecordItemMethod.getActualTotal();
            for(ConsumePayItem consumePayItem:noPayItemList){
                if(consumePayItem.getpTotal().compareTo(BigDecimal.ZERO) < 1){
@@ -704,7 +720,7 @@
            refundCarryVo.setRefundConsumePayList(new ArrayList<>());
            refundCarryVo.setDeductionTotal(BigDecimal.ZERO);
            refundCarryVo.setCashTotal(BigDecimal.ZERO);
            //商品类型判断
            switch (refundRecordItem.getType()){
                case OrderItemConstants.TYPE_RETAIL:
                    refundCarryVo = handRefundRerail(refundRecord,refundRecordItem,refundCarryVo,commonService);
@@ -874,7 +890,7 @@
            userCard= userCardList.get(i);
            map.put("id",userCard.getId());
            map.put("effectiveStatus", UserProjectConstants.EFF_STATUS_CANCEL);
            sqlSentence.sqlSentence(" effectiveStatus=#{m.effectiveStatus} where id = #{m.id}",map);
            sqlSentence.sqlSentence(" effectiveStatus=#{m.effectiveStatus} WHERE id = #{m.id}",map);
            commonService.updateWhere(UserCardMapper.class,sqlSentence);
            //生成退款关联
@@ -1018,7 +1034,7 @@
        //因为有些是算次数抵扣的,所以要算
        if(CardEquity.EQUITY_TYPE_TIME_CARD.equals(cardEquity.getEquityType())){
            //次卡:总次数=开单的总次数*每次划扣的次数
            returnNum= refundNum *cardItemInfo.getEveryDrawNum();
            returnNum= refundNum * cardItemInfo.getEveryDrawNum();
        }else if(CardEquity.EQUITY_TYPE_N_M.equals(cardEquity.getEquityType())){
            returnNum = refundNum;
        }else{
@@ -1052,7 +1068,6 @@
     */
    private static RefundCarryVo handRefundPromotion(String operationId, RefundRecord refundRecord, OrdersTotal ordersTotal
            , RefundRecordItem refundRecordItem,RefundCarryVo refundCarryVo,CommonService commonService) {
        //查看订单信息
        OrderItem orderItem = commonService.selectOneByKey(OrderItemMapper.class,refundRecordItem.getOrderItemId());
@@ -1168,14 +1183,14 @@
            ,RefundCarryVo refundCarryVo,CommonService commonService) {
        //判断操作完了去修改子订单状态
        OrderItemSon orderItemSon=commonService.selectOneByKey(OrderItemSonMapper.class,refundRecordItemSource.getOrderItemSonId());
        OrderItemSon orderItemSon = commonService.selectOneByKey(OrderItemSonMapper.class,refundRecordItemSource.getOrderItemSonId());
        if (orderItemSon==null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到二级子订单信息");
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到二级子订单信息[02]");
        }
        UserProjectItem userProjectItem = getUserProject(orderItemSon.getId(),commonService);
        if(userProjectItem == null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"用户项目获取失败!");
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"用户项目获取失败[06]!");
        }
        if(userProjectItem.getNotUsedNum()<refundRecordItemSource.getRefundNum()){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"退款次数大于可退次数[83]!");
@@ -1184,7 +1199,7 @@
        //计算子单是否还有剩余的可扣疗程数
        int surplusNum = orderItemSon.getUsedTotal() - orderItemSon.getHasReNum();
        if(refundRecordItemSource.getRefundNum() > surplusNum){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"退款次数大于可退次数[84]!");
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"退款次数大于可退次数[56]!");
        }
        //处理用户项目,减去用户项目数量
@@ -1267,13 +1282,13 @@
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        values.put("orderItemId", orderItem.getId());
        values.put("id", orderItem.getId());
        values.put("refundStatus", refundStatus);
        values.put("refundTotal",refundTotal);
        values.put("refundNum",refundNum);
        values.put("oldHasReNum",orderItem.getHasReNum());
        sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" +
                " where isDel=0 AND id=#{m.orderItemId} AND hasReNum = #{m.oldHasReNum}",values);
                " WHERE isDel = 0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values);
        if(commonService.updateWhere(OrderItemMapper.class,sqlSentence) != 1){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"当前订单信息已发生变化,请重试[012]!");
        }
@@ -1296,7 +1311,7 @@
        values.put("refundTotal",refundTotal);
        values.put("refundNum",refundNum);
        values.put("oldHasReNum",orderItemSon.getHasReNum());
        sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" +
        sqlSentence.sqlUpdate(" refundStatus = #{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" +
                " where isDel=0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values);
        if(commonService.updateWhere(OrderItemSonMapper.class,sqlSentence) != 1){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"当前订单信息已发生变化,请重试[012]!");