|
|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.epmet.common.token.constant.LoginConstant; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
@ -9,10 +11,8 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.password.PasswordUtils; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.constant.AuthHttpUrlConstant; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
@ -70,12 +70,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); |
|
|
|
resiLoginFormDTO.setAppId(formDTO.getAppId()); |
|
|
|
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); |
|
|
|
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("居民端小程序登陆,调用epmet_third服务获取数据失败"); |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
} |
|
|
|
UserWechatDTO userWechatDTO = result.getData(); |
|
|
|
UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO); |
|
|
|
|
|
|
|
//2.调用epmet-user服务,新增用户信息(先判断用户是否存在,不存在则新增存在则更新)
|
|
|
|
WxUserFormDTO wxUserFormDTO = new WxUserFormDTO(); |
|
|
|
@ -83,7 +78,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
wxUserFormDTO.setApp(formDTO.getApp()); |
|
|
|
Result<UserDTO> userResult = epmetUserOpenFeignClient.saveWxUser(wxUserFormDTO); |
|
|
|
if (!userResult.success()) { |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
throw new RenException(userResult.getCode()); |
|
|
|
} |
|
|
|
UserDTO userDTO = userResult.getData(); |
|
|
|
|
|
|
|
@ -147,12 +142,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); |
|
|
|
resiLoginFormDTO.setAppId(formDTO.getAppId()); |
|
|
|
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); |
|
|
|
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
} |
|
|
|
UserWechatDTO userWechatDTO = result.getData(); |
|
|
|
UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO); |
|
|
|
|
|
|
|
//2.根据openid查询用户是否存在历史登陆信息
|
|
|
|
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userWechatDTO.getWxOpenId()); |
|
|
|
@ -369,12 +359,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); |
|
|
|
resiLoginFormDTO.setAppId(formDTO.getAppId()); |
|
|
|
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); |
|
|
|
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); |
|
|
|
throw new RenException(result.getCode()); |
|
|
|
} |
|
|
|
UserWechatDTO userWechatDTO = result.getData(); |
|
|
|
UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO); |
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); |
|
|
|
wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); |
|
|
|
wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); |
|
|
|
@ -419,12 +404,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); |
|
|
|
} |
|
|
|
//1.根据appId查询对应客户Id
|
|
|
|
Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); |
|
|
|
if (!resultDTO.success()) { |
|
|
|
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId())); |
|
|
|
throw new RenException(resultDTO.getMsg()); |
|
|
|
} |
|
|
|
PaCustomerDTO customer = resultDTO.getData().getCustomer(); |
|
|
|
PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId()); |
|
|
|
|
|
|
|
//7.28 根据appId只能存在一个客户Id,后边的批量操作逻辑
|
|
|
|
//2.根据手机号查询到用户信息
|
|
|
|
@ -461,12 +441,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
@Override |
|
|
|
public List<StaffOrgsResultDTO> getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO) { |
|
|
|
//0.根据appId查询对应客户Id
|
|
|
|
Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); |
|
|
|
if (!resultDTO.success()) { |
|
|
|
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId())); |
|
|
|
throw new RenException(resultDTO.getMsg()); |
|
|
|
} |
|
|
|
PaCustomerDTO customer = resultDTO.getData().getCustomer(); |
|
|
|
// Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId());
|
|
|
|
PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId()); |
|
|
|
//7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun
|
|
|
|
//1、根据手机号查询到用户信息
|
|
|
|
ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO(); |
|
|
|
@ -526,4 +502,44 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 获取客户信息 |
|
|
|
* @param appId |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
public PaCustomerDTO getCustomerInfo(String appId){ |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.CUSTOMER_MSG_URL + appId, JSON.toJSONString(jsonObject)).getData(); |
|
|
|
JSONObject toResult = JSON.parseObject(data); |
|
|
|
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); |
|
|
|
if (!mapToResult.success()) { |
|
|
|
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + appId)); |
|
|
|
throw new RenException(mapToResult.getMsg()); |
|
|
|
} |
|
|
|
Object PublicCustomerResultDTO = mapToResult.getData(); |
|
|
|
JSONObject json = JSON.parseObject(PublicCustomerResultDTO.toString()); |
|
|
|
PublicCustomerResultDTO publicCustomerResultDTO = ConvertUtils.mapToEntity(json, PublicCustomerResultDTO.class); |
|
|
|
PaCustomerDTO customer = publicCustomerResultDTO.getCustomer(); |
|
|
|
return customer; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 获取UserWechatDTO |
|
|
|
* @param resiLoginFormDTO |
|
|
|
* @author zxc |
|
|
|
*/ |
|
|
|
public UserWechatDTO getUserWeChat(WxLoginFormDTO resiLoginFormDTO){ |
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.RESI_AND_WORK_LOGIN_URL, JSON.toJSONString(resiLoginFormDTO)).getData(); |
|
|
|
JSONObject toResult = JSON.parseObject(data); |
|
|
|
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); |
|
|
|
if (!mapToResult.success()) { |
|
|
|
logger.error("居民端小程序登陆,调用epmet_third服务获取数据失败"); |
|
|
|
throw new RenException(mapToResult.getCode()); |
|
|
|
} |
|
|
|
Object UserWeChatDTO = mapToResult.getData(); |
|
|
|
JSONObject json = JSON.parseObject(UserWeChatDTO.toString()); |
|
|
|
UserWechatDTO userWechatDTO = ConvertUtils.mapToEntity(json, UserWechatDTO.class); |
|
|
|
return userWechatDTO; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|