| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void alipayCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | try { |
| | | String resString = XmlUtils.parseRequest(request); |
| | | String respString = "error"; |
| | | if (!resString.isEmpty()) { |
| | | Map<String, String> map = XmlUtils.toMap(resString.getBytes(), "utf-8"); |
| | | map = XmlUtils.toMap(resString.getBytes(), "utf-8"); |
| | | String sign_type = map.get("sign_type"); |
| | | String reSign = map.get("sign"); |
| | | if (map.containsKey("sign")) { |
| | | OrderResponse order = orderService.getByOrderNum(map.get("out_trade_no")); |
| | | PayTypeEnum status = PayTypeEnum.find(order.getOrder().getPayType()); |
| | | if (SignUtil.verifySign(reSign, sign_type, map, properties, status)) { |
| | | log.error("验证签名错误!:{}", map.toString()); |
| | | log.error("汇旺财支付验证签名错误!:{}", map.toString()); |
| | | } else { |
| | | if ("0".equals(map.get("status"))) { |
| | | if ("0".equals(map.get("result_code"))) { |
| | |
| | | PayStateEnum stateEnum = PayStateEnum.NOTPAY; |
| | | if ("0".equals(map.get("pay_result"))) { |
| | | stateEnum = PayStateEnum.SUCCESS; |
| | | orderService.operationLog(order, OrderStatusEnum.TWO); |
| | | orderService.operationLog(order, OrderStatusEnum.TWO, null); |
| | | } |
| | | orderService.updatePayStatus(map.get("out_trade_no"), stateEnum, map.get("pay_info"), map.get("time_end")); |
| | | // 处理成功 |
| | |
| | | } |
| | | response.getWriter().write(respString); |
| | | } catch (Exception e) { |
| | | log.error("汇旺财支付回调失败:{}", map.toString()); |
| | | throw new BadRequestException("操作失败,原因:" + e.getMessage()); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void returnNotify(HttpServletRequest request, HttpServletResponse response) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | try { |
| | | String resString = XmlUtils.parseRequest(request); |
| | | String respString = "error"; |
| | | if (!resString.isEmpty()) { |
| | | Map<String, String> map = XmlUtils.toMap(resString.getBytes(), "utf-8"); |
| | | map = XmlUtils.toMap(resString.getBytes(), "utf-8"); |
| | | String sign_type = map.get("sign_type"); |
| | | String reSign = map.get("sign"); |
| | | if (map.containsKey("sign")) { |
| | | OrderReturn order = returnService.getByReturnNum(map.get("out_refund_no")); |
| | | PayTypeEnum status = PayTypeEnum.find(order.getPayType()); |
| | | if (SignUtil.verifySign(reSign, sign_type, map, properties, status)) { |
| | | log.error("验证签名错误!:{}", map.toString()); |
| | | log.error("汇旺财退款验证签名错误!:{}", map.toString()); |
| | | } else { |
| | | if ("0".equals(map.get("status"))) { |
| | | if ("0".equals(map.get("result_code"))) { |
| | |
| | | } |
| | | response.getWriter().write(respString); |
| | | } catch (Exception e) { |
| | | log.error("汇旺财退款回调失败:{}", map.toString()); |
| | | System.out.println("操作失败,原因:" + e.getMessage()); |
| | | } |
| | | } |