|
|
@ -1,15 +1,29 @@ |
|
|
package com.elink.esua.epdc.service.impl; |
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|
|
|
|
|
import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationDTO; |
|
|
|
|
|
import com.elink.esua.epdc.common.token.dto.WorkUserLoginDTO; |
|
|
|
|
|
import com.elink.esua.epdc.common.token.dto.WorkUserTokenFormDTO; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
|
|
import com.elink.esua.epdc.dto.SysUserDTO; |
|
|
|
|
|
import com.elink.esua.epdc.dto.form.EpdcWorkAppUserMaTokenFormDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.MemberRankFormDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.MemberRankFormDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.UserCountDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.UserCountDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.UserSortRankFormDTO; |
|
|
import com.elink.esua.epdc.dto.user.form.UserSortRankFormDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.OldMemberRankResultDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.OldMemberRankResultDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.UserSortRankResultDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.UserSortRankResultDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.YoungMemberRankResultDTO; |
|
|
import com.elink.esua.epdc.dto.user.result.YoungMemberRankResultDTO; |
|
|
|
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
import com.elink.esua.epdc.feign.AnalysisUserFeignClient; |
|
|
import com.elink.esua.epdc.feign.AnalysisUserFeignClient; |
|
|
|
|
|
import com.elink.esua.epdc.feign.ResourceFeignClient; |
|
|
import com.elink.esua.epdc.service.AnalysisUserService; |
|
|
import com.elink.esua.epdc.service.AnalysisUserService; |
|
|
|
|
|
import com.elink.esua.epdc.utils.WxMaServiceUtils; |
|
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -26,13 +40,48 @@ public class AnalysisUserServiceImpl implements AnalysisUserService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private AnalysisUserFeignClient analysisUserFeignClient; |
|
|
private AnalysisUserFeignClient analysisUserFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WxMaServiceUtils wxMaServiceUtils; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResourceFeignClient resourceFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result test() { |
|
|
public Result test() { |
|
|
return analysisUserFeignClient.test(); |
|
|
return analysisUserFeignClient.test(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result<WorkUserAuthorizationDTO> login(WorkUserLoginDTO formDto) { |
|
|
|
|
|
// 获取openId
|
|
|
|
|
|
String openId = this.getWxMaUser(formDto.getWxCode()).getOpenid(); |
|
|
|
|
|
formDto.setOpenId(openId); |
|
|
|
|
|
return resourceFeignClient.workLogin(formDto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result<WorkUserAuthorizationDTO> getMaToken(EpdcWorkAppUserMaTokenFormDTO formDto) { |
|
|
|
|
|
// 获取openId
|
|
|
|
|
|
String openId = this.getWxMaUser(formDto.getWxCode()).getOpenid(); |
|
|
|
|
|
|
|
|
|
|
|
// 检查当前微信是否已绑定账户
|
|
|
|
|
|
Result<SysUserDTO> sysUserDtoResult = adminFeignClient.getSysUserInfoByOpenId(openId); |
|
|
|
|
|
if (!sysUserDtoResult.success()) { |
|
|
|
|
|
return new Result<WorkUserAuthorizationDTO>().error(sysUserDtoResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
SysUserDTO userDto = sysUserDtoResult.getData(); |
|
|
|
|
|
if (null == userDto) { |
|
|
|
|
|
WorkUserAuthorizationDTO resultDto = new WorkUserAuthorizationDTO(); |
|
|
|
|
|
resultDto.setRegisterState(NumConstant.ZERO_STR); |
|
|
|
|
|
return new Result<WorkUserAuthorizationDTO>().ok(resultDto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return resourceFeignClient.getToken(ConvertUtils.sourceToTarget(userDto, WorkUserTokenFormDTO.class)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<List<OldMemberRankResultDTO>> listOldMemberRankByDeptId( MemberRankFormDTO formDto) { |
|
|
public Result<List<OldMemberRankResultDTO>> listOldMemberRankByDeptId( MemberRankFormDTO formDto) { |
|
|
return analysisUserFeignClient.listOldMemberRankByDeptId(formDto); |
|
|
return analysisUserFeignClient.listOldMemberRankByDeptId(formDto); |
|
|
@ -59,4 +108,28 @@ public class AnalysisUserServiceImpl implements AnalysisUserService { |
|
|
return analysisUserFeignClient.getGridStatistics(formDto); |
|
|
return analysisUserFeignClient.getGridStatistics(formDto); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* |
|
|
|
|
|
* 解析微信code获取小程序用户信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @params [wxCode] |
|
|
|
|
|
* @return cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult |
|
|
|
|
|
* @author liuchuang |
|
|
|
|
|
* @since 2020/2/12 13:20 |
|
|
|
|
|
*/ |
|
|
|
|
|
private WxMaJscode2SessionResult getWxMaUser(String wxCode) { |
|
|
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = null; |
|
|
|
|
|
try { |
|
|
|
|
|
wxMaJscode2SessionResult = wxMaServiceUtils.analysisWxMaService().jsCode2SessionInfo(wxCode); |
|
|
|
|
|
} catch (WxErrorException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
if (null == wxMaJscode2SessionResult) { |
|
|
|
|
|
throw new RenException("解析微信用户信息失败"); |
|
|
|
|
|
} else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) { |
|
|
|
|
|
throw new RenException("获取微信openid失败"); |
|
|
|
|
|
} |
|
|
|
|
|
return wxMaJscode2SessionResult; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|