|
@@ -386,6 +386,20 @@ public class WxLoginService implements IWxLoginService {
|
|
|
return openId;
|
|
|
}
|
|
|
|
|
|
+ public String getExamWxOpenId(WxLoginBody loginBody, Long userId) {
|
|
|
+ initData();
|
|
|
+ String openId;
|
|
|
+
|
|
|
+ //每次更新最新openid
|
|
|
+ String param = String.format(wxAuthParam, appid, appsrcret, loginBody.getCode());
|
|
|
+ String resultString = HttpUtils.sendGet(wxAuthUrl, param);
|
|
|
+ //解析json
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
|
|
|
+ String session_key = String.valueOf(jsonObject.get("session_key"));
|
|
|
+ openId = String.valueOf(jsonObject.get("openid"));
|
|
|
+ return openId;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//小程序获取用户信息
|
|
|
public User getWxUnionIdUser(WxLoginBody loginBody) {
|
|
@@ -1274,6 +1288,30 @@ public class WxLoginService implements IWxLoginService {
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ //获取公众号openid
|
|
|
+ public String bindGzhUnionIdUser(WxLoginBody loginBody) {
|
|
|
+ if(Validator.isEmpty(loginBody.getCode())){
|
|
|
+ throw new CustomException("code不能为空");
|
|
|
+ }
|
|
|
+ initData();
|
|
|
+ String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());
|
|
|
+ String resultString = HttpUtils.sendGet(gzh_wxAuthUrl, param);
|
|
|
+ //解析json
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
|
|
|
+ String access_token = String.valueOf(jsonObject.get("access_token"));
|
|
|
+ if(access_token.equals("null")){
|
|
|
+ throw new CustomException( String.valueOf(jsonObject.get("errmsg")));
|
|
|
+ }
|
|
|
+ String openId = String.valueOf(jsonObject.get("openid"));
|
|
|
+
|
|
|
+ String userInfoParam = String.format(gzh_wxUserInfoParam, access_token, openId);
|
|
|
+ String userInfoResultString = HttpUtils.sendGet(gzh_wxUserInfoUrl, userInfoParam);
|
|
|
+
|
|
|
+ //解析json
|
|
|
+ JSONObject jsonObject1 = (JSONObject) JSONObject.parse(userInfoResultString);
|
|
|
+ return openId;
|
|
|
+ }
|
|
|
+
|
|
|
public Boolean checkBindOpenId(WxIdBody loginBody) {
|
|
|
if(Validator.isEmpty(loginBody.getOpenid())||Validator.isEmpty(loginBody.getFromPlat())){
|
|
|
throw new CustomException("参数缺失");
|