From 99213f3d390cd357f8acb679f0ec52af711b187e Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期日, 08 十月 2023 19:11:12 +0800
Subject: [PATCH] 退款优化参数存储

---
 phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java   |  238 +++++++++++++++++++++++++++++++++++------------
 phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java |   14 ++
 2 files changed, 188 insertions(+), 64 deletions(-)

diff --git a/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java b/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java
index 0146c41..7aa423f 100644
--- a/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java
+++ b/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java
@@ -1,5 +1,7 @@
 package com.hx.phip.vo.order.refund;
 
+import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
+import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
 import com.hx.phiappt.model.refund.RefundRecordConsumePay;
 import com.hx.phiappt.model.refund.RefundRecordItemMethod;
 import com.hx.phiappt.model.refund.RefundRecordMethod;
@@ -26,9 +28,17 @@
     private BigDecimal deductionTotal;
     /**鍒嗛厤鐨勯��娆炬敮浠樻柟寮忕幇閲戦噾棰濇�诲拰*/
     private BigDecimal cashTotal;
+    /**閫�娆剧幇閲戞�婚噾棰�(鍏冿紝涓嶅寘鍚��鍒板偍鍊奸噾鐨�)*/
+    private BigDecimal cashPurenessTotal;
+    /**閫�娆惧偍鍊奸噾鎬婚噾棰�(鍏�)"*/
+    private BigDecimal rechargeTotal;
+    /**閫�娆惧鍊奸噾鎬婚噾棰�(鍏�)*/
+    private BigDecimal incrementTotal;
+    /**閫�娆剧Н鍒�*/
+    private BigDecimal integralTotal;
+    /**閫�娆炬�婚噾棰濓紙鍏冿級*/
+    private BigDecimal refundTotal;
     /**鍒嗛厤鐨勭敤鎴烽」鐩垝鎵i噾棰�*/
     private BigDecimal deductionTotalUser;
-
-
 
 }
diff --git a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java
index 855c5be..4ccc83a 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java
@@ -89,11 +89,10 @@
         //閫�娆炬�昏鍗曠姸鎬佸彉鏇�
         values.put("refundStatus", RefundStatus.STATUS_SUCC_REFUND);
         values.put("oldRefundStatus", RefundStatus.STATUS_APPLY_REFUND);
-        values.put("refundTotal", refundRecord.getRefundTotal());
         values.put("createTime", new Date());
         values.put("isDel", BaseEntity.NO);
         values.put("id",refundRecord.getId());
-        sqlSentence.sqlSentence(" refundTotal = #{m.refundTotal},refundStatus=#{m.refundStatus},createTime = #{m.createTime} WHERE id = #{m.id} AND isDel=#{m.isDel} AND refundStatus = #{m.oldRefundStatus}",values);
+        sqlSentence.sqlSentence(" refundStatus=#{m.refundStatus},createTime = #{m.createTime} WHERE id = #{m.id} AND isDel=#{m.isDel} AND refundStatus = #{m.oldRefundStatus}",values);
         if(commonService.updateWhere(RefundRecordMapper.class,sqlSentence) != 1){
             throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔澶辫触锛岄��娆惧崟鐘舵�佸凡鏀瑰彉锛�");
         }
@@ -133,6 +132,21 @@
         handCoupon(refundRecord,commonService);
         //澶勭悊鎬婚��娆炬柟寮忔暟鎹�
         refundCarryVo = refundRecordMotnedHandle(refundCarryVo,operationId,operationNme,refundRecord,ordersTotal,commonService);
+
+        //-----瀛樺偍閫�娆鹃噾棰�
+        values.put("id",refundRecord.getId());
+        values.put("realRefundTotal",refundCarryVo.getRefundTotal());
+        values.put("realRefundIntegral",refundCarryVo.getIntegralTotal());
+        values.put("deductionTotal",refundRecord.getDeductionTotal());
+        values.put("cashTotal",refundRecord.getCashTotal());
+        values.put("cashPurenessTotal",refundRecord.getCashPurenessTotal());
+        values.put("rechargeTotal",refundRecord.getRechargeTotal());
+        values.put("incrementTotal",refundRecord.getIncrementTotal());
+        sqlSentence.sqlSentence(" realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},deductionTotal=#{m.deductionTotal},cashTotal = #{m.cashTotal}" +
+                ",cashPurenessTotal = #{m.cashPurenessTotal},rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values);
+        if(commonService.updateWhere(RefundRecordMapper.class,sqlSentence) != 1){
+            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔澶辫触锛屽彉鏇撮��娆惧崟閲戦澶辫触锛�");
+        }
 
         //鏇存敼鎬昏鍗曢��娆剧姸鎬�
         values.clear();
@@ -253,10 +267,22 @@
         }
         refundCarryVo.setRefundConsumePayList(refundRecordConsumePayList);
 
