|
@@ -0,0 +1,61 @@
|
|
|
+package com.llisoft.service.pay.controller;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+@Api(tags="微信支付回调")
|
|
|
+@Controller
|
|
|
+@RequestMapping("/wxpay")
|
|
|
+public class WxPayController {
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(WxPayController.class);
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="同步回调")
|
|
|
+ @GetMapping("/return")
|
|
|
+ public String retur(HttpServletRequest request) {
|
|
|
+ Map<String, String> resultMap = this.getParamMap(request);
|
|
|
+ logger.info("收到微信同步回调: {}", resultMap);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="异步通知")
|
|
|
+ @PostMapping(value="/notify")
|
|
|
+ public @ResponseBody String notify(HttpServletRequest request) {
|
|
|
+ Map<String, String> resultMap = this.getParamMap(request);
|
|
|
+ logger.info("收到微信异步通知: {}", resultMap);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取参数Map<String, String>
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, String> getParamMap(HttpServletRequest request){
|
|
|
+ Map<String, String> returnMap = new HashMap<String, String>();
|
|
|
+ Map<String, String[]> paramMap = request.getParameterMap();
|
|
|
+ for (String key: paramMap.keySet()) {
|
|
|
+ String[] values = paramMap.get(key);
|
|
|
+ if (values!=null && values.length>0) {
|
|
|
+ returnMap.put(key, values[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|