From cfedbfad423aa6fd758da748967122819b1787e2 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期五, 01 三月 2024 18:14:57 +0800
Subject: [PATCH] 爆款活动-退款处理

---
 phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java
index 80722a0..f1595d3 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java
@@ -22,6 +22,7 @@
 import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed;
 import com.hx.phip.dao.mapper.*;
 import com.hx.phip.service.order.impl.OrderRefundServiceImpl;
+import com.hx.phip.tool.order.OrderTool;
 import com.hx.phip.tool.user.UserCardTool;
 import com.hx.phip.tool.user.UserProjectTool;
 import com.hx.phip.util.api.UserMoneyUtil;
@@ -435,6 +436,58 @@
         }
     }
 
+    /**浣滃簾閫�娆�-鐖嗘娲诲姩璧犻�佸鐞�*/
+    public static void burstActivityHandle(StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){
+        //涓嶆槸鐖嗘娲诲姩
+        if(ordersTotal.getActivityPageType() != OrderTotalConstants.ACTIVITY_TYPE_BURST){
+            return;
+        }
+
+        //鏌ユ壘鏄惁澶勭悊浜嗚禒閫佺殑澧炲�奸噾
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+        values.put("isDel",102);
+        values.put("orderId",refundRecord.getOrderId());
+        sqlSentence.sqlSentence("SELECT * FROM refund_user_assets rua WHERE rua.isDel = #{m.isDel} AND rua.status = 1 AND rua.amountStatus IN(1,3) AND rua.orderId = #{m.orderId}",values);
+        List<RefundUserAssets> refundUserAssetsList = commonService.selectList(RefundUserAssetsMapper.class,sqlSentence);
+        if(refundUserAssetsList.size() == 0){
+            return;
+        }
+
+        for(RefundUserAssets refundUserAssets:refundUserAssetsList){
+            //鍒ゆ柇鏄惁宸茬粡瀛樺湪浜嗗埆鐨勮禒閫佽褰�
+            if(OrderTool.getActivityGive(refundUserAssets.getUserId(),ordersTotal.getActivityPageCode(),commonService).size() == 0){
+                //鏄惁鏈夋墸鍑忕敤鎴疯祫浜�
+                if(refundUserAssets.getAmountStatus() == RefundUserAssets.AMOUNT_STATUS_NORMAL){
+                    orderNodeBuilder.append("锛屾椿鍔ㄨ禒閫佸鍔犳垚鍔�");
+                    UserMoneyUtil.setNewUserMoneyUnclaimed(refundUserAssets.getUserId(),refundRecord.getRemarks(),"閫�娆句綔搴�:娲诲姩璧犻�佽祫閲戝洖閫�浣滃簾",refundUserAssets.getOperatorId()
+                            ,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundUserAssets.getId(),refundUserAssets.getAmount().negate(),refundUserAssets.getAmountType()
+                            ,OperationReasonConstants.OP_REASON_BRING_NEW_USER_GIFT_RETRU_CANCEL,commonService,UserMoneyUnclaimed.YES);
+                }else if(refundUserAssets.getAmountStatus() == RefundUserAssets.AMOUNT_STATUS_NOT_RECEIVE){
+                    //鐢ㄦ埛鏈鍙栬褰曪紝杩樺師
+                    orderNodeBuilder.append("锛屾椿鍔ㄨ禒閫佺敤鎴锋湭棰嗗彇锛屼綔搴熺殑棰嗗彇璁板綍杩樺師");
+                    values.clear();
+                    values.put("id",refundUserAssets.getUserMoneyUnclaimedId());
+                    values.put("status",UserMoneyUnclaimed.STATUS_WAI);
+                    sqlSentence.sqlUpdate("isDel = 0,isValid = 1 WHERE id = #{m.id} AND isDel = 1 AND isValid = 0 AND status = #{m.status}",values);
+                    if(commonService.updateWhere(UserMoneyUnclaimedMapper.class,sqlSentence) != 1){
+                        throw new TipsException("娲诲姩璧犻�佽祫浜ц褰曠姸鎬佸凡鍙樺寲[浣滃簾]锛�");
+                    }
+                }
+            }
+
+            //璁板綍浣滃簾
+            values.clear();
+            values.put("id",refundUserAssets.getId());
+            values.put("status",RefundUserAssets.STATUS_CANCEL);
+            values.put("oldStatus",RefundUserAssets.STATUS_NORMAL);
+            sqlSentence.sqlSentence("status = #{m.status} WHERE id = #{m.id} AND status = #{m.oldStatus}",values);
+            if(commonService.updateWhere(RefundUserAssetsMapper.class,sqlSentence) != 1){
+                throw new TipsException("娲诲姩璧犻�佽祫浜ч��娆捐褰曠姸鎬佸凡鍙樺寲[浣滃簾]锛�");
+            }
+        }
+    }
+
     /**閫�娆惧瓙椤瑰鐞�*/
     public static void refundRecordItemHandle(OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){
 

--
Gitblit v1.8.0