+
+        //璁$畻鍚勭閲戦
+        refundCarryVo.setRefundTotal(BigDecimal.ZERO);
+        refundCarryVo.setDeductionTotal(BigDecimal.ZERO);
+        refundCarryVo.setCashTotal(BigDecimal.ZERO);
+        refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO);
+        refundCarryVo.setRechargeTotal(BigDecimal.ZERO);
+        refundCarryVo.setIncrementTotal(BigDecimal.ZERO);
+        refundCarryVo.setIntegralTotal(BigDecimal.ZERO);
+
         //澶勭悊鍥為��鍒拌处
         for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){
             if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo())){
                 //鍌ㄥ�奸噾棰濄��
+                refundCarryVo.setRechargeTotal(refundCarryVo.getRechargeTotal().add(refundRecordMethod.getActualTotal()));
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal()));
                 //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0
                 if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){
                     UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"鎿嶄綔鍘熷洜:閫�娆惧鏍搁�氳繃,閫�娆炬柟寮�:閫�鍥炲偍鍊奸噾",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO);
@@ -265,22 +291,25 @@
                 }
             }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo())){
                 //澧炲�奸噾
+                refundCarryVo.setIncrementTotal(refundCarryVo.getIncrementTotal().add(refundRecordMethod.getActualTotal()));
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal()));
                 //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0
-                if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)!=0){
+                if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){
                     UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"鎿嶄綔鍘熷洜:閫�娆惧鏍搁�氳繃,閫�娆炬柟寮�:閫�鍥炲鍊奸噾",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.YES);
                     OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,operationId,operationNme,refundRecordMethod.getName(),0, OrderLogConstants.LOG_TYPE_REFUND);
                     commonService.insert(OrderLogMapper.class,orderLog);
                 }
             }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){
                 //绉垎
+                refundCarryVo.setIntegralTotal(refundCarryVo.getIntegralTotal().add(refundRecordMethod.getActualTotal()));
                 //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0
-                if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)!=0){
+                if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){
                     UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"鎿嶄綔鍘熷洜:閫�娆惧鏍搁�氳繃,閫�娆炬柟寮�:閫�鍥炵Н鍒�",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_INTEGRAL,OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.YES);
                     OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,operationId,operationNme,refundRecordMethod.getName()+"閫�娆鹃噾棰�:"+refundRecordMethod.getActualTotal(),0, OrderLogConstants.LOG_TYPE_REFUND);
                     commonService.insert(OrderLogMapper.class,orderLog);
                 }
             }else {
-                //鐜伴噾鏀粯
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal()));
                 if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)<1){
                     continue;
                 }
@@ -288,6 +317,21 @@
                 orderLog.setOrderId(ordersTotal.getId());
                 commonService.insert(OrderLogMapper.class,orderLog);
             }
+            //鏄惁鐜伴噾
+            if(refundRecordMethod.getIsMoneyPay().equals(BaseEntity.YES)){
+                refundCarryVo.setCashTotal(refundCarryVo.getCashTotal().add(refundRecordMethod.getActualTotal()));
+                //涓嶆槸閫�鍒板偍鍊奸噾銆佸鍊奸噾銆佺Н鍒�
+                if(!PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo())
+                    &&!PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo())
+                        &&!PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){
+                    refundCarryVo.setCashPurenessTotal(refundCarryVo.getCashPurenessTotal().add(refundRecordMethod.getActualTotal()));
+                }
+            }
+            //鍒ゆ柇鏄惁鍒掓墸鐨�
+            if(refundRecordMethod.getIsExecute().equals(BaseEntity.YES)){
+                refundCarryVo.setDeductionTotal(refundCarryVo.getDeductionTotal().add(refundRecordMethod.getActualTotal()));
+            }
+
         }
         return refundCarryVo;
     }
