chenjiahe
2023-05-11 b3fdeac8c313971112a6245513f7215b39da537d
作废退款-测
2个文件已修改
159 ■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java 91 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
@@ -925,10 +925,10 @@
        //判断是否是充值订单,是的话先冻结储值金,就是扣掉,审批通过就不处理储值金了,不通过还原资金
        if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
            OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"申请退款",commonService);
            OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"申请退款",orderNodeBuilder,commonService);
        }
        //活动处理
        OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"申请退款",commonService);
        OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"申请退款",orderNodeBuilder,commonService);
        return refundRecord;
    }
@@ -2011,10 +2011,10 @@
            if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
                //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0
                //充值金额
                OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"拒绝审批",commonService);
                OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"拒绝审批",orderNodeBuilder,commonService);
            }
            //活动规则退款处理
            OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"拒绝审批",commonService);
            OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"拒绝审批",orderNodeBuilder,commonService);
            ordersNodeLog.setCommonType(OrdersNodeLog.TYPE_COMMON_ORDER_REFUND);
            ordersNodeLog.setContent(orderNodeBuilder.toString());
@@ -2420,21 +2420,35 @@
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作失败,退款单状态已发生变化!");
        }
        //订单系统日志
        StringBuilder orderNodeBuilder = new StringBuilder();
        orderNodeBuilder.append("开始作废退款");
        //判断订单类型
        if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
            //充值订单
            OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"作废退款",commonService);
            OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"作废退款",orderNodeBuilder,commonService);
        }else{
            //处理子单
            OrderRefundCancelTool.refundRecordItemHandle(ordersTotal,refundRecord,commonService);
        }
        //处理订单活动
        OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"作废退款",commonService);
        OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"作废退款",orderNodeBuilder,commonService);
        //处理订单优惠券
        OrderRefundCancelTool.handCoupon(ordersTotal,refundRecord,commonService);
        OrderRefundCancelTool.handCoupon(ordersTotal,refundRecord,orderNodeBuilder,commonService);
        //处理总退款方式
        OrderRefundCancelTool.refundRecordMotnedHandle(refundRecord,ordersTotal,commonService);
        List<RefundRecordMethod> refundRecordMethodList= OrderRefundCancelTool.refundRecordMotnedHandle(refundRecord,ordersTotal,orderNodeBuilder,commonService);
        //操作的现金金额
        BigDecimal cashTotal = BigDecimal.ZERO;
        for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){
            if(refundRecordMethod.getIsMoneyPay().equals(RefundRecordMethod.YES)){
                cashTotal = cashTotal.add(refundRecordMethod.getActualTotal());
            }
        }
        //报错订单系统日志
        //****更改总订单退款状态
        values.clear();
