From 572df690f72ed4a077d934823f261dec39b3cc7d Mon Sep 17 00:00:00 2001
From: 刘帅 <rr.iii@qq.com>
Date: 星期二, 08 九月 2026 17:11:34 +0800
Subject: [PATCH] feat&bug:文档内容修改

---
 cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java |   39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
index 0f53331..4a0f1d5 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -124,13 +124,37 @@
 
     @RequestMapping("/base/pointMerchars/writeOff")
     public Object writeOff(@RequestBody WriteOffDTO dto) {
-        UserPointsMerchandise byId = userPointsMerchandiseService.getById(dto.getId());
-        byId.setStoreId(dto.getVerifiStoreId());
-        byId.setStatus(2);
-        byId.setVerificationTime(new Date());
-        byId.setUserId(null);
-        byId.setVerificationUserId(dto.getVerificationUserId());
-        return userPointsMerchandiseService.updateById(byId);
+        if (dto == null || dto.getId() == null) {
+            throw new IllegalArgumentException("门票记录不能为空");
+        }
+        if (!Integer.valueOf(1).equals(dto.getGoType()) && !Integer.valueOf(2).equals(dto.getGoType())) {
+            throw new IllegalArgumentException("入园方式参数不正确");
+        }
+
+        UserPointsMerchandise ticket = userPointsMerchandiseService.getById(dto.getId());
+        if (ticket == null) {
+            throw new IllegalArgumentException("门票记录不存在");
+        }
+        if (!Integer.valueOf(1).equals(ticket.getStatus())) {
+            throw new IllegalStateException("该门票已核销");
+        }
+
+        // 以待核销状态作为更新条件,避免并发请求重复核销同一张门票。
+        UserPointsMerchandise updatedTicket = new UserPointsMerchandise();
+        updatedTicket.setId(ticket.getId());
+        updatedTicket.setVerifiStoreId(dto.getVerifiStoreId());
+        updatedTicket.setStatus(2);
+        updatedTicket.setVerificationTime(new Date());
+        updatedTicket.setVerificationUserId(dto.getVerificationUserId());
+        updatedTicket.setGoType(dto.getGoType());
+        boolean updated = userPointsMerchandiseService.update(updatedTicket,
+                new LambdaQueryWrapper<UserPointsMerchandise>()
+                        .eq(UserPointsMerchandise::getId, ticket.getId())
+                        .eq(UserPointsMerchandise::getStatus, 1));
+        if (!updated) {
+            throw new IllegalStateException("该门票已核销");
+        }
+        return true;
     }
 
     @Autowired
@@ -1779,6 +1803,7 @@
                 map.put("id", pointsMerchandise.getId());
                 map.put("userId", pointsMerchandise.getUserId());
                 map.put("status", pointsMerchandise.getStatus());
+                map.put("goType", pointsMerchandise.getGoType());
                 map.put("payTime", sdf.format(pointsMerchandise.getPaymentTime()));
                 map.put("orderNumber", pointsMerchandise.getOrderNumber());
                 mapList.add(map);

--
Gitblit v1.7.1