|
@@ -1,65 +1,71 @@
|
|
|
-package com.book.server.controller;
|
|
|
-
|
|
|
-import com.book.dao.VO.WxPayInfo;
|
|
|
-import com.book.dao.VO.WxPayRequest;
|
|
|
-import com.book.dao.cps.mapper.GoodsMapper;
|
|
|
-import com.book.server.utils.HttpUtils;
|
|
|
-import com.book.server.common.entity.Result;
|
|
|
-import com.book.server.common.entity.ResultCode;
|
|
|
-import com.book.server.service.WxPayService;
|
|
|
-import com.book.server.utils.NetworkUtil;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-/**
|
|
|
- * created in 2021/8/30
|
|
|
- * Project: book-store
|
|
|
- *
|
|
|
- * @author win7
|
|
|
- */
|
|
|
-@RestController
|
|
|
-@RequestMapping("/api/wxpay")
|
|
|
-@Slf4j
|
|
|
-public class WxPayController extends BaseController {
|
|
|
- @Autowired
|
|
|
- private WxPayService wxPayService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建订单
|
|
|
- *
|
|
|
- * @param wxPayRequest
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PostMapping("/createOrder")
|
|
|
- public Result<WxPayInfo> createOrder(@RequestBody WxPayRequest wxPayRequest, HttpServletRequest request) {
|
|
|
- String ip = null;
|
|
|
- try {
|
|
|
- ip = NetworkUtil.getIpAddress(request);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- wxPayRequest.setIp(ip);
|
|
|
- Result<WxPayInfo> success = Result.byObject(wxPayService.createOrder(wxPayRequest), ResultCode.ORDER_FAIL);
|
|
|
- return success;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/notify")
|
|
|
- public String PayNotify(HttpServletRequest request) {
|
|
|
- return wxPayService.PayNotify(request);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package com.book.server.controller;
|
|
|
+
|
|
|
+import com.book.dao.VO.WxPayInfo;
|
|
|
+import com.book.dao.VO.WxPayRequest;
|
|
|
+import com.book.dao.cps.mapper.GoodsMapper;
|
|
|
+import com.book.server.utils.HttpUtils;
|
|
|
+import com.book.server.common.entity.Result;
|
|
|
+import com.book.server.common.entity.ResultCode;
|
|
|
+import com.book.server.service.WxPayService;
|
|
|
+import com.book.server.utils.NetworkUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 支付
|
|
|
+ * created in 2021/8/30
|
|
|
+ * Project: book-store
|
|
|
+ *
|
|
|
+ * @author win7
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/wxpay")
|
|
|
+@Slf4j
|
|
|
+public class WxPayController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private WxPayService wxPayService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建订单
|
|
|
+ *
|
|
|
+ * @param wxPayRequest
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/createOrder")
|
|
|
+ public Result<WxPayInfo> createOrder(@RequestBody WxPayRequest wxPayRequest, HttpServletRequest request) {
|
|
|
+ String ip = null;
|
|
|
+ try {
|
|
|
+ ip = NetworkUtil.getIpAddress(request);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ wxPayRequest.setIp(ip);
|
|
|
+ Result<WxPayInfo> success = Result.byObject(wxPayService.createOrder(wxPayRequest), ResultCode.ORDER_FAIL);
|
|
|
+ return success;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通知
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/notify")
|
|
|
+ public String PayNotify(HttpServletRequest request) {
|
|
|
+ return wxPayService.PayNotify(request);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|