| | |
| | | } |
| | | |
| | | JSONObject paramObj = JSONObject.parseObject(paramOut.getBody()); |
| | | |
| | | //获取 openId |
| | | String openId = paramObj.getString("openid"); |
| | | url = WechatConstant.APP_GET_USER_INFO_URL |
| | | .replace("ACCESS_TOKEN", paramObj.getString("access_token")) |
| | | .replace("OPENID", openId); |
| | | |
| | | paramOut = outRestTemplate.getForEntity(url, String.class); |
| | | |
| | | logger.debug("调用微信换去openId ", paramOut); |
| | | if (paramOut.getStatusCode() != HttpStatus.OK) { |
| | | return ResultVo.redirectPage("/"); |
| | | } |
| | | paramObj = JSONObject.parseObject(paramOut.getBody()); |
| | | JSONObject paramAuth = new JSONObject(); |
| | | paramAuth.put("openId", openId); |
| | | paramAuth.put("staffId", staffId); |
| | | paramAuth.put("storeId", storeId); |
| | | paramAuth.put("appType", "WECHAT"); |
| | | paramAuth.put("state", "2002"); |
| | | paramAuth.put("openName", paramObj.getString("nickname")); |
| | | |
| | | ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, paramAuth.toJSONString(), |
| | | ServiceConstant.SERVICE_API_URL + "/api/staff/updateStaffAppAuth", HttpMethod.POST); |
| | |
| | | try { |
| | | openUrl = WechatConstant.OPEN_AUTH |
| | | .replace("APPID", smallWeChatDto.getAppId()) |
| | | .replace("SCOPE", "snsapi_base") |
| | | //.replace("SCOPE", "snsapi_base") |
| | | .replace("SCOPE", "snsapi_userinfo") |
| | | .replace( |
| | | "REDIRECT_URL", |
| | | URLEncoder |
| | | .encode( |
| | | (url |
| | | + "/app/loginStaffWechatAuth?appId=992020061452450002&staffId=" |
| | | + staffId + "&storeId=" + storeId + "&wId=" + WechatFactory.getWId(smallWeChatDto.getAppId())), |
| | | + staffId + "&storeId=" + storeId + "&wId=" + WechatFactory.getWId(smallWeChatDto.getAppId())) |
| | | + "&communityId=" + communityId, |
| | | "UTF-8")).replace("STATE", "1"); |
| | | |
| | | response.sendRedirect(openUrl); |
| | | } catch (Exception e) { |
| | | logger.error("微信公众号鉴权 redirectUrl 错误 " + url, e); |
| | | throw new SMOException(ResponseConstant.RESULT_CODE_ERROR, e.getLocalizedMessage()); |