@@ -369,14 +413,13 @@
     }
 
     /**澶勭悊涓�绾у瓙閫�娆炬柟寮忔暟鎹�
-     * @param deductionTotalUser 鐢ㄦ埛椤圭洰琚墸鍑忕殑鍒掓墸閲戦锛屽彲绌�
      * @param refundRecord 閫�娆捐褰曟�昏〃
      * @param refundRecordItem 閫�娆捐褰曞瓙琛�
      * @param refundCarryVo 鎬绘惡甯﹀弬鏁扮粨鏋�
      * @param commonService 鏄犲皠
      * @return 鎬绘惡甯﹀弬鏁扮粨鏋�
      */
-    public static RefundCarryVo refundRecordMotnedItemHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItem refundRecordItem
+    public static RefundCarryVo refundRecordMotnedItemHandle(RefundRecord refundRecord,RefundRecordItem refundRecordItem
             ,RefundCarryVo refundCarryVo,CommonService commonService){
 
         //娌℃湁閫�娆炬柟寮忥紝璺宠繃褰撳墠澶勭悊锛屽洜涓鸿繖閲屾槸澶勭悊閫�娆炬柟寮忛噾棰濈殑锛屽鏋滄病鏈夐��娆鹃噾棰濓紝閭d箞鍙互璺宠繃璇ョ幆鑺�
@@ -392,49 +435,50 @@
             payMothedPercentage = BigDecimal.ZERO;
         }
 
-        //澶勭悊閫�娆炬柟寮�
+        //澶勭悊閫�娆炬柟寮忥紝瀛樺偍淇℃伅
         refundCarryVo = insertRefundItemMothed(refundRecordItem.getId(),refundRecordItem.getRefundMoney(),payMothedPercentage,OrderSourceConstans.TYPE_PROJECT
                 ,refundRecordItem.getOrderItemId(),refundCarryVo,refundRecord,commonService);
 
         //鏇存柊閫�娆惧瓙鍗�
-        updateRefundItem(refundCarryVo.getDeductionTotal(),refundCarryVo.getCashTotal(),deductionTotalUser
-                ,refundRecordItem.getId(),commonService);
+        updateRefundItem(refundCarryVo,refundRecordItem.getId(),commonService);
 
         return refundCarryVo;
     }
 
     /**鏇存柊閫�娆句竴绾у瓙鍗曠殑淇℃伅
-     * @param deductionTotal 閫�娆炬柟寮忕殑鍒掓墸閲戦
-     * @param cashTotal 閫�娆炬柟寮忕殑鐜伴噾閲戦
-     * @param deductionTotalUser 鐢ㄦ埛椤圭洰鐨勫垝鎵i噾棰�
      * @param refundItemId 閫�娆捐褰曚竴绾у瓙鍗曟爣璇�
      * @param commonService 鏄犲皠
      */
-    public static void updateRefundItem(BigDecimal deductionTotal,BigDecimal cashTotal,BigDecimal deductionTotalUser
+    public static void updateRefundItem(RefundCarryVo refundCarryVo
             ,String refundItemId,CommonService commonService){
         SqlSentence sqlSentence = new SqlSentence();
         Map<String,Object> values = new HashMap<>();
 
         //鏇存柊閫�娆惧瓙鍗曠殑淇℃伅锛屾洿鏂扮幇閲戝拰鍒掓墸閲戦淇濆瓨
-        values.put("deductionTotal",deductionTotal);
-        values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser);
-        values.put("cashTotal",cashTotal);
+        values.put("realRefundTotal",refundCarryVo.getRefundTotal());
+        values.put("realRefundIntegral",refundCarryVo.getIntegralTotal());
+        values.put("deductionTotal",refundCarryVo.getDeductionTotal());
+        values.put("deductionTotalUser",refundCarryVo.getDeductionTotalUser());
+        values.put("cashTotal",refundCarryVo.getCashTotal());
+        values.put("cashPurenessTotal",refundCarryVo.getCashPurenessTotal());
+        values.put("rechargeTotal",refundCarryVo.getRechargeTotal());
+        values.put("incrementTotal",refundCarryVo.getIncrementTotal());
         values.put("id",refundItemId);
-        sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal} WHERE id = #{m.id}",values);
+        sqlSentence.sqlUpdate("realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal}" +
+                ",cashPurenessTotal = #{m.cashPurenessTotal},rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values);
         if(commonService.updateWhere(RefundRecordItemMapper.class,sqlSentence) != 1){
             throw new TipsException("鏇存柊閫�娆惧瓙椤逛俊鎭け璐ワ紒");
         }
     }
 
     /**澶勭悊浜岀骇瀛愰��娆炬柟寮忔暟鎹�
-     * @param deductionTotalUser 鐢ㄦ埛椤圭洰琚墸鍑忕殑鍒掓墸閲戦
      * @param refundRecord  閫�娆捐褰曟�昏〃
      * @param refundRecordItemSource 閫�娆捐褰曞瓙琛�
      * @param refundCarryVo 鎬绘惡甯﹀弬鏁扮粨鏋�
      * @param commonService 鏄犲皠
      * @return 鎬绘惡甯﹀弬鏁扮粨鏋�
      */
