| @@ -26,7 +26,10 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.BufferedReader; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -154,10 +157,13 @@ public class CallbackPayController extends BaseController { | |||||
| String biz_content = request.getParameter("biz_content"); | String biz_content = request.getParameter("biz_content"); | ||||
| logger.info("ali支付回调结果通知{}notify_id="+notify_id+",app_id="+app_id+",biz_content="+biz_content); | logger.info("ali支付回调结果通知{}notify_id="+notify_id+",app_id="+app_id+",biz_content="+biz_content); | ||||
| Map<String,Object> resultMap = new HashMap<>(); | Map<String,Object> resultMap = new HashMap<>(); | ||||
| /** | /** | ||||
| * ----效验数据来源合法 | * ----效验数据来源合法 | ||||
| */ | */ | ||||
| try{ | try{ | ||||
| String body = this.getBody(request); | |||||
| logger.info("ali支付回调结果通知---body{}"+body); | |||||
| // String msg = (String) paranMap.get("msg"); | // String msg = (String) paranMap.get("msg"); | ||||
| // String type = (String) paranMap.get("type"); | // String type = (String) paranMap.get("type"); | ||||
| // | // | ||||
| @@ -185,4 +191,36 @@ public class CallbackPayController extends BaseController { | |||||
| return resultMap; | return resultMap; | ||||
| } | } | ||||
| private String getBody(HttpServletRequest request) throws IOException { | |||||
| StringBuilder stringBuilder = new StringBuilder(); | |||||
| BufferedReader bufferedReader = null; | |||||
| try { | |||||
| InputStream inputStream = request.getInputStream(); | |||||
| if (inputStream != null) { | |||||
| bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); | |||||
| char[] charBuffer = new char[1024]; | |||||
| int bytesRead = -1; | |||||
| while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { | |||||
| stringBuilder.append(charBuffer, 0, bytesRead); | |||||
| } | |||||
| } else { | |||||
| stringBuilder.append(""); | |||||
| } | |||||
| } catch ( | |||||
| IOException ex) { | |||||
| throw ex; | |||||
| } finally { | |||||
| if (bufferedReader != null) { | |||||
| try { | |||||
| bufferedReader.close(); | |||||
| } catch (IOException ex) { | |||||
| throw ex; | |||||
| } | |||||
| } | |||||
| } | |||||
| return stringBuilder.toString(); | |||||
| } | |||||
| } | } | ||||