|
@@ -55,7 +55,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Slf4j
|
|
|
@Controller
|
|
|
@RequestMapping("/wechat/app")
|
|
|
-@Api(description = "微信小程序api服务")
|
|
|
+@Api(tags = "微信小程序api服务")
|
|
|
public class WechatAppController extends BaseController {
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
@@ -73,7 +73,7 @@ public class WechatAppController extends BaseController {
|
|
|
@ApiOperation(value = "微信登录", notes = "微信登录")
|
|
|
@PostMapping("/login")
|
|
|
@ResponseBody
|
|
|
- public ResponseBase login(@RequestBody LoginRequest request) {
|
|
|
+ public ResponseBase<Map<String, String>> login(@RequestBody LoginRequest request) {
|
|
|
String code = request.getCode();
|
|
|
if (StringUtils.isBlank(code)) {
|
|
|
return resultVOError("请输入code错误!");
|
|
@@ -134,251 +134,251 @@ public class WechatAppController extends BaseController {
|
|
|
return resultVOSuccess();
|
|
|
}
|
|
|
|
|
|
- private Map<String, Object> getStringObjectMap(String customerId) {
|
|
|
- CustomerInfoForm customerInfoForm = customerInfoService.queryByPrimaryKey(customerId);
|
|
|
- CustomerInfo data = BeanCopyUtil.convertBean(customerInfoForm, CustomerInfo.class);
|
|
|
-// CustomerInfo data = resultVO.getData();
|
|
|
- String guid = data.getGuid();
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
- ValueOperations<String, Object> operations = redisTemplate.opsForValue();
|
|
|
- Token token = TokenUtil.createJwtToken(guid, GlobleConstant.CURRENT_MEMBER);
|
|
|
- String accessToken = token.getAccessToken();
|
|
|
- resultMap.put("accessToken", accessToken);
|
|
|
- resultMap.put(WECHAT_USER_INFO, data);
|
|
|
- operations.set(token.getAccessToken(), resultMap, GlobleConstant.TOKEN_EXPIRES_SECOND, TimeUnit.SECONDS);
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
-
|
|
|
- private static final String WECHAT_USER_INFO = "wechatUserInfo";
|
|
|
-
|
|
|
- @GetMapping("dologin")
|
|
|
- @ResponseBody
|
|
|
- public ResponseBase login(String customerId) {
|
|
|
- Map<String, Object> resultMap = getStringObjectMap(customerId);
|
|
|
- return responseSuccess(new ResultVO(ResultEnum.SUCCESS, resultMap));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private MyWxMpUser getMyWxMpUser(WxMaUserInfo userInfo) {
|
|
|
- String openId = userInfo.getOpenId();
|
|
|
- String unionId = userInfo.getUnionId();
|
|
|
- String nickName = userInfo.getNickName();
|
|
|
- String gender = userInfo.getGender();
|
|
|
- String avatarUrl = userInfo.getAvatarUrl();
|
|
|
- MyWxMpUser myWxMpUser = new MyWxMpUser();
|
|
|
- myWxMpUser.setOpenId(openId);
|
|
|
- myWxMpUser.setUnionId(unionId);
|
|
|
- myWxMpUser.setNickname(nickName);
|
|
|
- myWxMpUser.setHeadImgUrl(avatarUrl);
|
|
|
- myWxMpUser.setSex(1);
|
|
|
- return myWxMpUser;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Value("${wx.pay.wxpayAppcallbackurl}")
|
|
|
- private String wxpayCallbackUrl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private WxPayService wxPayService;
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping("/pay")
|
|
|
- @AuthCarbonValidate
|
|
|
- @ResponseBody
|
|
|
- public ResponseBase pay(HttpServletRequest request) {
|
|
|
-// String orderId = wxPayFrom.getOrderId();
|
|
|
-// String openid = wxPayFrom.getOpenid();
|
|
|
-// String tradeType = wxPayFrom.getTradeType();
|
|
|
-// ResultVO<Order> appget = orderClient.get(orderId);
|
|
|
-// Order data = appget.getData();
|
|
|
-// int enable = data.getEnable().intValue();
|
|
|
-// if(1==enable){
|
|
|
-// throw new RuntimeException("订单已支付");
|
|
|
+// private Map<String, Object> getStringObjectMap(String customerId) {
|
|
|
+// CustomerInfoForm customerInfoForm = customerInfoService.queryByPrimaryKey(customerId);
|
|
|
+// CustomerInfo data = BeanCopyUtil.convertBean(customerInfoForm, CustomerInfo.class);
|
|
|
+//// CustomerInfo data = resultVO.getData();
|
|
|
+// String guid = data.getGuid();
|
|
|
+// Map<String, Object> resultMap = new HashMap<>();
|
|
|
+// ValueOperations<String, Object> operations = redisTemplate.opsForValue();
|
|
|
+// Token token = TokenUtil.createJwtToken(guid, GlobleConstant.CURRENT_MEMBER);
|
|
|
+// String accessToken = token.getAccessToken();
|
|
|
+// resultMap.put("accessToken", accessToken);
|
|
|
+// resultMap.put(WECHAT_USER_INFO, data);
|
|
|
+// operations.set(token.getAccessToken(), resultMap, GlobleConstant.TOKEN_EXPIRES_SECOND, TimeUnit.SECONDS);
|
|
|
+// return resultMap;
|
|
|
+// }
|
|
|
+
|
|
|
+// @Autowired
|
|
|
+// private RedisTemplate redisTemplate;
|
|
|
+//
|
|
|
+// private static final String WECHAT_USER_INFO = "wechatUserInfo";
|
|
|
+//
|
|
|
+// @GetMapping("dologin")
|
|
|
+// @ResponseBody
|
|
|
+// public ResponseBase login(String customerId) {
|
|
|
+// Map<String, Object> resultMap = getStringObjectMap(customerId);
|
|
|
+// return responseSuccess(new ResultVO(ResultEnum.SUCCESS, resultMap));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// private MyWxMpUser getMyWxMpUser(WxMaUserInfo userInfo) {
|
|
|
+// String openId = userInfo.getOpenId();
|
|
|
+// String unionId = userInfo.getUnionId();
|
|
|
+// String nickName = userInfo.getNickName();
|
|
|
+// String gender = userInfo.getGender();
|
|
|
+// String avatarUrl = userInfo.getAvatarUrl();
|
|
|
+// MyWxMpUser myWxMpUser = new MyWxMpUser();
|
|
|
+// myWxMpUser.setOpenId(openId);
|
|
|
+// myWxMpUser.setUnionId(unionId);
|
|
|
+// myWxMpUser.setNickname(nickName);
|
|
|
+// myWxMpUser.setHeadImgUrl(avatarUrl);
|
|
|
+// myWxMpUser.setSex(1);
|
|
|
+// return myWxMpUser;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Value("${wx.pay.wxpayAppcallbackurl}")
|
|
|
+// private String wxpayCallbackUrl;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private WxPayService wxPayService;
|
|
|
+//
|
|
|
+//
|
|
|
+// @PostMapping("/pay")
|
|
|
+// @AuthCarbonValidate
|
|
|
+// @ResponseBody
|
|
|
+// public ResponseBase pay(HttpServletRequest request) {
|
|
|
+//// String orderId = wxPayFrom.getOrderId();
|
|
|
+//// String openid = wxPayFrom.getOpenid();
|
|
|
+//// String tradeType = wxPayFrom.getTradeType();
|
|
|
+//// ResultVO<Order> appget = orderClient.get(orderId);
|
|
|
+//// Order data = appget.getData();
|
|
|
+//// int enable = data.getEnable().intValue();
|
|
|
+//// if(1==enable){
|
|
|
+//// throw new RuntimeException("订单已支付");
|
|
|
+//// }
|
|
|
+// WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+// //随机字符串
|
|
|
+// String s = UUIDUtils.randomUUID();
|
|
|
+//
|
|
|
+// orderRequest.setNonceStr(s);
|
|
|
+// //商品描述
|
|
|
+// orderRequest.setBody("碳汇扶贫!");
|
|
|
+// //商户订单号(支付编号)
|
|
|
+// GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
|
|
|
+// String orderNum = generatorIdUtils.nextId();
|
|
|
+// log.info("orderNum:" + orderNum);
|
|
|
+// //设置商户订单号
|
|
|
+// orderRequest.setOutTradeNo(orderNum);
|
|
|
+// //设置支付id
|
|
|
+//// data.setTransId(orderNum);
|
|
|
+// //设置金额
|
|
|
+//// BigDecimal money = data.getTotalPrice();
|
|
|
+// //元转成分
|
|
|
+//// money = money.multiply(new BigDecimal(100));
|
|
|
+//// int i = money.intValue();
|
|
|
+//// if ("test".equals(tradeType)) {
|
|
|
+//// //测试环境一分钱
|
|
|
+//// orderRequest.setTotalFee(1);
|
|
|
+//// } else {
|
|
|
+//// orderRequest.setTotalFee(i);
|
|
|
+//// }
|
|
|
+// //终端ip
|
|
|
+// String ipAddress = getIpAddress(request);
|
|
|
+// orderRequest.setSpbillCreateIp(ipAddress);
|
|
|
+// // 通知地址 支付成功后回调地址
|
|
|
+// log.info("wxpayCallbackUrl=================>{}", wxpayCallbackUrl);
|
|
|
+// orderRequest.setNotifyUrl(wxpayCallbackUrl);
|
|
|
+// //交易类型
|
|
|
+// orderRequest.setTradeType(WxPayConstants.TradeType.APP);
|
|
|
+// //用户标识 获取用户openid
|
|
|
+//// orderRequest.setOpenid(openid);
|
|
|
+// // 这个可能是偏向原生一点的统一下单,返回的参数有很多没用的 或者null值 建议使用 createOrder下单
|
|
|
+// Object unOrder = null;
|
|
|
+// try {
|
|
|
+// unOrder = wxPayService.createOrder(orderRequest);
|
|
|
+// } catch (WxPayException e) {
|
|
|
+// //e.printStackTrace();
|
|
|
+// log.error(e.getMessage());
|
|
|
+// //签名完成新增支付订单
|
|
|
+// ResultVO resultVO = new ResultVO();
|
|
|
+// resultVO.setCode(1);
|
|
|
+// resultVO.setMsg("微信支付失败!");
|
|
|
+// return responseError(resultVO);
|
|
|
// }
|
|
|
- WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
- //随机字符串
|
|
|
- String s = UUIDUtils.randomUUID();
|
|
|
-
|
|
|
- orderRequest.setNonceStr(s);
|
|
|
- //商品描述
|
|
|
- orderRequest.setBody("碳汇扶贫!");
|
|
|
- //商户订单号(支付编号)
|
|
|
- GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
|
|
|
- String orderNum = generatorIdUtils.nextId();
|
|
|
- log.info("orderNum:" + orderNum);
|
|
|
- //设置商户订单号
|
|
|
- orderRequest.setOutTradeNo(orderNum);
|
|
|
- //设置支付id
|
|
|
-// data.setTransId(orderNum);
|
|
|
- //设置金额
|
|
|
-// BigDecimal money = data.getTotalPrice();
|
|
|
- //元转成分
|
|
|
-// money = money.multiply(new BigDecimal(100));
|
|
|
-// int i = money.intValue();
|
|
|
-// if ("test".equals(tradeType)) {
|
|
|
-// //测试环境一分钱
|
|
|
-// orderRequest.setTotalFee(1);
|
|
|
+// //更新本地订单支付id
|
|
|
+//// orderClient.update(data);
|
|
|
+// //签名完成新增支付订单
|
|
|
+// ResultVO resultVO = new ResultVO();
|
|
|
+// resultVO.setCode(0);
|
|
|
+// resultVO.setData(unOrder);
|
|
|
+// return responseSuccess(resultVO);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * wx支付成功回调接口
|
|
|
+// *
|
|
|
+// * @param request
|
|
|
+// * @param response
|
|
|
+// * @throws IOException
|
|
|
+// */
|
|
|
+// @RequestMapping("payResult")
|
|
|
+// public void payResult(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+// log.info("微信支付返回通知函数开始---------------------");
|
|
|
+//
|
|
|
+// InputStream inStream = request.getInputStream();
|
|
|
+// ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
|
|
|
+// byte[] buffer = new byte[1024];
|
|
|
+// int len = 0;
|
|
|
+// while ((len = inStream.read(buffer)) != -1) {
|
|
|
+// outSteam.write(buffer, 0, len);
|
|
|
+// }
|
|
|
+// outSteam.close();
|
|
|
+// inStream.close();
|
|
|
+// String result = new String(outSteam.toByteArray(), "utf-8");
|
|
|
+// boolean isPayOk = false;
|
|
|
+// WxPayOrderNotifyResult wxPayOrderNotifyResult = null;
|
|
|
+// // 此处调用订单查询接口验证是否交易成功
|
|
|
+// try {
|
|
|
+// wxPayOrderNotifyResult = wxPayService.parseOrderNotifyResult(result);
|
|
|
+// if ("SUCCESS".equals(wxPayOrderNotifyResult.getResultCode())) {
|
|
|
+// isPayOk = true;
|
|
|
+// }
|
|
|
+// log.info("解析数据:" + wxPayOrderNotifyResult.toString());
|
|
|
+// } catch (WxPayException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// String noticeStr = "";
|
|
|
+// // 支付成功,商户处理后同步返回给微信参数
|
|
|
+// PrintWriter writer = response.getWriter();
|
|
|
+// if (isPayOk) {
|
|
|
+// //建议在这里处理付款完成的业务(虽然前端也可以处理后续业务,但是前端处理并不安全,例如:客户突然关闭浏览器了等情况,付款成功后续的业务将中断)
|
|
|
+// //支付订单支付编号
|
|
|
+// System.out.println("===============付款成功,业务开始处理==============");
|
|
|
+// String orderNum = wxPayOrderNotifyResult.getOutTradeNo();
|
|
|
+// log.info("orderNum:" + orderNum);
|
|
|
+//
|
|
|
+//// Order order=new Order();
|
|
|
+//// order.setTransId(orderNum);
|
|
|
+//// //将订单更新为支付
|
|
|
+//// orderClient.payment(order);
|
|
|
+// /**
|
|
|
+// * 自己的业务
|
|
|
+// */
|
|
|
+// System.out.println("===============付款成功,业务处理完毕==============");
|
|
|
+// // 通知微信已经收到消息,不要再给我发消息了,否则微信会8连击调用本接口
|
|
|
+// noticeStr = setXML("SUCCESS", "OK");
|
|
|
+// log.info("收到通知返回给微信api信息:-----------" + noticeStr);
|
|
|
+// writer.write(noticeStr);
|
|
|
+// writer.flush();
|
|
|
// } else {
|
|
|
-// orderRequest.setTotalFee(i);
|
|
|
+// // 支付失败, 记录流水失败
|
|
|
+// noticeStr = setXML("FAIL", "");
|
|
|
+// writer.write(noticeStr);
|
|
|
+// writer.flush();
|
|
|
+// System.out.println("===============支付失败==============");
|
|
|
// }
|
|
|
- //终端ip
|
|
|
- String ipAddress = getIpAddress(request);
|
|
|
- orderRequest.setSpbillCreateIp(ipAddress);
|
|
|
- // 通知地址 支付成功后回调地址
|
|
|
- log.info("wxpayCallbackUrl=================>{}", wxpayCallbackUrl);
|
|
|
- orderRequest.setNotifyUrl(wxpayCallbackUrl);
|
|
|
- //交易类型
|
|
|
- orderRequest.setTradeType(WxPayConstants.TradeType.APP);
|
|
|
- //用户标识 获取用户openid
|
|
|
-// orderRequest.setOpenid(openid);
|
|
|
- // 这个可能是偏向原生一点的统一下单,返回的参数有很多没用的 或者null值 建议使用 createOrder下单
|
|
|
- Object unOrder = null;
|
|
|
- try {
|
|
|
- unOrder = wxPayService.createOrder(orderRequest);
|
|
|
- } catch (WxPayException e) {
|
|
|
- //e.printStackTrace();
|
|
|
- log.error(e.getMessage());
|
|
|
- //签名完成新增支付订单
|
|
|
- ResultVO resultVO = new ResultVO();
|
|
|
- resultVO.setCode(1);
|
|
|
- resultVO.setMsg("微信支付失败!");
|
|
|
- return responseError(resultVO);
|
|
|
- }
|
|
|
- //更新本地订单支付id
|
|
|
-// orderClient.update(data);
|
|
|
- //签名完成新增支付订单
|
|
|
- ResultVO resultVO = new ResultVO();
|
|
|
- resultVO.setCode(0);
|
|
|
- resultVO.setData(unOrder);
|
|
|
- return responseSuccess(resultVO);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * wx支付成功回调接口
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @RequestMapping("payResult")
|
|
|
- public void payResult(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- log.info("微信支付返回通知函数开始---------------------");
|
|
|
-
|
|
|
- InputStream inStream = request.getInputStream();
|
|
|
- ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
|
|
|
- byte[] buffer = new byte[1024];
|
|
|
- int len = 0;
|
|
|
- while ((len = inStream.read(buffer)) != -1) {
|
|
|
- outSteam.write(buffer, 0, len);
|
|
|
- }
|
|
|
- outSteam.close();
|
|
|
- inStream.close();
|
|
|
- String result = new String(outSteam.toByteArray(), "utf-8");
|
|
|
- boolean isPayOk = false;
|
|
|
- WxPayOrderNotifyResult wxPayOrderNotifyResult = null;
|
|
|
- // 此处调用订单查询接口验证是否交易成功
|
|
|
- try {
|
|
|
- wxPayOrderNotifyResult = wxPayService.parseOrderNotifyResult(result);
|
|
|
- if ("SUCCESS".equals(wxPayOrderNotifyResult.getResultCode())) {
|
|
|
- isPayOk = true;
|
|
|
- }
|
|
|
- log.info("解析数据:" + wxPayOrderNotifyResult.toString());
|
|
|
- } catch (WxPayException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- String noticeStr = "";
|
|
|
- // 支付成功,商户处理后同步返回给微信参数
|
|
|
- PrintWriter writer = response.getWriter();
|
|
|
- if (isPayOk) {
|
|
|
- //建议在这里处理付款完成的业务(虽然前端也可以处理后续业务,但是前端处理并不安全,例如:客户突然关闭浏览器了等情况,付款成功后续的业务将中断)
|
|
|
- //支付订单支付编号
|
|
|
- System.out.println("===============付款成功,业务开始处理==============");
|
|
|
- String orderNum = wxPayOrderNotifyResult.getOutTradeNo();
|
|
|
- log.info("orderNum:" + orderNum);
|
|
|
-
|
|
|
-// Order order=new Order();
|
|
|
-// order.setTransId(orderNum);
|
|
|
-// //将订单更新为支付
|
|
|
-// orderClient.payment(order);
|
|
|
- /**
|
|
|
- * 自己的业务
|
|
|
- */
|
|
|
- System.out.println("===============付款成功,业务处理完毕==============");
|
|
|
- // 通知微信已经收到消息,不要再给我发消息了,否则微信会8连击调用本接口
|
|
|
- noticeStr = setXML("SUCCESS", "OK");
|
|
|
- log.info("收到通知返回给微信api信息:-----------" + noticeStr);
|
|
|
- writer.write(noticeStr);
|
|
|
- writer.flush();
|
|
|
- } else {
|
|
|
- // 支付失败, 记录流水失败
|
|
|
- noticeStr = setXML("FAIL", "");
|
|
|
- writer.write(noticeStr);
|
|
|
- writer.flush();
|
|
|
- System.out.println("===============支付失败==============");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * //签名成功生成支付订单
|
|
|
- *
|
|
|
- * @return
|
|
|
- * @throws GeneralSecurityException
|
|
|
- */
|
|
|
- private void insertPayOrder(Object object) {
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static String setXML(String return_code, String return_msg) {
|
|
|
- return "<xml><return_code><![CDATA[" + return_code + "]]></return_code><return_msg><![CDATA[" + return_msg + "]]></return_msg></xml>";
|
|
|
- }
|
|
|
-
|
|
|
- public static String getIpAddress(HttpServletRequest request) {
|
|
|
- String ip = request.getHeader("x-forwarded-for");
|
|
|
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
- ip = request.getHeader("Proxy-Client-IP");
|
|
|
- }
|
|
|
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
- ip = request.getHeader("WL-Proxy-Client-IP");
|
|
|
- }
|
|
|
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
- ip = request.getHeader("HTTP_CLIENT_IP");
|
|
|
- }
|
|
|
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
- ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
|
|
- }
|
|
|
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
- ip = request.getRemoteAddr();
|
|
|
- }
|
|
|
- String[] split = ip.split(",");
|
|
|
- ip = split[0];
|
|
|
- return ip;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * <pre>
|
|
|
- * 获取用户绑定手机号信息
|
|
|
- * </pre>
|
|
|
- */
|
|
|
- @GetMapping("/phone")
|
|
|
- public String phone(String sessionKey, String signature,
|
|
|
- String rawData, String encryptedData, String iv) {
|
|
|
-
|
|
|
- // 用户信息校验
|
|
|
- if (!wxMaService.getUserService().checkUserInfo(sessionKey, rawData, signature)) {
|
|
|
- return "user check failed";
|
|
|
- }
|
|
|
-
|
|
|
- // 解密
|
|
|
- WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
|
|
|
-
|
|
|
- return JsonUtils.toJson(phoneNoInfo);
|
|
|
- }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * //签名成功生成支付订单
|
|
|
+// *
|
|
|
+// * @return
|
|
|
+// * @throws GeneralSecurityException
|
|
|
+// */
|
|
|
+// private void insertPayOrder(Object object) {
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static String setXML(String return_code, String return_msg) {
|
|
|
+// return "<xml><return_code><![CDATA[" + return_code + "]]></return_code><return_msg><![CDATA[" + return_msg + "]]></return_msg></xml>";
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static String getIpAddress(HttpServletRequest request) {
|
|
|
+// String ip = request.getHeader("x-forwarded-for");
|
|
|
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+// ip = request.getHeader("Proxy-Client-IP");
|
|
|
+// }
|
|
|
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+// ip = request.getHeader("WL-Proxy-Client-IP");
|
|
|
+// }
|
|
|
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+// ip = request.getHeader("HTTP_CLIENT_IP");
|
|
|
+// }
|
|
|
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+// ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
|
|
+// }
|
|
|
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+// ip = request.getRemoteAddr();
|
|
|
+// }
|
|
|
+// String[] split = ip.split(",");
|
|
|
+// ip = split[0];
|
|
|
+// return ip;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * <pre>
|
|
|
+// * 获取用户绑定手机号信息
|
|
|
+// * </pre>
|
|
|
+// */
|
|
|
+// @GetMapping("/phone")
|
|
|
+// public String phone(String sessionKey, String signature,
|
|
|
+// String rawData, String encryptedData, String iv) {
|
|
|
+//
|
|
|
+// // 用户信息校验
|
|
|
+// if (!wxMaService.getUserService().checkUserInfo(sessionKey, rawData, signature)) {
|
|
|
+// return "user check failed";
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 解密
|
|
|
+// WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
|
|
|
+//
|
|
|
+// return JsonUtils.toJson(phoneNoInfo);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|