From d45f3f7467e76477e8babbefd5844975bdff7af1 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 28 十一月 2024 15:45:58 +0800
Subject: [PATCH] 修改bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
index ebdead0..a3e2d80 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -4,6 +4,7 @@
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.google.api.client.http.UrlEncodedParser;
+import com.stylefeng.guns.core.util.MD5Util;
 import com.stylefeng.guns.core.util.ToolUtil;
 import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
 import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
@@ -31,6 +32,8 @@
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.http.client.utils.URLEncodedUtils;
 import org.bouncycastle.util.encoders.UrlBase64Encoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.StringUtils;
@@ -55,6 +58,8 @@
 @RestController
 @RequestMapping("")
 public class OrderController {
+    
+    private Logger log = LoggerFactory.getLogger(OrderController.class);
 
     @Autowired
     private IOrderTaxiService orderTaxiService;
@@ -1040,6 +1045,13 @@
             if(null == uid){
                 return ResultUtil.tokenErr();
             }
+            String format = String.format("uid=%s&id=%s&orderType=%s&payType=%s&type=%s", uid, id, orderType, payType, type);
+            String key = MD5Util.encrypt(format);
+            String value = redisUtil.getValue(key);
+            if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){
+                return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération");
+            }
+            redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5);
             switch (orderType){
                 case 1:
                     return orderPrivateCarService.cancleOrderPrivateCar(id, payType, bankCardId, cancleId, type, language);
@@ -1261,6 +1273,14 @@
             if(null == uid){
                 return ResultUtil.tokenErr();
             }
+            String format = String.format("uid=%s&payType=%s&orderId=%s&orderType=%s", uid, payType, orderId, orderType);
+            String key = MD5Util.encrypt(format);
+            String value = redisUtil.getValue(key);
+            if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){
+                return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération");
+            }
+            redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5);
+    
             switch (orderType){
                 case 1:
                     return orderPrivateCarService.payPrivateCarOrder(payType, bankCardId, orderId, couponId, redDeduction, type, language);
@@ -1413,6 +1433,7 @@
     @ResponseBody
     @PostMapping("/base/wxCancelOrderTaxi")
     public CallbackResponse wxCancelOrderTaxi(@RequestBody CallbackRequest callbackRequest){
+        log.info("取消订单支付回调结果:{}", JSON.toJSONString(callbackRequest));
         CallbackResponse callbackResponse = new CallbackResponse();
         try {
             /**
@@ -1464,6 +1485,7 @@
         }catch (Exception e){
             e.printStackTrace();
         }
+        log.info("取消订单支付回调处理结束:{}", JSON.toJSONString(callbackResponse));
         return callbackResponse;
     }
 
@@ -1515,6 +1537,7 @@
     @ResponseBody
     @PostMapping("/base/wxPayOrderTaxi")
     public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){
+        log.info("订单完成支付回调结果:{}", JSON.toJSONString(callbackRequest));
         CallbackResponse callbackResponse = new CallbackResponse();
         try {
             /**
@@ -1569,6 +1592,7 @@
         }catch (Exception e){
             e.printStackTrace();
         }
+        log.info("订单完成支付回调处理结束:{}", JSON.toJSONString(callbackResponse));
         return callbackResponse;
     }
 
@@ -1835,6 +1859,7 @@
             }
             String randomCode = UUIDUtil.getRandomCode();
             redisUtil.setStrValue("trip" + uid, randomCode);
+            log.warn("生成tripId:{}   {}", System.currentTimeMillis(), randomCode);
             return ResultUtil.success(randomCode);
         }catch (Exception e){
             e.printStackTrace();

--
Gitblit v1.7.1