| | |
| | | |
| | | @Override |
| | | public WxLoginVO wxLogin(String code, HttpServletRequest request) { |
| | | WxLoginVO wxLoginVO = new WxLoginVO(); |
| | | |
| | | String appId = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPID).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPSECRET).getCode(); |
| | | String getTokenUrl = GET_ACCESS_TOKEN_URL.replace("CODE", code).replace("APPID", appId).replace("SECRET", appSecret); |
| | |
| | | String openId = tokenJson.getString("openid"); |
| | | String getUserInfoUrl = GET_USER_INFO_URL.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openId); |
| | | JSONObject userInfoJson = JSONObject.parseObject(HttpsUtil.get(getUserInfoUrl,true)); |
| | | return loginByUnionIdAndReturn(userInfoJson.getString("unionid"),openId,request); |
| | | |
| | | } |
| | | |
| | | private WxLoginVO loginByUnionIdAndReturn(String unionid,String openId,HttpServletRequest request) { |
| | | WxLoginVO wxLoginVO = new WxLoginVO(); |
| | | wxLoginVO.setOpenid(openId); |
| | | wxLoginVO.setUnionid(userInfoJson.getString("unionid")); |
| | | CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().eq("openid",openId).last(" limit 1 ")); |
| | | wxLoginVO.setUnionid(unionid); |
| | | CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().lambda() |
| | | .eq(CompanyUser::getUnionid,wxLoginVO.getUnionid()) |
| | | .eq(CompanyUser::getDeleted,Constants.ZERO) |
| | | .last(" limit 1 ")); |
| | | // CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().eq("openid",openId).last(" limit 1 ")); |
| | | if(Objects.isNull(companyUser)){ |
| | | wxLoginVO.setLoginStatus(Constants.ONE); |
| | | return wxLoginVO; |
| | |
| | | systemLoginLogService.create(loginLog); |
| | | throw ee; |
| | | } |
| | | return wxLoginVO; |
| | | } |
| | | |
| | | @Override |
| | | public WxLoginVO wxProgramLogin(String unionId,String openId, HttpServletRequest request) { |
| | | return loginByUnionIdAndReturn(unionId,openId,request); |
| | | |
| | | } |
| | | |
| | | |