From b69c81718237d87ead2aa61d8f808b53e6a09b58 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 29 Mar 2023 09:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/web/controller/OrderPayController.java | 5 +++++ hai-service/src/main/java/com/hai/common/utils/DateUtil.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index 9183bc9c..fd948f14 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -42,6 +42,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.SortedMap; @@ -122,6 +123,10 @@ public class OrderPayController { log.error("wxPay ERROR", "订单不处于待支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); } + if (DateUtil.getSecondDiff(order.getCreateTime(), DateUtil.addDate(order.getCreateTime(), 10)) < 10) { + log.error("wxPay ERROR", "订单待支付时间小于10秒,请重新下单支付"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单待支付时间小于10秒,请重新下单支付"); + } Integer openIdType = body.getInteger("openIdType"); // 是否分账 diff --git a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java index cbc578f6..a1ef0be8 100644 --- a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java +++ b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java @@ -413,7 +413,7 @@ public class DateUtil { * @return: java.util.Date * @throws */ - public static Date addDate(Date date,int day) throws ParseException { + public static Date addDate(Date date,int day) { long time = date.getTime(); // 得到指定日期的毫秒数 long longTime = (long)day; long addDay = longTime*24*60*60*1000; // 要加上的天数转换成毫秒数 @@ -577,7 +577,7 @@ public class DateUtil { * @return: int * @throws */ - public static long getMinutesDiff(Date oldTime, Date newTime) throws Exception{ + public static long getMinutesDiff(Date oldTime, Date newTime) { long oldTimeStamp = oldTime.getTime(); long newTimeStamp = newTime.getTime();