From fb2f11d7d502ceacbe7fbed176bea4ab0f152f69 Mon Sep 17 00:00:00 2001
From: liulin <lin.liu@88.com>
Date: 星期四, 03 七月 2025 18:17:59 +0800
Subject: [PATCH] 添加mqtt

---
 src/main/java/com/lunhan/water/service/PaymentServices.java |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/lunhan/water/service/PaymentServices.java b/src/main/java/com/lunhan/water/service/PaymentServices.java
index 1452abd..3e3a839 100644
--- a/src/main/java/com/lunhan/water/service/PaymentServices.java
+++ b/src/main/java/com/lunhan/water/service/PaymentServices.java
@@ -23,6 +23,7 @@
 import com.lunhan.water.repository.po.*;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -55,7 +56,8 @@
     private UserCapitalChangeMapperImpl capitalChangeDao;
     @Autowired
     private TradeRecordMapperImpl tradeRecordDao;
-
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
 
 
     /**
@@ -66,6 +68,14 @@
      */
     @Transactional(rollbackFor = Exception.class)
     public ExecutedResult<Map<String, Object>> weiXinPay(LoginUserDTO loginUser, ReqCreatePay request) {
+        //判断token是否存在,如果不存在,说明重复提交订单
+        String redisToken = redisTemplate.opsForValue().get(request.getPayToken()).toString();
+        if (StringUtil.isNullOrEmpty(redisToken)) {
+            throw new RuntimeException("请勿重复提交充值订单!");
+        }
+        //删除token
+        redisTemplate.delete(request.getPayToken());
+
         EBusinessType type = EBusinessType.getByValue(request.getBusinessType());
         if (Objects.isNull(type)) {
             return ExecutedResult.failed("业务不支持." + request.getBusinessType());

--
Gitblit v1.9.3