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/PartialRefundUtil.java |   48 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 3 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 4f70c87..25d96b7 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
@@ -915,7 +915,7 @@
             return;
         }
         //璁㈠崟鍙栨秷鐘舵�佹墠澶勭悊
-        if(ordersTotal.getStatus() != OrderTotalConstants.STATUS_CANCEL){
+        if(ordersTotal.getRefundStatus() != OrderTotalConstants.STATUS_REFUND_FINSH){
             return;
         }
 
@@ -925,20 +925,40 @@
         if(userMoneyUnclaimed == null){
             return;
         }
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+
+        //-----鐢熸垚涓�鏉¤褰曪紝鍙互鍥炴函
+        RefundUserAssets refundUserAssets;
+        //鐢熸垚璁板綍
+        refundUserAssets = new RefundUserAssets();
+        //璁剧疆鏈�102鏄綋鍓嶇殑璁板綍绫诲瀷
+        refundUserAssets.setIsDel(102);
+        refundUserAssets.setType(userMoneyUnclaimed.getOperationReason());
+        refundUserAssets.setStatus(RefundUserAssets.STATUS_NORMAL);
+        refundUserAssets.setAmountType(userMoneyUnclaimed.getFundType());
+        refundUserAssets.setAmount(userMoneyUnclaimed.getOpNumber().negate());
+        refundUserAssets.setOperatorId(refundRecord.getOperatorId());
+        refundUserAssets.setOperatorNo(refundRecord.getOperatorNo());
+        refundUserAssets.setOperatorName(refundRecord.getOperatorName());
+        refundUserAssets.setOrderId(refundRecord.getOrderId());
+        refundUserAssets.setRefundRecordId(refundRecord.getId());
+        refundUserAssets.setUserMoneyUnclaimedId(userMoneyUnclaimed.getId());
+        refundUserAssets.setUserId(userMoneyUnclaimed.getUserId());
 
         if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){
             //宸查鍙栵紝閭d箞灏辨墸鍥炴潵
             if(userMoneyUnclaimed.getOpNumber().compareTo(BigDecimal.ZERO) < 1){
                 return;
             }
+            refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NORMAL);
             UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(),UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber().negate(),BaseEntity.NO,OperationReasonConstants.OP_REASON_INVITE_ORDER_CANCEL,"濂藉弸璁㈠崟閫�娆�-娲诲姩璧犻�佹墸闄"+ordersTotal.getOrderNo()+"]","鎿嶄綔鍘熷洜:閫�娆惧鏍搁�氳繃锛屾椿鍔ㄨ禒閫佹墸闄よ祫閲戯紝閫�娆炬柟寮�:閫�鍥炲鍊奸噾",ordersTotal.getOperatorId()
                     ,ordersTotal.getId(),ordersTotal.getActivityPageCode(),null,commonService);
         }else{
             if(!UserMoneyUnclaimed.YES.equals(userMoneyUnclaimed.getIsValid())){
                return;
             }
-            SqlSentence sqlSentence = new SqlSentence();
-            Map<String,Object> values = new HashMap<>();
+            refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NOT_RECEIVE);
             //娌℃湁棰嗗彇灏变綔搴�
             values.put("id",userMoneyUnclaimed.getId());
             values.put("isValid",UserMoneyUnclaimed.NO);
@@ -949,6 +969,28 @@
                 activityPageGiveIncrease(ordersTotal,refundRecord,operationId,circulateNum,commonService);
             }
         }
+        //淇濆瓨璁板綍锛屾甯告墸鍑忓拰鏈鍙栨墠鍘讳繚瀛樿繖涓褰�
+        commonService.insert(RefundUserAssetsMapper.class,refundUserAssets);
+
+        //鏌ョ湅鏄惁鏈夌浜屽紶璁㈠崟绗﹀悎
+        values.clear();
+        values.put("status",OrderTotalConstants.STATUS_CANCEL);
+        values.put("payStatus",OrderTotalConstants.PAY_STATUS_SUC);
+        values.put("id",ordersTotal.getId());
+        values.put("activityPageType",ordersTotal.getActivityPageType());
+        values.put("activityPageCode",ordersTotal.getActivityPageCode());
+        sqlSentence.sqlSentence("SELECT * FROM orders_total WHERE isDel = 0 AND status != #{m.status} AND payStatus = #{m.payStatus}" +
+                " AND id != #{m.id} AND activityPageType = #{m.activityPageType} AND activityPageCode = #{m.activityPageCode} ORDER BY createTime ASC LIMIT 1",values);
+        OrdersTotal ordersTotal1 = commonService.selectOne(OrdersTotalMapper.class,sqlSentence);
+        if(ordersTotal1 != null){
+            Integer opType = BaseEntity.NO;
+            if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){
+                opType = BaseEntity.YES;
+            }
+            //澧炲�奸噾鍒拌处澶勭悊
+            UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber(),opType, OperationReasonConstants.OP_REASON_INVITE_ORDER,userMoneyUnclaimed.getOriginSubject(),userMoneyUnclaimed.getRemarks(),userMoneyUnclaimed.getOperatorId()
+                    ,ordersTotal1.getId(),ordersTotal.getActivityPageCode(),userMoneyUnclaimed.getMoneyRuleId(),commonService);
+        }
 
     }
 

--
Gitblit v1.8.0