From 9dc0e46c76f466ac02ddeb790b1dac836b663b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Thu, 10 Oct 2024 10:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A0Token=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=AE=A2=E5=8D=95=E7=AE=80=E8=A6=81=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PayController.java | 27 +++++++++++++++---- .../interceptor/SignInterceptor.java | 8 +++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java index b5e7178..aa4445f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java @@ -8,12 +8,12 @@ import com.alipay.api.AlipayClient; import com.alipay.api.AlipayConfig; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.request.AlipaySystemOauthTokenRequest; -import com.alipay.api.request.AlipayUserInfoShareRequest; import com.alipay.api.response.AlipaySystemOauthTokenResponse; -import com.alipay.api.response.AlipayUserInfoShareResponse; import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit; +import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper; import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO; @@ -24,11 +24,9 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.IpUtil; import com.chaozhanggui.system.cashierservice.util.JSONUtil; -import com.chaozhanggui.system.cashierservice.util.RedisCst; import com.chaozhanggui.system.cashierservice.util.WechatUtil; import com.fasterxml.jackson.core.JsonProcessingException; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -52,7 +50,9 @@ public class PayController { private ShopInfoService shopInfoService; @Autowired - TbShopInfoMapper tbShopInfoMapper; + private TbShopInfoMapper tbShopInfoMapper; + @Autowired + private TbOrderInfoMapper tbOrderInfoMapper; @RequestMapping("queryPayType") public Result queryPayType(@RequestHeader("token") String token, @@ -306,6 +306,23 @@ public class PayController { return payService.queryOrderPay(orderId); } + @GetMapping("/noToken/queryOrderInfo") + public Result noTokenQueryOrderInfo(String orderId) { + if(StrUtil.isBlank(orderId)){ + return Result.fail("订单id不能为空"); + } + TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId)); + if(orderInfo == null){ + return Result.fail("订单不存在"); + } + Map data = new HashMap<>(4); + data.put("id", orderInfo.getId()); + data.put("orderNo", orderInfo.getOrderNo()); + data.put("payAmount", orderInfo.getPayAmount()); + data.put("orderAmount", orderInfo.getOrderAmount()); + return Result.success(CodeEnum.SUCCESS, data); + } + @Value("${wx.ysk.appId}") private String appId; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java index acf8bf3..91d41a3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java @@ -9,17 +9,13 @@ import com.chaozhanggui.system.cashierservice.util.*; 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.http.HttpMethod; import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; @Component @@ -49,6 +45,10 @@ public class SignInterceptor implements HandlerInterceptor { return true; } + if (requestUri.contains("/pay/noToken/queryOrderInfo")) { + return true; + } + String token=request.getHeader("token"); String loginName=request.getHeader("loginName"); String clientType=request.getHeader("clientType");