From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001
From: lee <4766465@qq.com>
Date: Wed, 18 Dec 2024 13:27:00 +0800
Subject: [PATCH] init

---
 yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java
new file mode 100644
index 0000000..d1a09cb
--- /dev/null
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
+ *
+ * https://www.mall4j.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+package com.yami.shop.api.controller;
+
+
+import com.yami.shop.bean.app.param.PayParam;
+import com.yami.shop.bean.enums.PayEntry;
+import com.yami.shop.bean.pay.PayInfoDto;
+import com.yami.shop.common.exception.YamiShopBindException;
+import com.yami.shop.common.response.ServerResponseEntity;
+import com.yami.shop.manager.impl.PayManager;
+import com.yami.shop.security.api.model.YamiUser;
+import com.yami.shop.security.api.util.SecurityUtils;
+import com.yami.shop.service.PayInfoService;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+/**
+ * @author LGH
+ */
+@RestController
+@RequestMapping("/p/order")
+@Tag(name = "订单支付接口")
+@AllArgsConstructor
+public class PayController {
+
+    private final PayInfoService payInfoService;
+    private final PayManager payManager;
+
+    @PostMapping("/pay")
+    @Operation(summary = "根据订单号进行支付" , description = "根据订单号进行支付")
+    @SneakyThrows
+    public ServerResponseEntity<?> pay(HttpServletResponse httpResponse, @Valid @RequestBody PayParam payParam) {
+        YamiUser user = SecurityUtils.getUser();
+        String userId = user.getUserId();
+        if (!user.getEnabled()) {
+            // 您已被禁用,不能购买,请联系平台客服
+            throw new YamiShopBindException("yami.order.pay.user.disable");
+        }
+        PayInfoDto payInfo = payInfoService.pay(userId, payParam);
+        payInfo.setBizUserId(user.getBizUserId());
+        payInfo.setPayType(payParam.getPayType());
+        payInfo.setApiNoticeUrl("/notice/pay/" + PayEntry.ORDER.value() + "/" + payParam.getPayType());
+        payInfo.setReturnUrl(payParam.getReturnUrl());
+        return payManager.doPay(httpResponse, payInfo);
+    }
+
+    @GetMapping("/isPay/{payEntry}/{orderNumbers}")
+    @Operation(summary = "根据订单号查询该订单是否已经支付" , description = "根据订单号查询该订单是否已经支付")
+    @Parameter(name = "orderNumbers", description = "多个订单号拼接" , required = true)
+    public ServerResponseEntity<Boolean> isPay(@PathVariable Integer payEntry, @PathVariable String orderNumbers) {
+        YamiUser user = SecurityUtils.getUser();
+        Integer count = payInfoService.queryPay(orderNumbers, user.getUserId(), payEntry);
+        boolean res = count != null && count == 1;
+        return ServerResponseEntity.success(res);
+    }
+}

--
Gitblit v1.9.3