Procházet zdrojové kódy

fix 支付时,校验订单状态

zoujiajian před 3 roky
rodič
revize
827c06fa91

+ 21 - 1
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -81,7 +81,13 @@ public class OrderController {
     public Result<H5JsPayParams> pay(@PathVariable Long orderId) throws Exception {
         final String methodName = "吊起微信支付";
         log.info("{}[start] orderId:{}",methodName,orderId);
-
+        OrderDon orderDon = orderDonService.getById(orderId);
+        if (orderDon == null) {
+            throw BusinessRuntimeException.getInstance("订单不存在");
+        }
+        if (orderDon.getStatus() == OrderDon.Status.close) {
+            throw BusinessRuntimeException.getInstance("订单已关闭");
+        }
         H5JsPayParams payParams = orderDonService.pay(orderId, "JSAPI");
 
         return GatewayResponse.SUCCESS.newBuilder().toResult(payParams);
@@ -93,6 +99,13 @@ public class OrderController {
      */
     @PostMapping("/get/wx/orderQrCode/{orderId}")
     public Result<String> createUnifiedOrderQr(@PathVariable Long orderId) throws Exception {
+        OrderDon orderDon = orderDonService.getById(orderId);
+        if (orderDon == null) {
+            throw BusinessRuntimeException.getInstance("订单不存在");
+        }
+        if (orderDon.getStatus() == OrderDon.Status.close) {
+            throw BusinessRuntimeException.getInstance("订单已关闭");
+        }
         //预下单
         H5JsPayParams payParams = orderDonService.wxPcWebPay(orderId, "NATIVE");
         //获取二维码链接code_url
@@ -175,6 +188,13 @@ public class OrderController {
 	@PostMapping("/post/pay/zfb/{orderId}")
     @Deprecated
 	public Result<String> aliPay(@PathVariable Long orderId,HttpServletResponse response) throws Exception {
+        OrderDon orderDon = orderDonService.getById(orderId);
+        if (orderDon == null) {
+            throw BusinessRuntimeException.getInstance("订单不存在");
+        }
+        if (orderDon.getStatus() == OrderDon.Status.close) {
+            throw BusinessRuntimeException.getInstance("订单已关闭");
+        }
         AliPayParams aliPayParams = orderDonService.aliPay(orderId, ZfbProductCode.MOBILE_WEB.getProductCode());
 //        response.setContentType("text/html;charset=" + BaseZfbConfig.charset);
 //        //直接将完整的表单html输出到页面