| | |
| | | |
| | | //判断是否是充值订单,是的话先冻结储值金,就是扣掉,审批通过就不处理储值金了,不通过还原资金 |
| | | 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; |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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(); |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | } |