From c19fd2da97b631cc720f039967760da475887554 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 01 七月 2025 14:34:01 +0800
Subject: [PATCH] 二手新增迭代

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WithdrawController.java |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WithdrawController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WithdrawController.java
index 054aa57..89a8fe0 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WithdrawController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WithdrawController.java
@@ -324,15 +324,23 @@
     @GetMapping("/confirmMoney")
 
     R<String> confirmWithdraw(@RequestParam("id")String id){
-        Withdraw withdraw = withdrawService.getById(id);
-        WithdrawRecord withdrawRecord = new WithdrawRecord();
-        withdrawRecord.setWithdrawId(withdraw.getId());
-        withdrawRecord.setOrderId(withdraw.getOrderId());
-        withdrawRecord.setUserId(withdraw.getUserId());
-        withdrawRecord.setWithdrawType(3);
-        withdrawRecord.setCreateTime(new Date());
-        withdrawRecord.setAuditStatus(1);
-        withdrawRecordService.save(withdrawRecord);
+        Order order = orderService.getById(id);
+        Withdraw withdraw = withdrawService.lambdaQuery()
+                .eq(Withdraw::getOrderId,order.getId()).last("limit 1")
+                .one();
+        List<WithdrawRecord> list = withdrawRecordService.lambdaQuery().eq(WithdrawRecord::getWithdrawId, withdraw.getId())
+                .eq(WithdrawRecord::getWithdrawType, 3).list();
+        if (list.isEmpty()){
+            WithdrawRecord withdrawRecord = new WithdrawRecord();
+            withdrawRecord.setWithdrawId(withdraw.getId());
+            withdrawRecord.setOrderId(withdraw.getOrderId());
+            withdrawRecord.setUserId(withdraw.getUserId());
+            withdrawRecord.setWithdrawType(3);
+            withdrawRecord.setCreateTime(new Date());
+            withdrawRecord.setAuditStatus(1);
+            withdrawRecordService.save(withdrawRecord);
+        }
+
         return R.ok();
     }
     @GetMapping("/withdrawDetailByUser")
@@ -374,16 +382,17 @@
         if (null != withdraw) {
             withdrawDetailVO.setWithdrawalState(withdraw.getState());
             withdrawDetailVO.setWithdrawalTime(withdraw.getCreateTime());
+            List<WithdrawRecord> list = withdrawRecordService.lambdaQuery().eq(WithdrawRecord::getOrderId, orderId)
+                    .eq(WithdrawRecord::getWithdrawId, withdraw.getId())
+                    .eq(WithdrawRecord::getUserId, withdraw.getUserId()).list();
+            withdrawDetailVO.setWithdrawRecords(list);
         }
         withdrawDetailVO.setPackageInfo(order.getPackageInfo());
         withdrawDetailVO.setAddress(order.getAddress());
         if (null != serveRecord) {
             withdrawDetailVO.setPhoto(serveRecord.getPhoto());
         }
-        List<WithdrawRecord> list = withdrawRecordService.lambdaQuery().eq(WithdrawRecord::getOrderId, orderId)
-                .eq(WithdrawRecord::getWithdrawId, withdraw.getId())
-                .eq(WithdrawRecord::getUserId, withdraw.getUserId()).list();
-        withdrawDetailVO.setWithdrawRecords(list);
+
         return R.ok(withdrawDetailVO);
     }
 

--
Gitblit v1.7.1