@@ -2493,6 +2507,44 @@
            throw new TipsException("作废失败,订单状态已发生改变!");
        }
        //额外的操作,升降级,收入确认表
        additionalOperate(ordersTotal,refundRecord,cashTotal,orderNodeBuilder,customParameter,commonService);
        //记录日志(处理到具体节点(成功和失败))
        OrdersNodeLog ordersNodeLog = new OrdersNodeLog();
        orderNodeBuilder.append("-作废退款单结束");
        ordersNodeLog.setCommonType(OrdersNodeLog.TYPE_COMMON_ORDER_REFUND_CANCEL);
        ordersNodeLog.setContent(orderNodeBuilder.toString());
        ordersNodeLog.setOrderId(ordersTotal.getId());
        commonService.insert(OrdersNodeLogMapper.class,ordersNodeLog);
    }
    /**额外操作,不影响主流程*/
    public static void additionalOperate(OrdersTotal ordersTotal,RefundRecord refundRecord,BigDecimal total,StringBuilder orderNodeBuilder,CustomParameter customParameter,CommonService commonService){
        if(BigDecimal.ZERO.compareTo(total) < 0){
            try {
                orderNodeBuilder.append("-开始处理用户升降级,金额:").append(total);
                UserLevelUtil.refund(ordersTotal.getUserId(),ordersTotal.getId(),total,ordersTotal.getAppIdCode());
                orderNodeBuilder.append("-处理用户升降级成功");
            }catch (Exception e){
                String snapshot="处理用户升降级失败";
                orderNodeBuilder.append("-处理用户升降级失败,异常原因:").append(e.getMessage());
                logger.error("处理用户升降级失败:" + e.getMessage());
                //发送企业微信通知给工作人员
                SendNoticeUtil.failOrderSendNotice(ordersTotal,e.getMessage(),snapshot,commonService,customParameter);
            }
        }
        try{
            orderNodeBuilder.append("-开始记录收入确认表");
            PerformanceInfoTool.refundCancelPerformanceInfo(commonService,refundRecord);
            orderNodeBuilder.append("-记录收入确认表成功");
        }catch (Exception e){
            orderNodeBuilder.append("-记录收入确认表失败");
            logger.info("记录收入确认表,异常:{}",e.getMessage(),e);
            // 添加错误日志
            PerformanceInfoTool.addErrorLog(commonService, refundRecord.getId(), PerformanceInfo.ASSOCIATION_TYPE_GOODS_REFUND, e.getMessage());
        }
    }
}
phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java
@@ -54,7 +54,7 @@
    /**处理总退款方式数据*/
    public static void refundRecordMotnedHandle(RefundRecord refundRecord,OrdersTotal ordersTotal,CommonService commonService){
    public static List<RefundRecordMethod> refundRecordMotnedHandle(RefundRecord refundRecord,OrdersTotal ordersTotal,StringBuilder orderNodeBuilder,CommonService commonService){
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
@@ -90,7 +90,7 @@
        }
        //处理回退到账
        //处理扣减账号资金
        for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){
            if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo())){
                //储值金额 
@@ -99,6 +99,9 @@
                    UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getInvalidRemarks(),"作废退款:支付方式储值金额扣减",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO);
                    OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getInvalidId(), refundRecord.getInvalidName(), refundRecordMethod.getName()+"作废退款金额:"+refundRecordMethod.getRealRefundTotal(), 1, OrderLogConstants.LOG_TYPE_REFUND_UNDO);
                    commonService.insert(OrderLogMapper.class,orderLog);
                    if(orderNodeBuilder != null){
                        orderNodeBuilder.append("-[作废退款]扣减退款金额(储值金):").append(refundRecordMethod.getRealRefundTotal());
                    }
                }
            }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo())){
                //增值金
@@ -107,6 +110,9 @@
                    UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"作废退款:支付方式增值金退回",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO);
                    OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,refundRecord.getInvalidId(),refundRecord.getInvalidName(),refundRecordMethod.getName(),1, OrderLogConstants.LOG_TYPE_REFUND_UNDO);
                    commonService.insert(OrderLogMapper.class,orderLog);
                    if(orderNodeBuilder != null){
                        orderNodeBuilder.append("-[作废退款]扣减退款金额(增值金):").append(refundRecordMethod.getRealRefundTotal());
                    }
                }
            }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){
                //积分
@@ -115,6 +121,9 @@
                    UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"作废退款:支付方式积分退回",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_INTEGRAL,OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO);
                    OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,refundRecord.getInvalidId(),refundRecord.getInvalidName(),refundRecordMethod.getName()+"作废退款金额:"+refundRecordMethod.getRealRefundTotal(),1, OrderLogConstants.LOG_TYPE_REFUND_UNDO);
                    commonService.insert(OrderLogMapper.class,orderLog);
                    if(orderNodeBuilder != null){
                        orderNodeBuilder.append("-[作废退款]扣减退款金额(积分):").append(refundRecordMethod.getRealRefundTotal());
                    }
                }
            }else {
                //现金支付
@@ -126,6 +135,7 @@
                commonService.insert(OrderLogMapper.class,orderLog);
            }
        }
        return refundRecordMethodList;
    }
    /**充值单特需处理
@@ -135,7 +145,7 @@
     * @param optName 操作名称,如:申请退款、作废退款、审核拒绝
     * @param commonService 映射
     */
    public static void rechargeHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName, CommonService commonService){
    public static void rechargeHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,StringBuilder orderNodeBuilder, CommonService commonService){
        if(!OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作失败,不是充值单!");
@@ -148,12 +158,16 @@
            //充值金额扣减
            UserMoneyUtil.setNewUserMoneyUnclaimed(refundRecord.getUserId(),refundRecord.getInvalidRemarks(),"退款单:"+refundRecord.getCode()+";"+optName+",扣减充值资金:"+ordersTotal.getTotal(),refundRecord.getOperatorId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),ordersTotal.getTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_REFUND_CANCEL,commonService,UserMoneyUnclaimed.NO);
            orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getOperatorId(), refundRecord.getOperatorName(), "充值单:"+ordersTotal.getOrderNo()+";"+optName+",预扣除金额:"+ordersTotal.getTotal(), 0, OrderLogConstants.LOG_TYPE_REFUND);
        }else if(optType == OPT_TYPE_CANCEL){
            //充值金额回退
            UserMoneyUtil.setNewUserMoneyUnclaimed(refundRecord.getUserId(),refundRecord.getInvalidRemarks(),"退款单:"+refundRecord.getCode()+";"+optName+",退回充值资金:"+ordersTotal.getTotal(),refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),ordersTotal.getTotal(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_REFUND_CANCEL,commonService,UserMoneyUnclaimed.NO);
            orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getOperatorId(), refundRecord.getOperatorName(), "充值单:"+ordersTotal.getOrderNo()+";"+optName+",退回预扣除金额:"+ordersTotal.getTotal(), 0, OrderLogConstants.LOG_TYPE_REFUND);
        }else{
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作类型错误[1]["+optType+"]!");
        }
        if(orderNodeBuilder !=null){
            orderNodeBuilder.append("-[").append(optName).append("]充值单充值金操作(储值金):").append(ordersTotal.getTotal());
        }
        orderLog.setOrderId(ordersTotal.getId());
        commonService.insert(OrderLogMapper.class,orderLog);
