|
@@ -1,22 +1,32 @@
|
|
|
package com.kym.miniapp.controller;
|
|
package com.kym.miniapp.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.XmlUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.kym.common.R;
|
|
import com.kym.common.R;
|
|
|
import com.kym.common.annotation.ApiLog;
|
|
import com.kym.common.annotation.ApiLog;
|
|
|
import com.kym.service.wechat.WxPayService;
|
|
import com.kym.service.wechat.WxPayService;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+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.ResponseBody;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author skyline
|
|
* @author skyline
|
|
|
* @description
|
|
* @description
|
|
|
* @date 2023-07-22 20:36
|
|
* @date 2023-07-22 20:36
|
|
|
*/
|
|
*/
|
|
|
-@RestController
|
|
|
|
|
@RequestMapping("/payment")
|
|
@RequestMapping("/payment")
|
|
|
public class PaymentController {
|
|
public class PaymentController {
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(PaymentController.class);
|
|
|
|
|
|
|
|
private final WxPayService wxPayService;
|
|
private final WxPayService wxPayService;
|
|
|
|
|
|
|
@@ -34,9 +44,20 @@ public class PaymentController {
|
|
|
@ApiLog(value = "微信回调", ignoreParams = true)
|
|
@ApiLog(value = "微信回调", ignoreParams = true)
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@PostMapping("/notify")
|
|
@PostMapping("/notify")
|
|
|
- @ResponseBody
|
|
|
|
|
- ResponseEntity.BodyBuilder notify(HttpServletRequest request) {
|
|
|
|
|
- return wxPayService.wxNotify(request);
|
|
|
|
|
|
|
+ String notify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ response.setContentType("text/xml");
|
|
|
|
|
+ Map<String,String> result = new HashMap<>();
|
|
|
|
|
+ try {
|
|
|
|
|
+ wxPayService.wxNotify(request);
|
|
|
|
|
+ result.put("return_code","SUCCESS");
|
|
|
|
|
+ result.put("return_msg","OK");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ result.put("return_code","FAIL");
|
|
|
|
|
+ result.put("return_msg",e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ String resp = XmlUtil.mapToXmlStr(result);
|
|
|
|
|
+ logger.info("wxpay notify result>>>:{}",resp);
|
|
|
|
|
+ return resp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|