-    public static RefundCarryVo refundRecordMotnedItemTwoHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItemSource refundRecordItemSource
+    public static RefundCarryVo refundRecordMotnedItemTwoHandle(RefundRecord refundRecord,RefundRecordItemSource refundRecordItemSource
             ,RefundCarryVo refundCarryVo,CommonService commonService){
 
         //瑁呰浇鏀粯鏂瑰紡閫�娆句俊鎭�
@@ -461,10 +505,17 @@
                 ,refundRecordItemSource.getOrderItemSonId(),refundCarryVo,refundRecord,commonService);
 
         values.put("deductionTotal",refundCarryVo.getDeductionTotal());
-        values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser);
+        values.put("deductionTotalUser",refundCarryVo.getDeductionTotalUser());
+        values.put("realRefundTotal",refundCarryVo.getRefundTotal());
+        values.put("realRefundIntegral",refundCarryVo.getIntegralTotal());
         values.put("cashTotal",refundCarryVo.getCashTotal());
+        values.put("cashPurenessTotal",refundCarryVo.getCashPurenessTotal());
+        values.put("rechargeTotal",refundCarryVo.getRechargeTotal());
+        values.put("incrementTotal",refundCarryVo.getIncrementTotal());
         values.put("id",refundRecordItemSource.getId());
-        sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal} WHERE id = #{m.id}",values);
+        sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal}" +
+                ",realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},cashPurenessTotal = #{m.cashPurenessTotal}" +
+                ",rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values);
         if(commonService.updateWhere(RefundRecordItemSourceMapper.class,sqlSentence) != 1){
             throw new TipsException("鏇存柊閫�娆惧瓙椤逛俊鎭け璐94]锛�");
         }
@@ -542,10 +593,6 @@
         BigDecimal mothedTotal;
         //鏀粯缂栧彿鍒嗛厤鐨勯��娆鹃噾棰�
         BigDecimal mothedCutTotal;
-        //鍒嗛厤鐨勫垝鎵i噾棰濇�诲拰
-        BigDecimal deductionTotal = BigDecimal.ZERO;
-        //鍒嗛厤鐨勭幇閲戦噾棰濇�诲拰
-        BigDecimal cashTotal = BigDecimal.ZERO;
 
         //瑁呰浇宸茬粡鍒嗛厤鐨勯��娆鹃噾棰濊褰曪紝key鍊硷細鎬婚��娆炬柟寮忚褰曟爣璇�
         Map<String,RefundRecordItemMethod> refundRecordItemMethodMap = new HashMap<>();
@@ -648,6 +695,21 @@
             //鑾峰彇鍒嗛厤鐨勯��娆炬柟寮忚褰�
             refundRecordItemMethod = refundRecordItemMethodMap.get(refundRecordMethod.getId());
 