@@ -166,7 +180,7 @@
     * @param optName 操作名称,如:申请退款、作废退款、审核拒绝
     * @param commonService 映射
     */
    public static void activityRuleHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,CommonService commonService){
    public static void activityRuleHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,StringBuilder orderNodeBuilder,CommonService commonService){
        //先获取活动规则
        SqlSentence sqlSentence = new SqlSentence();
@@ -177,7 +191,7 @@
        List<OrdersActivityInfo> ordersActivityInfoList = commonService.selectList(OrdersActivityInfoMapper.class,sqlSentence);
        if(ordersActivityInfoList.size() > 0){
            //订单活动信息处理
            activityRulePollingHandle2(ordersActivityInfoList,optType,optName,ordersTotal,refundRecord,commonService);
            activityRulePollingHandle2(ordersActivityInfoList,optType,optName,ordersTotal,refundRecord,orderNodeBuilder,commonService);
        }else{
            //没有订单活动信息处理,就获取保存在订单里面的活动标识
            values.clear();
@@ -185,7 +199,7 @@
            sqlSentence.sqlSentence("SELECT * FROM orders_info WHERE isDel = 0 AND orderId = #{m.orderId}",values);
            OrderInfo orderInfo = commonService.selectOne(OrderInfoMapper.class,sqlSentence);
            if(orderInfo!=null && StringUtils.noNull(orderInfo.getActivityId())){
                activityRulePollingHandle1(orderInfo.getActivityId(),optType,optName,ordersTotal,refundRecord,commonService);
                activityRulePollingHandle1(orderInfo.getActivityId(),optType,optName,ordersTotal,refundRecord,orderNodeBuilder,commonService);
            }
        }
    }
