From f72f73a11138a79b0e79a345c3c2bb1a08f4d610 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期二, 04 四月 2023 10:35:33 +0800
Subject: [PATCH] 退款-订单状态变化优化

---
 phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

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 c14e2a6..9a5f906 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
@@ -135,6 +135,10 @@
         sqlSentence.sqlSentence("select * from order_item WHERE  orderId=#{m.orderId} and isDel=0",values);
         List<OrderItem> orderItemList=commonService.selectList(OrderItemMapper.class,sqlSentence);
 
+        values.clear();
+        values.put("oldStatus",ordersTotal.getStatus());
+        values.put("oldRefundStatus",ordersTotal.getRefundStatus());
+
         List<Integer> collect = orderItemList.stream().map(OrderItem::getRefundStatus).collect(Collectors.toList());
         if(collect.contains(OrderTotalConstants.STATUS_REFUND_PART)){
             ordersTotal.setRefundStatus(OrderTotalConstants.STATUS_REFUND_PART);
@@ -152,16 +156,28 @@
             if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
                 if(ordersTotal.getActualTotal().compareTo(refundRecord.getRefundTotal()) <= 0){
                     ordersTotal.setRefundStatus(OrderTotalConstants.STATUS_REFUND_FINSH);
+                    ordersTotal.setStatus(OrderTotalConstants.STATUS_CANCEL);
+                    ordersTotal.setReTotal(ordersTotal.getReTotal().add(refundRecord.getRefundTotal()));
                 }else{
                     ordersTotal.setRefundStatus(OrderTotalConstants.STATUS_REFUND_PART);
+                    ordersTotal.setReTotal(ordersTotal.getReTotal().add(refundRecord.getRefundTotal()));
                 }
             }else{
                 ordersTotal.setRefundStatus(OrderTotalConstants.STATUS_REFUND_NONE);
             }
         }
         ordersTotal.setIsSyncOrder(BaseEntity.NO);
-        ordersTotal.setEditTime(new Date());
-        commonService.updateAll(OrdersTotalMapper.class,ordersTotal);
+
+        values.put("isSyncOrder",BaseEntity.NO);
+        values.put("status",ordersTotal.getStatus());
+        values.put("refundStatus",ordersTotal.getRefundStatus());
+        values.put("reTotal",ordersTotal.getReTotal());
+        values.put("id",ordersTotal.getId());
+        sqlSentence.sqlUpdate("isSyncOrder = #{m.isSyncOrder},status = #{m.status},refundStatus = #{m.refundStatus},reTotal = #{m.reTotal}" +
+                " WHERE id = #{m.id} AND status = #{m.oldStatus} AND refundStatus = #{m.oldRefundStatus}",values);
+        if(commonService.updateWhere(OrdersTotalMapper.class,sqlSentence) != 1){
+            throw new TipsException("鎿嶄綔澶辫触锛岃鍗曠姸鎬佸凡鍙戠敓鏀瑰彉锛�");
+        }
         return ordersTotal;
     }
 

--
Gitblit v1.8.0