+            if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordItemMethod.getRefundNumberNo())){
+                //鍌ㄥ�奸噾棰濄��
+                refundCarryVo.setRechargeTotal(refundCarryVo.getRechargeTotal().add(refundRecordItemMethod.getActualTotal()));
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal()));
+            }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordItemMethod.getRefundNumberNo())){
+                //澧炲�奸噾
+                refundCarryVo.setIncrementTotal(refundCarryVo.getIncrementTotal().add(refundRecordItemMethod.getActualTotal()));
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal()));
+            }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordItemMethod.getRefundNumberNo())){
+                //绉垎
+                refundCarryVo.setIntegralTotal(refundCarryVo.getIntegralTotal().add(refundRecordItemMethod.getActualTotal()));
+            }else {
+                refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal()));
+            }
+
             ///////鐢熸垚鍏宠仈鏀粯鏂瑰紡璁板綍鍜岄��娆炬柟寮忓叧鑱�
             //鏍规嵁鏀粯缂栧彿鑾峰彇鏀粯鏂瑰紡璁板綍
             noPayItemList = noPayItemMap.computeIfAbsent(refundRecordItemMethod.getNumberNo(),k->new ArrayList<>());
@@ -667,11 +729,17 @@
 
                 //鐜伴噾閲戦
                 if(consumePayItem.getIsMoneyPay().equals(ConsumePayItem.YES)){
-                    cashTotal = cashTotal.add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP);
+                    refundCarryVo.setCashTotal(refundCarryVo.getCashTotal().add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP));
+                    //涓嶆槸閫�鍒板偍鍊奸噾銆佸鍊奸噾銆佺Н鍒�
+                    if(!PayMethodTypeConstants.PAY_STORED.equals(refundRecordItemMethod.getRefundNumberNo())
+                            &&!PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordItemMethod.getRefundNumberNo())
+                            &&!PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordItemMethod.getRefundNumberNo())){
+                        refundCarryVo.setCashPurenessTotal(refundCarryVo.getCashPurenessTotal().add(mothedCutTotal));
+                    }
                 }
                 //鍒掓墸閲戦
                 if(consumePayItem.getIsExecute().equals(ConsumePayItem.YES)){
-                    deductionTotal = deductionTotal.add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP);
+                    refundCarryVo.setDeductionTotal(refundCarryVo.getDeductionTotal().add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP));
                 }
 
                 //鐢熸垚鍏宠仈璁板綍
@@ -695,8 +763,6 @@
             }
         }
 
-        refundCarryVo.setDeductionTotal(deductionTotal);
-        refundCarryVo.setCashTotal(cashTotal);
         refundCarryVo.setRefundConsumePayList(refundConsumePayList);
         refundCarryVo.setRefundRecordItemMethodList(refundRecordItemMethodList);
 
@@ -879,6 +945,11 @@
             refundCarryVo.setDeductionTotal(BigDecimal.ZERO);
             refundCarryVo.setCashTotal(BigDecimal.ZERO);
             refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO);
+            refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO);
+            refundCarryVo.setRechargeTotal(BigDecimal.ZERO);
+            refundCarryVo.setIntegralTotal(BigDecimal.ZERO);
+            refundCarryVo.setIncrementTotal(BigDecimal.ZERO);
+            refundCarryVo.setRefundTotal(BigDecimal.ZERO);
             //鍟嗗搧绫诲瀷鍒ゆ柇
             switch (refundRecordItem.getType()){
                 case OrderItemConstants.TYPE_RETAIL:
@@ -957,11 +1028,13 @@
             refundStatus = OrderTotalConstants.STATUS_REFUND_PART;
         }
 
-        //鏇存柊瀛愯鍗曚俊鎭�
-        updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService);
-
         //閫�娆炬柟寮忓鐞�
-        return refundRecordMotnedItemHandle(null,refundRecord,refundRecordItem,refundCarryVo,commonService);
+        refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService);
+
+        //鏇存柊瀛愯鍗曚俊鎭�
+        updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService);
+
+        return refundCarryVo;
     }
 
     /**
@@ -1015,11 +1088,13 @@
             refundStatus=OrderTotalConstants.STATUS_REFUND_PART;
         }
 
-        //鏇存柊瀛愯鍗曚俊鎭�
-        updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService);
-
         //閫�娆炬柟寮忓鐞�
-        return refundRecordMotnedItemHandle(userProjectDeductionVo.getDeductionTotal(),refundRecord,refundRecordItem,refundCarryVo,commonService);
+        refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService);
+
+        //鏇存柊瀛愯鍗曚俊鎭�
+        updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService);
+
+        return refundCarryVo;
     }
 
     /**閫�娆�-澶勭悊鍗¢」
@@ -1080,11 +1155,11 @@
             refundStatus =  OrderTotalConstants.STATUS_REFUND_PART;
         }
 
-        //鏇存柊瀛愯鍗曚俊鎭�
-        updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService);
-
         //閫�娆炬柟寮忓鐞�
-        refundCarryVo = refundRecordMotnedItemHandle(null,refundRecord,refundRecordItem,refundCarryVo,commonService);
+        refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService);
+
+        //鏇存柊瀛愯鍗曚俊鎭�
+        updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService);
 
         //--鍗¢」閮ㄥ垎閫�澶勭悊
         if(RefundSoruceConstants.TYPE_SOURCE_USER_CARD.equals(refundRecord.getSourceAssistantType())){
@@ -1323,10 +1398,20 @@
         RefundRecordConsumePay refundRecordConsumePay;
         //璁$畻鏈閫�娆炬柟寮忕殑鍒掓墸閲戦
         BigDecimal deductionTotal = BigDecimal.ZERO;
-        //璁$畻鏈閫�娆炬柟寮忕殑鐜伴噾閲戦
-        BigDecimal cashTotal = BigDecimal.ZERO;
         //鍒嗛厤鐨勭敤鎴烽」鐩垝鎵i噾棰�
         BigDecimal deductionTotalUser = BigDecimal.ZERO;
+        //璁$畻鏈閫�娆炬柟寮忕殑鐜伴噾閲戦
+        BigDecimal cashTotal = BigDecimal.ZERO;
+        //閫�娆剧幇閲戞�婚噾棰�(鍏冿紝涓嶅寘鍚��鍒板偍鍊奸噾鐨�)
+        BigDecimal cashPurenessTotal = BigDecimal.ZERO;;
+        //閫�娆惧偍鍊奸噾鎬婚噾棰�(鍏�)
+         BigDecimal rechargeTotal = BigDecimal.ZERO;;
+        //閫�娆惧鍊奸噾鎬婚噾棰�(鍏�)
+         BigDecimal incrementTotal = BigDecimal.ZERO;;
+        //閫�娆剧Н鍒�
+         BigDecimal integralTotal = BigDecimal.ZERO;;
+        //閫�娆炬�婚噾棰濓紙鍏冿級
+        BigDecimal refundTotal = BigDecimal.ZERO;;
 
         for (RefundRecordItemSource son : sons) {
             //鍒濆鍖栨�荤粨鏋勬惡甯﹀弬鏁�
@@ -1334,6 +1419,12 @@
             refundCarryVo.setDeductionTotal(BigDecimal.ZERO);
             refundCarryVo.setCashTotal(BigDecimal.ZERO);
             refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO);
+            refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO);
+            refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO);
+            refundCarryVo.setRechargeTotal(BigDecimal.ZERO);
+            refundCarryVo.setIntegralTotal(BigDecimal.ZERO);
+            refundCarryVo.setIncrementTotal(BigDecimal.ZERO);
+            refundCarryVo.setRefundTotal(BigDecimal.ZERO);
             switch (GroupTypeEnum.getCode(son.getType())){
                 case PROJECT:
                     refundCarryVo = handRefundNoSonExecution(refundRecord,refundRecordItem,son,refundCarryVo,orderItem.getUserCardId(),commonService,deductionSingleService);
@@ -1366,6 +1457,11 @@
             deductionTotal = deductionTotal.add(refundCarryVo.getDeductionTotal());
             cashTotal = cashTotal.add(refundCarryVo.getCashTotal());
             deductionTotalUser = deductionTotalUser.add(refundCarryVo.getDeductionTotalUser());
+            cashPurenessTotal = cashPurenessTotal.add(refundCarryVo.getCashPurenessTotal());
+            rechargeTotal = rechargeTotal.add(refundCarryVo.getRechargeTotal());
+            incrementTotal = incrementTotal.add(refundCarryVo.getIncrementTotal());
+            integralTotal = integralTotal.add(refundCarryVo.getIntegralTotal());
+            refundTotal = refundTotal.add(refundCarryVo.getRefundTotal());
             //閬嶅巻鍙犲姞鏀粯鏂瑰紡璁板綍鐨勯��娆鹃噾棰�
             for(RefundRecordConsumePay re:refundCarryVo.getRefundConsumePayList()){
                 refundRecordConsumePay = refundRecordConsumePayMap.computeIfAbsent(re.getConsumePayId(),k->new RefundRecordConsumePay(BigDecimal.ZERO,re.getNumberNo(),re.getName(),re.getIsMoneyPay(),re.getIsExecute(),re.getConsumePayId()));
@@ -1382,10 +1478,13 @@
         refundCarryVo.setDeductionTotal(deductionTotal);
         refundCarryVo.setDeductionTotalUser(deductionTotalUser);
         refundCarryVo.setRefundConsumePayList(refundRecordConsumePayList);
+        refundCarryVo.setCashPurenessTotal(cashPurenessTotal);
+        refundCarryVo.setRechargeTotal(rechargeTotal);
+        refundCarryVo.setIncrementTotal(incrementTotal);
+        refundCarryVo.setRefundTotal(refundTotal);
 
         //鏇存柊閫�娆惧瓙鍗�
-        updateRefundItem(refundCarryVo.getDeductionTotal(),refundCarryVo.getCashTotal(),refundCarryVo.getDeductionTotalUser()
-                ,refundRecordItem.getId(),commonService);
+        updateRefundItem(refundCarryVo,refundRecordItem.getId(),commonService);
 
         //鑾峰彇鍏跺瓙椤�
         map.put("orderItemId",orderItem.getId());
@@ -1411,7 +1510,7 @@
         }
 
         //鏇存柊瀛愯鍗曚俊鎭�
-        updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundNum,commonService);
+        updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundNum,commonService);
 
         return refundCarryVo;
     }
@@ -1462,11 +1561,10 @@
             refundStatus=OrderTotalConstants.STATUS_REFUND_PART;
         }
 
-        //鏇存柊瀛愬崟淇℃伅
-        updateOrderItemTwo(orderItemSon,refundStatus,refundRecordItemSource.getRefundMoney(),refundRecordItemSource.getRefundNum(),commonService);
-
         //澶勭悊閫�娆炬敮浠樻柟寮�
-        refundCarryVo = refundRecordMotnedItemTwoHandle(userProjectDeductionVo.getDeductionTotal(),refundRecord,refundRecordItemSource,refundCarryVo,commonService);
+        refundCarryVo = refundRecordMotnedItemTwoHandle(refundRecord,refundRecordItemSource,refundCarryVo,commonService);
+        //鏇存柊瀛愬崟淇℃伅
+        updateOrderItemTwo(orderItemSon,refundStatus,refundCarryVo,refundRecordItemSource.getRefundNum(),commonService);
 
         if(refundRecordItem.getType().equals(OrderItemConstants.CARD_BAG)){
             //鏄崱鍖呯殑锛屽埅闄ゅ崱鍖呬娇鐢�
@@ -1506,10 +1604,10 @@
             refundStatus=OrderTotalConstants.STATUS_REFUND_PART;
         }
 
-        updateOrderItemTwo(orderItemSon,refundStatus,refundRecordItemSource.getRefundMoney(),refundRecordItemSource.getRefundNum(),commonService);
-
         //澶勭悊閫�娆炬敮浠樻柟寮�
-        refundCarryVo = refundRecordMotnedItemTwoHandle(null,refundRecord,refundRecordItemSource,refundCarryVo,commonService);
+        refundCarryVo = refundRecordMotnedItemTwoHandle(refundRecord,refundRecordItemSource,refundCarryVo,commonService);
+
+        updateOrderItemTwo(orderItemSon,refundStatus,refundCarryVo,refundRecordItemSource.getRefundNum(),commonService);
 
         if(refundRecordItem.getType().equals(OrderItemConstants.CARD_BAG)){
             //鏄崱鍖呯殑锛屽埅闄ゅ崱鍖呬娇鐢�
@@ -1522,21 +1620,29 @@
     /**鏇存柊璁㈠崟涓�绾у瓙鍗曠殑淇℃伅
      * @param orderItem 璁㈠崟瀛愬崟
      * @param refundStatus 閫�娆剧姸鎬�
-     * @param refundTotal 閫�娆鹃噾棰濓紝姝h礋鏁�
+     * @param refundCarryVo 浼犲弬
      * @param refundNum 閫�娆炬暟閲� 姝h礋鏁�
      * @param commonService 鏄犲皠
      */
