/** * 支付宝异步请求通知 * * @param request * @return */@RequestMapping(value = "async", method = RequestMethod.POST)@ResponseBody@Transactional(readOnly = false)public String async(HttpServletRequest request) { Map<String, String> params = new HashMap<String, String>(); Map requestParams = request.getParameterMap(); for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { String name = (String) iter.next(); String[] values = (String[]) requestParams.get(name); String valueStr = ""; for (int i = 0; i < values.length; i++) { valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; } System.out.println(">>>>>参数" + name + ":" + valueStr); params.put(name, valueStr); } requestParams.get("trade_status"); String tradeNo = request.getParameter("out_trade_no"); String tradeStatus = request.getParameter("trade_status"); if (AlipayNotify.verify(params)) {//验证成功 if (tradeStatus.equals("TRADE_FINISHED") || tradeStatus.equals("TRADE_SUCCESS")) { System.out.println(">>>>>状态要更新了");
//商品交易成功之后的业务逻辑代码System.out.println(">>>>>下单成功" + tradeNo); } return "success"; } else {//验证失败 System.out.println(">>>>>验签失败" + tradeNo); System.out.println(">>>>>交易被关闭了"); MemberOrder order = this.memberOrderService.get(tradeNo); this.memberOrderService.updateActualPayAndSurplusPay("0.00", order.getActualPay().toString(), tradeNo); return "fail"; }}
时间: 2024-10-16 14:08:32