|
|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.enterprise.form.EnterpriseInfoFormDTO; |
|
|
|
@ -81,12 +82,21 @@ public class CustomEnterpriseServiceImpl implements CustomEnterpriseService { |
|
|
|
if (StringUtils.isBlank(wxCode) || StringUtils.isBlank(iv) || StringUtils.isBlank(encryptedData)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
String sessionKey = this.getUserSessionKey(wxCode); |
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, encryptedData, iv); |
|
|
|
WxMaService wxMaService = wxMaServiceUtils.normalWxMaService(); |
|
|
|
try { |
|
|
|
WxMaJscode2SessionResult wxMaJscode = wxMaService.jsCode2SessionInfo(wxCode); |
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaService.getUserService().getUserInfo(wxMaJscode.getSessionKey(), encryptedData, iv); |
|
|
|
if (null == wxMaUserInfo || StringUtils.isBlank(wxMaUserInfo.getUnionId())) { |
|
|
|
throw new RenException("解析微信数据失败,请刷新后重试"); |
|
|
|
throw new RenException("解析微信数据失败,请刷新页面后重试"); |
|
|
|
} |
|
|
|
return wxMaUserInfo.getUnionId(); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
if (e.getError().getErrorCode() == 40163) { |
|
|
|
throw new RenException("禁止重复提交,请刷新页面后重试"); |
|
|
|
} |
|
|
|
throw new RenException(e.getError().getErrorMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -99,27 +109,4 @@ public class CustomEnterpriseServiceImpl implements CustomEnterpriseService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据微信code获取session_key |
|
|
|
* |
|
|
|
* @return java.lang.String |
|
|
|
* @params [code] |
|
|
|
* @author liuchuang |
|
|
|
* @since 2019/10/25 16:31 |
|
|
|
*/ |
|
|
|
private String getUserSessionKey(String code) { |
|
|
|
try { |
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(code); |
|
|
|
if (wxMaJscode2SessionResult != null) { |
|
|
|
return wxMaJscode2SessionResult.getSessionKey(); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
if (e.getError().getErrorCode() == 40163) { |
|
|
|
throw new RenException("禁止重复提交,请刷新页面后重试"); |
|
|
|
} |
|
|
|
throw new RenException(e.getError().getErrorMsg()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|