-    public static void updateOrderItemOne(OrderItem orderItem,Integer refundStatus,BigDecimal refundTotal,Integer refundNum
+    public static void updateOrderItemOne(OrderItem orderItem,Integer refundStatus,RefundCarryVo refundCarryVo,Integer refundNum
             ,CommonService commonService){
         SqlSentence sqlSentence = new SqlSentence();
         Map<String,Object> values = new HashMap<>();
 
         values.put("id", orderItem.getId());
         values.put("refundStatus", refundStatus);
-        values.put("refundTotal",refundTotal);
-        values.put("refundNum",refundNum);
         values.put("oldHasReNum",orderItem.getHasReNum());
+        values.put("refundNum",refundNum);
+        values.put("refundTotal",refundCarryVo.getRefundTotal());
+        values.put("reIntegralTotal",refundCarryVo.getIntegralTotal());
+        values.put("reCashTotal",refundCarryVo.getCashTotal());
+        values.put("reCashPurenessTotal",refundCarryVo.getCashPurenessTotal());
+        values.put("reRechargeTotal",refundCarryVo.getRechargeTotal());
+        values.put("reIncrementTotal",refundCarryVo.getIncrementTotal());
         sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" +
+                ",reIntegralTotal = reIntegralTotal+#{m.reIntegralTotal},reCashTotal = reCashTotal+#{m.reCashTotal}" +
+                ",reCashPurenessTotal = reCashPurenessTotal+#{m.reCashPurenessTotal},reRechargeTotal = reRechargeTotal+#{m.reRechargeTotal}" +
+                ",reIncrementTotal = reIncrementTotal+#{m.reIncrementTotal}" +
                 " 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]锛�");
@@ -1546,21 +1652,29 @@
     /**鏇存柊璁㈠崟浜岀骇瀛愬崟鐨勪俊鎭�
      * @param orderItemSon 璁㈠崟瀛愬崟
      * @param refundStatus 閫�娆剧姸鎬�
-     * @param refundTotal 閫�娆鹃噾棰�
+     * @param refundCarryVo 浼犲弬
      * @param refundNum 閫�娆炬暟閲�
      * @param commonService 鏄犲皠
      */
-    public static void updateOrderItemTwo(OrderItemSon orderItemSon,Integer refundStatus,BigDecimal refundTotal,Integer refundNum
+    public static void updateOrderItemTwo(OrderItemSon orderItemSon,Integer refundStatus,RefundCarryVo refundCarryVo,Integer refundNum
             ,CommonService commonService){
         SqlSentence sqlSentence = new SqlSentence();
         Map<String,Object> values = new HashMap<>();
 
         values.put("id", orderItemSon.getId());
         values.put("refundStatus", refundStatus);
-        values.put("refundTotal",refundTotal);
-        values.put("refundNum",refundNum);
         values.put("oldHasReNum",orderItemSon.getHasReNum());
+        values.put("refundTotal",refundCarryVo.getRefundTotal());
+        values.put("refundNum",refundNum);
+        values.put("reIntegralTotal",refundCarryVo.getIntegralTotal());
+        values.put("reCashTotal",refundCarryVo.getCashTotal());
+        values.put("reCashPurenessTotal",refundCarryVo.getCashPurenessTotal());
+        values.put("reRechargeTotal",refundCarryVo.getRechargeTotal());
+        values.put("reIncrementTotal",refundCarryVo.getIncrementTotal());
         sqlSentence.sqlUpdate(" refundStatus = #{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" +
+                ",reIntegralTotal = reIntegralTotal+#{m.reIntegralTotal},reCashTotal = reCashTotal+#{m.reCashTotal}" +
+                ",reCashPurenessTotal = reCashPurenessTotal+#{m.reCashPurenessTotal},reRechargeTotal = reRechargeTotal+#{m.reRechargeTotal}" +
+                ",reIncrementTotal = reIncrementTotal+#{m.reIncrementTotal}" +
                 " 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]锛�");

--
Gitblit v1.8.0