@@ -198,7 +212,8 @@
     * @param refundRecord 退款单
     * @param commonService 映射
     */
    public static void activityRulePollingHandle1(String activityId,int optType,String optName,OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){
    public static void activityRulePollingHandle1(String activityId,int optType,String optName,OrdersTotal ordersTotal,RefundRecord refundRecord
            ,StringBuilder orderNodeBuilder,CommonService commonService){
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
@@ -228,6 +243,9 @@
                    }else{
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作类型错误[2]["+optType+"]!");
                    }
                    if(orderNodeBuilder !=null){
                        orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(积分):").append(activityAction.getWorth());
                    }
                }else if(ActivityAction.TYPE_VALUEADDEDFUND.equals(activityAction.getType())){
                    //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0
                    if(new BigDecimal(activityAction.getWorth()).compareTo(BigDecimal.ZERO) == 0 ){
@@ -240,13 +258,20 @@
                    }else{
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作类型错误[3]["+optType+"]!");
                    }
                    if(orderNodeBuilder !=null){
                        orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(增值金):").append(activityAction.getWorth());
                    }
                }else if(ActivityAction.TYPE_COUPON.equals(activityAction.getType())){
                    values.put("oldValidState",optType==OPT_TYPE_EXECUTE? BaseEntity.YES:BaseEntity.NO);
                    values.put("newValidState",optType==OPT_TYPE_EXECUTE?BaseEntity.NO:BaseEntity.YES);
                    values.put("couponId",activityAction.getCrmCouponId());
                    values.put("commonId",ordersTotal.getId());
                    sqlSentence.sqlSentence(" validState=#{m.newValidState} where couponId=#{m.couponId} and commonId=#{m.commonId} and validState=#{m.oldValidState} ",values);
                    commonService.updateWhere(CouponNumberMapper.class,sqlSentence);
                    if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){
                        if(orderNodeBuilder !=null){
                            orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(优惠券):").append(activityAction.getWorthName());
                        }
                    }
                }
            }
        }
