From b3fdeac8c313971112a6245513f7215b39da537d Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期一, 15 五月 2023 10:07:43 +0800
Subject: [PATCH] 作废退款-测

---
 phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java |   68 ++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
index df2733e..e5177d3 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
+++ b/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());
+        }
     }
 
 }

--
Gitblit v1.8.0