@@ -261,13 +286,15 @@
     * @param commonService 映射
     */
    public static void activityRulePollingHandle2(List<OrdersActivityInfo> ordersActivityInfoList,int optType,String optName,OrdersTotal ordersTotal
            ,RefundRecord refundRecord,CommonService commonService){
            ,RefundRecord refundRecord,StringBuilder orderNodeBuilder,CommonService commonService){
        if(ordersActivityInfoList == null || ordersActivityInfoList.size()==0){
            return;
        }
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        //是否变更订单活动状态
        boolean changeStatus;
        //获取订单活动条目
        List<OrdersActivityInfoItem> ordersActivityInfoItemList;
        for(OrdersActivityInfo ordersActivityInfo:ordersActivityInfoList){
@@ -278,6 +305,7 @@
            sqlSentence.sqlSentence("SELECT * FROM orders_activity_info_item WHERE isDel = 0 AND activityInfoId = #{m.activityInfoId} AND performStatus = #{m.performStatus} AND handleStatus = #{m.handleStatus}",values);
            ordersActivityInfoItemList = commonService.selectList(OrdersActivityInfoItemMapper.class,sqlSentence);
            for(OrdersActivityInfoItem ordersActivityInfoItem:ordersActivityInfoItemList){
                changeStatus = false;
                if(ActivityAction.TYPE_INTEGRAL.equals(ordersActivityInfoItem.getType())){
                    //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0
                    if(new BigDecimal(ordersActivityInfoItem.getWorth()).compareTo(BigDecimal.ZERO) == 0){
@@ -290,6 +318,10 @@
                    }else{
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作类型错误[2]["+optType+"]!");
                    }
                    if(orderNodeBuilder !=null){
                        orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(积分):").append(ordersActivityInfoItem.getWorth());
                    }
                    changeStatus = true;
                }else if(ActivityAction.TYPE_VALUEADDEDFUND.equals(ordersActivityInfoItem.getType())){
                    //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0
                    if(new BigDecimal(ordersActivityInfoItem.getWorth()).compareTo(BigDecimal.ZERO) == 0 ){
@@ -302,6 +334,10 @@
                    }else{
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作类型错误[3]["+optType+"]!");
                    }
                    if(orderNodeBuilder !=null){
                        orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(增值金):").append(ordersActivityInfoItem.getWorth());
                    }
                    changeStatus = true;
                }else if(ActivityAction.TYPE_COUPON.equals(ordersActivityInfoItem.getType())){
                    values.clear();
                    values.put("oldValidState",optType==OPT_TYPE_EXECUTE? BaseEntity.YES:BaseEntity.NO);
@@ -309,18 +345,24 @@
                    values.put("id",ordersActivityInfoItem.getCouponNumberId());
                    sqlSentence.sqlSentence(" validState=#{m.newValidState} where id=#{m.id} AND validState = #{m.oldValidState} ",values);
                    //优惠券不判断回退
                    commonService.updateWhere(CouponNumberMapper.class,sqlSentence);
                    if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){
                        if(orderNodeBuilder !=null){
                            orderNodeBuilder.append("-[").append(optName).append("]处理活动赠送(优惠券):").append(ordersActivityInfoItem.getWorthName());
                        }
                        changeStatus = true;
                    }
                }
                //更新订单活动信息状态
                values.clear();
                values.put("handleStatus",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_CANCEL:OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS);
                values.put("handleStatusOld",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS:OrdersActivityInfoItem.HANDLE_STATUS_CANCEL);
                values.put("performStatusOld",OrdersActivityInfoItem.STATUS_PERFORM_SEND_OUT);
                values.put("id",ordersActivityInfoItem.getId());
                sqlSentence.sqlSentence("handleStatus = #{m.handleStatus} WHERE id = #{m.id} AND handleStatus = #{m.handleStatusOld} AND performStatus = #{m.performStatusOld}",values);
                if(commonService.updateWhere(OrdersActivityInfoItemMapper.class,sqlSentence) != 1){
                    throw new PlatTipsException(PlatformCode.ERROR_TIPS,"活动条目状态变化错误:");
                if(changeStatus){
                    //更新订单活动信息状态
                    values.clear();
                    values.put("handleStatus",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_CANCEL:OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS);
                    values.put("handleStatusOld",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS:OrdersActivityInfoItem.HANDLE_STATUS_CANCEL);
                    values.put("performStatusOld",OrdersActivityInfoItem.STATUS_PERFORM_SEND_OUT);
                    values.put("id",ordersActivityInfoItem.getId());
                    sqlSentence.sqlSentence("handleStatus = #{m.handleStatus} WHERE id = #{m.id} AND handleStatus = #{m.handleStatusOld} AND performStatus = #{m.performStatusOld}",values);
                    if(commonService.updateWhere(OrdersActivityInfoItemMapper.class,sqlSentence) != 1){
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS,"活动条目状态变化错误:");
                    }
                }
            }
        }
@@ -332,7 +374,7 @@
     * @param refundRecord 退款总数据
     * @param commonService 映射
     */
    public static void handCoupon(OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService) {
    public static void handCoupon(OrdersTotal ordersTotal,RefundRecord refundRecord,StringBuilder orderNodeBuilder,CommonService commonService) {
        //回退的优惠券变成使用状态
        //如果该优惠券在别的订单使用了,那么就不再理会
@@ -372,7 +414,10 @@
                values.put("useType", CouponNumber.USE_TYPE_USER);
                values.put("id", couponOrderDiscountLog.getCouponNumberId());
                sqlSentence.sqlSentence("  isUse=#{m.isUse},useTime=#{m.useTime},useType=#{m.useType},isUse=#{m.isUse} WHERE id = #{m.id} AND isUse = #{m.isUseOld}",values);
                if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) == 1){
                if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){
                    if(orderNodeBuilder != null){
                        orderNodeBuilder.append("-[作废退款]使用优惠券处理:"+couponOrderDiscountLog.getTitle());
                    }
                    //变更订单优惠券记录状态
                    values.clear();
                    values.put("status", BaseEntity.NO);
@@ -740,7 +785,7 @@
        StringBuilder sql;
        for(UserCardUsed userCardUsed:userCardUsedList){
            //判断是否够了,跳出循环
            if(opNum == returnNum){
            if(opNum <= 0){
                break;
            }
            if(userCardUsed.getCancelNum() <= 0){