Browse Source

Merge branches 'dev' and 'dev_heart' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_heart

master
yinzuomei 5 years ago
parent
commit
70eb3079f5
  1. 2
      epmet-auth/deploy/docker-compose-dev.yml
  2. 2
      epmet-auth/pom.xml
  3. 24
      epmet-auth/src/main/java/com/epmet/constant/AuthHttpUrlConstant.java
  4. 30
      epmet-auth/src/main/java/com/epmet/constant/ThirdApiConstant.java
  5. 25
      epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java
  6. 5
      epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java
  7. 4
      epmet-auth/src/main/java/com/epmet/dto/form/PaWxCodeFormDTO.java
  8. 6
      epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java
  9. 62
      epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java
  10. 86
      epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
  11. 26
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java
  12. 2
      epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml
  13. 2
      epmet-module/epmet-heart/epmet-heart-server/pom.xml
  14. 19
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/constant/HttpUrlConstant.java
  15. 14
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java
  16. 14
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java
  17. 27
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CheckPaUserFormDTO.java
  18. 12
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java
  19. 5
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java
  20. 9
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterInfoFormDTO.java
  21. 6
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java
  22. 28
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WxCodeToTokenFormDTO.java
  23. 2
      epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml
  24. 2
      epmet-module/epmet-third/epmet-third-server/pom.xml
  25. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java
  26. 17
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java
  27. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java
  28. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
  29. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerUserAgencyDao.java
  30. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java
  31. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserVisitedDao.java
  32. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java
  33. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  34. 13
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java
  35. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java
  36. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java
  37. 42
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  38. 27
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  39. 35
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java
  40. 1
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java
  41. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java
  42. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java
  43. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java
  44. 20
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  45. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
  46. 32
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerUserAgencyDao.xml
  47. 19
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
  48. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserVisitedDao.xml
  49. 31
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml
  50. 2
      epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml
  51. 2
      epmet-module/oper-crm/oper-crm-server/pom.xml
  52. 10
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  53. 11
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/GuideHttpUrlConstant.java
  54. 32
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java

2
epmet-auth/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-auth-server: epmet-auth-server:
container_name: epmet-auth-server-dev container_name: epmet-auth-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.57 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.58
ports: ports:
- "8081:8081" - "8081:8081"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-auth/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.3.57</version> <version>0.3.58</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId> <artifactId>epmet-cloud</artifactId>

24
epmet-auth/src/main/java/com/epmet/constant/AuthHttpUrlConstant.java

@ -0,0 +1,24 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 10:05
*/
public interface AuthHttpUrlConstant {
/**
* 注册url
*/
String REGISTER_URL = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/register";
/**
* 获取客户信息url
*/
String CUSTOMER_MSG_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
/**
* 登录url
*/
String RESI_AND_WORK_LOGIN_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/resiandworklogin";
}

30
epmet-auth/src/main/java/com/epmet/constant/ThirdApiConstant.java

@ -0,0 +1,30 @@
package com.epmet.constant;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/7/30 10:46
*/
public interface ThirdApiConstant {
/**
* 根据openId新增或更新用户信息
*/
String THIRD_PAUSER_SAVEUSER = "https://epmet-cloud.elinkservice.cn/api/third/pauser/saveuser";
/**
* 根据手机号查询公众号用户基本信息校验用户是否存在
*/
String THIRD_PAUSER_CHECKPAUSER = "https://epmet-cloud.elinkservice.cn/api/third/pauser/checkpauser";
/**
* 用户登陆新增访问记录数据
*/
String THIRD_PAUSERVISITED_SAVEUSERVISITED = "https://epmet-cloud.elinkservice.cn/api/third/pauservisited/saveuservisited";
/**
* 根据客户Id查询各项注册信息
*/
String THIRD_PACUSTOMER_GETCUSTOMERAGENCYUSER = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/getcustomeragencyuser/";
/**
* 修改客户数据状态为已完成初始化
*/
String THIRD_PACUSTOMER_UPDATECUSTOMER = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/updatecustomer/";
}

25
epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java

@ -1,6 +1,7 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -12,11 +13,12 @@ import com.epmet.dto.form.PublicSendSmsCodeFormDTO;
import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.PublicUserLoginService; import com.epmet.service.PublicUserLoginService;
import com.netflix.ribbon.proxy.annotation.Http;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*;
/** /**
* 描述一下 * 描述一下
@ -38,8 +40,10 @@ public class PublicUserLoginController {
* @description 解析wxcode获取用户信息并生成token * @description 解析wxcode获取用户信息并生成token
**/ **/
@PostMapping(value = "/wxcodetotoken") @PostMapping(value = "/wxcodetotoken")
public Result<UserTokenResultDTO> wxCodeToToken(@RequestBody PaWxCodeFormDTO formDTO) {
public Result<UserTokenResultDTO> wxCodeToToken(@RequestHeader("source") String source, @RequestBody PaWxCodeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, PaWxCodeFormDTO.AddUserInternalGroup.class); ValidatorUtils.validateEntity(formDTO, PaWxCodeFormDTO.AddUserInternalGroup.class);
formDTO.setSource(source);
return new Result<UserTokenResultDTO>().ok(publicUserLoginService.wxCodeToToken(formDTO)); return new Result<UserTokenResultDTO>().ok(publicUserLoginService.wxCodeToToken(formDTO));
} }
@ -50,11 +54,12 @@ public class PublicUserLoginController {
* @Description 公众号登录-发送验证码 * @Description 公众号登录-发送验证码
**/ **/
@PostMapping(value = "/sendsmscode") @PostMapping(value = "/sendsmscode")
public Result sendSmsCode(@RequestBody PublicSendSmsCodeFormDTO formDTO) { public Result sendSmsCode(@RequestHeader("source") String source, @RequestBody PublicSendSmsCodeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO,PublicSendSmsCodeFormDTO.AddUserShowGroup.class); ValidatorUtils.validateEntity(formDTO,PublicSendSmsCodeFormDTO.AddUserShowGroup.class);
if(formDTO.getIsLogon()!=true&&formDTO.getIsLogon()!=false){ if (formDTO.getIsLogon() != true && formDTO.getIsLogon() != false) {
throw new RenException(PublicUserLoginConstant.PARAMETER_EXCEPTION); throw new RenException(PublicUserLoginConstant.PARAMETER_EXCEPTION);
} }
formDTO.setSource(source);
publicUserLoginService.sendSmsCode(formDTO); publicUserLoginService.sendSmsCode(formDTO);
return new Result(); return new Result();
} }
@ -66,8 +71,9 @@ public class PublicUserLoginController {
* @Description 公众号-手机验证码登陆 * @Description 公众号-手机验证码登陆
**/ **/
@PostMapping(value = "/loginbyphone") @PostMapping(value = "/loginbyphone")
public Result<UserTokenResultDTO> loginByPhone(@LoginUser TokenDto tokenDTO, @RequestBody LoginByPhoneFormDTO formDTO) { public Result<UserTokenResultDTO> loginByPhone(@RequestHeader("source") String source, @LoginUser TokenDto tokenDTO, @RequestBody LoginByPhoneFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, LoginByPhoneFormDTO.AddUserShowGroup.class, LoginByPhoneFormDTO.LoginByPhone.class); ValidatorUtils.validateEntity(formDTO, LoginByPhoneFormDTO.AddUserShowGroup.class, LoginByPhoneFormDTO.LoginByPhone.class);
formDTO.setSource(source);
return new Result<UserTokenResultDTO>().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO)); return new Result<UserTokenResultDTO>().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO));
} }
@ -78,9 +84,10 @@ public class PublicUserLoginController {
* @Description 公众号-手机号注册 * @Description 公众号-手机号注册
**/ **/
@PostMapping(value = "/register") @PostMapping(value = "/register")
public Result<UserTokenResultDTO> register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) { public Result<UserTokenResultDTO> register(@RequestHeader("source") String source, @LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class); ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class);
formDTO.setUserId(tokenDTO.getUserId()); formDTO.setUserId(tokenDTO.getUserId());
formDTO.setSource(source);
return new Result<UserTokenResultDTO>().ok(publicUserLoginService.register(formDTO)); return new Result<UserTokenResultDTO>().ok(publicUserLoginService.register(formDTO));
} }

5
epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java

@ -34,5 +34,10 @@ public class LoginByPhoneFormDTO implements Serializable {
@NotBlank(message="验证码不能为空", groups = {LoginByPhone.class}) @NotBlank(message="验证码不能为空", groups = {LoginByPhone.class})
private String smsCode; private String smsCode;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
} }

4
epmet-auth/src/main/java/com/epmet/dto/form/PaWxCodeFormDTO.java

@ -20,4 +20,8 @@ public class PaWxCodeFormDTO implements Serializable {
*/ */
@NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class})
private String wxCode; private String wxCode;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
} }

6
epmet-auth/src/main/java/com/epmet/dto/form/PublicSendSmsCodeFormDTO.java

@ -26,8 +26,14 @@ public class PublicSendSmsCodeFormDTO implements Serializable {
*/ */
@NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class})
private String phone; private String phone;
/** /**
* 是否登陆登陆true 注册false * 是否登陆登陆true 注册false
*/ */
private Boolean isLogon; private Boolean isLogon;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
} }

62
epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java

@ -1,17 +1,21 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.common.token.constant.LoginConstant; import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.constant.PublicUserLoginConstant; import com.epmet.constant.PublicUserLoginConstant;
import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.SmsTemplateConstant;
import com.epmet.constant.ThirdApiConstant;
import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.PaUserWechatDTO;
@ -32,10 +36,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -68,13 +70,17 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
public UserTokenResultDTO wxCodeToToken(PaWxCodeFormDTO formDTO) { public UserTokenResultDTO wxCodeToToken(PaWxCodeFormDTO formDTO) {
//1.通过微信code获取用户基本信息 //1.通过微信code获取用户基本信息
WxMpUser wxMpUser = this.getWxMpUser(formDTO.getWxCode()); WxMpUser wxMpUser = this.getWxMpUser(formDTO.getWxCode());
WxCodeToTokenFormDTO dto = new WxCodeToTokenFormDTO();
dto.setWxMpUser(wxMpUser);
dto.setSource(formDTO.getSource());
//2.将获取的用户基本信息初始化到数据库 //2.将获取的用户基本信息初始化到数据库
Result<SaveUserResultDTO> result = epmetThirdFeignClient.saveUser(wxMpUser); String url = ThirdApiConstant.THIRD_PAUSER_SAVEUSER;
Result<String> result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto));
if (!result.success()) { if (!result.success()) {
throw new RenException(PublicUserLoginConstant.SAVE_USER_EXCEPTION); throw new RenException(PublicUserLoginConstant.SAVE_USER_EXCEPTION);
} }
SaveUserResultDTO resultDTO = result.getData(); SaveUserResultDTO resultDTO = JSONObject.parseObject(result.getData(), SaveUserResultDTO.class);
//3.获取用户token //3.获取用户token
String token = this.generateGovWxmpToken(resultDTO.getUserId()); String token = this.generateGovWxmpToken(resultDTO.getUserId());
@ -156,19 +162,23 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg()));
throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode()); throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode());
} }
//2、根据手机号校验用户是否存在 //2、根据数据来源和手机号校验用户是否存在
Result<CustomerUserResultDTO> Result = epmetThirdFeignClient.checkPaUser(formDTO.getPhone()); CheckPaUserFormDTO dto = new CheckPaUserFormDTO();
if (!Result.success()) { dto.setPhone(formDTO.getPhone());
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), Result.getCode(), Result.getMsg())); dto.setSource(formDTO.getSource());
throw new RenException(Result.getCode()); String url = ThirdApiConstant.THIRD_PAUSER_CHECKPAUSER;
Result<String> result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto));
if (!result.success()) {
logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getPhone(), result.getCode(), result.getMsg()));
throw new RenException(result.getCode());
} }
CustomerUserResultDTO ResultDTO = Result.getData(); CustomerUserResultDTO resultDTO = JSONObject.parseObject(result.getData(), CustomerUserResultDTO.class);
//登陆 //登陆
if (formDTO.getIsLogon() && null == ResultDTO.getPaUserResult()) { if (formDTO.getIsLogon() && null == resultDTO.getPaUserResult()) {
throw new RenException(EpmetErrorCode.PUBLIC_NOT_EXISTS.getCode()); throw new RenException(EpmetErrorCode.PUBLIC_NOT_EXISTS.getCode());
} }
//注册 //注册
if (!formDTO.getIsLogon() && null != ResultDTO.getPaUserResult()) { if (!formDTO.getIsLogon() && null != resultDTO.getPaUserResult()) {
throw new RenException(EpmetErrorCode.MOBILE_USED.getCode()); throw new RenException(EpmetErrorCode.MOBILE_USED.getCode());
} }
//3、发送短信验证码 //3、发送短信验证码
@ -194,13 +204,17 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
**/ **/
@Override @Override
public UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO) { public UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO) {
//1.根据手机号查询到用户、客户信息 //1.根据数据来源和手机号查询用户、客户信息
Result<CustomerUserResultDTO> result = epmetThirdFeignClient.checkPaUser(formDTO.getPhone()); CheckPaUserFormDTO dto = new CheckPaUserFormDTO();
dto.setPhone(formDTO.getPhone());
dto.setSource(formDTO.getSource());
String url = ThirdApiConstant.THIRD_PAUSER_CHECKPAUSER;
Result<String> result = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto));
if (!result.success()) { if (!result.success()) {
logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getPhone(), result.getCode(), result.getMsg())); logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getPhone(), result.getCode(), result.getMsg()));
throw new RenException(result.getCode()); throw new RenException(result.getCode());
} }
CustomerUserResultDTO resultDTO = result.getData(); CustomerUserResultDTO resultDTO = JSONObject.parseObject(result.getData(), CustomerUserResultDTO.class);
//2.用户不存在时不允许登陆 //2.用户不存在时不允许登陆
PaUserDTO userDTO = resultDTO.getPaUserResult(); PaUserDTO userDTO = resultDTO.getPaUserResult();
@ -236,7 +250,9 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
visited.setUserId(userDTO.getId()); visited.setUserId(userDTO.getId());
visited.setLogonUserId(tokenDTO.getUserId()); visited.setLogonUserId(tokenDTO.getUserId());
visited.setPhone(formDTO.getPhone()); visited.setPhone(formDTO.getPhone());
Result visitedResult = epmetThirdFeignClient.saveUserVisited(visited); visited.setSource(formDTO.getSource());
String saveUserVisitedUrl = ThirdApiConstant.THIRD_PAUSERVISITED_SAVEUSERVISITED;
Result<String> visitedResult = HttpClientManager.getInstance().sendPostByJSON(saveUserVisitedUrl, JSON.toJSONString(visited));
if(!visitedResult.success()){ if(!visitedResult.success()){
logger.error(PublicUserLoginConstant.SAVE_VISITED_EXCEPTION); logger.error(PublicUserLoginConstant.SAVE_VISITED_EXCEPTION);
} }
@ -256,12 +272,16 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
@Override @Override
public UserTokenResultDTO register(RegisterFormDTO formDTO) { public UserTokenResultDTO register(RegisterFormDTO formDTO) {
//1.调用epmet-third服务,完成信息注册 //1.调用epmet-third服务,完成信息注册
Result<RegisterResultDTO> result = epmetThirdFeignClient.register(formDTO); String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.REGISTER_URL, JSON.toJSONString(formDTO)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) { if (!result.success()) {
logger.error("调用epmet_third服务初始化用户信息失败"); logger.error(String.format("调用epmet_third服务初始化用户信息失败,数据来源[%s],手机号[%s],userId:[%S]", formDTO.getSource(), formDTO.getPhone(), formDTO.getUserId()));
throw new RenException(result.getCode()); throw new RenException(result.getCode());
} }
RegisterResultDTO resultDTO = result.getData(); Object RegisterResult = result.getData();
JSONObject jsonObject = JSON.parseObject(RegisterResult.toString());
RegisterResultDTO resultDTO = ConvertUtils.mapToEntity(jsonObject, RegisterResultDTO.class);
//2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成) //2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成)
//2-1.生成token //2-1.生成token

86
epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java

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

26
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java

@ -12,9 +12,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 转换工具类 * 转换工具类
@ -58,4 +60,28 @@ public class ConvertUtils {
return targetList; return targetList;
} }
public static <T> T mapToEntity(Map<String, Object> map, Class<T> entity) {
T t = null;
try {
t = entity.newInstance();
for(Field field : entity.getDeclaredFields()) {
if (map.containsKey(field.getName())) {
boolean flag = field.isAccessible();
field.setAccessible(true);
Object object = map.get(field.getName());
if (object!= null && field.getType().isAssignableFrom(object.getClass())) {
field.set(t, object);
}
field.setAccessible(flag);
}
}
return t;
} catch (InstantiationException e) {
logger.error("convert error ", e);
} catch (IllegalAccessException e) {
logger.error("convert error ", e);
}
return t;
}
} }

2
epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-heart-server: epmet-heart-server:
container_name: epmet-heart-server-dev container_name: epmet-heart-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.13 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.14
ports: ports:
- "8111:8111" - "8111:8111"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-module/epmet-heart/epmet-heart-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.0.13</version> <version>0.0.14</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-heart</artifactId> <artifactId>epmet-heart</artifactId>

19
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/constant/HttpUrlConstant.java

@ -0,0 +1,19 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 9:47
*/
public interface HttpUrlConstant {
/**
* 定时任务 刷新authorizer_access_tokenurl
*/
String AUTH_ACCESS_TOKEN_URL = "https://epmet-cloud.elinkservice.cn/api/third/wechatthird/refreshtoken";
/**
* 定时任务 刷新component_access_tokenurl
*/
String COMPONENT_ACCESS_TOKEN_URL = "https://epmet-cloud.elinkservice.cn/api/third/wechatthird/componentaccesstoken";
}

14
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java

@ -1,6 +1,11 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.HttpUrlConstant;
import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.service.ComponentAccessTokenService; import com.epmet.service.ComponentAccessTokenService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -15,11 +20,12 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService { public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService {
@Autowired
private EpmetThirdFeignClient epmetThirdFeignClient;
@Override @Override
public Result componentAccessTokenJob() { public Result componentAccessTokenJob() {
return epmetThirdFeignClient.getComponentAccessTokenJob(); JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(HttpUrlConstant.COMPONENT_ACCESS_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
return result;
} }
} }

14
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java

@ -1,6 +1,11 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.HttpUrlConstant;
import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.service.RefreshAuthAccessTokenService; import com.epmet.service.RefreshAuthAccessTokenService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,11 +18,12 @@ import org.springframework.stereotype.Service;
@Service @Service
public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService { public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService {
@Autowired
private EpmetThirdFeignClient epmetThirdFeignClient;
@Override @Override
public Result refreshAuthorizerAccessTokenJob() { public Result refreshAuthorizerAccessTokenJob() {
return epmetThirdFeignClient.refreshAuthorizerAccessTokenJob(); JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(HttpUrlConstant.AUTH_ACCESS_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
return result;
} }
} }

27
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CheckPaUserFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 公众号-发送短信验证码-接口入参
* @Author sun
*/
@Data
public class CheckPaUserFormDTO implements Serializable {
private static final long serialVersionUID = -6163303184086480522L;
/**
* s手机号
*/
private String phone;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
}

12
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterByAuthFormDTO.java

@ -1,7 +1,9 @@
package com.epmet.dto.form; package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -12,10 +14,20 @@ import java.io.Serializable;
public class RegisterByAuthFormDTO implements Serializable { public class RegisterByAuthFormDTO implements Serializable {
private static final long serialVersionUID = -6547893374373422628L; private static final long serialVersionUID = -6547893374373422628L;
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
/** /**
* 初始化状态0:已初始化1:未初始化 * 初始化状态0:已初始化1:未初始化
* */ * */
private Integer initState; private Integer initState;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
@NotBlank(message = "数据来源不能为空", groups = {RegisterByAuthFormDTO.AddUserInternalGroup.class, RegisterByAuthFormDTO.AddUserShowGroup.class})
private String source;
} }

5
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterFormDTO.java

@ -51,4 +51,9 @@ public class RegisterFormDTO implements Serializable {
*/ */
private String userId; private String userId;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
} }

9
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RegisterInfoFormDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto.form; package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
@ -17,6 +18,8 @@ public class RegisterInfoFormDTO implements Serializable {
public interface AddUserInternalGroup { public interface AddUserInternalGroup {
} }
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
/** /**
* 当前页 * 当前页
@ -29,4 +32,10 @@ public class RegisterInfoFormDTO implements Serializable {
* */ * */
private Integer pageSize = 20; private Integer pageSize = 20;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
@NotBlank(message = "数据来源不能为空", groups = {RegisterInfoFormDTO.AddUserInternalGroup.class, RegisterInfoFormDTO.AddUserShowGroup.class})
private String source;
} }

6
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SaveUserVisitedFormDTO.java

@ -31,4 +31,10 @@ public class SaveUserVisitedFormDTO implements Serializable {
*/ */
private String phone; private String phone;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
} }

28
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WxCodeToTokenFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import lombok.Data;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import java.io.Serializable;
import java.util.Date;
/**
* 公众号-wxcode换取token保存微信用户信息-接口入参
* @Author sun
*/
@Data
public class WxCodeToTokenFormDTO implements Serializable {
private static final long serialVersionUID = -6163303184086480522L;
/**
* 微信用户信息
*/
private WxMpUser wxMpUser;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
*/
private String source;
}

2
epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-third-server: epmet-third-server:
container_name: epmet-third-server-dev container_name: epmet-third-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.79 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.80
ports: ports:
- "8110:8110" - "8110:8110"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.0.79</version> <version>0.0.80</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java

@ -61,25 +61,27 @@ public class PaCustomerController {
/** /**
* @param formDTO * @param formDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-创建组织 * @Description 公众号-创建组织
**/ **/
@PostMapping("createagency") @PostMapping("createagency")
public Result<CreateAgencyResultDTO> createAgency(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO) { public Result<CreateAgencyResultDTO> createAgency(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO,@RequestHeader("source")String source) {
ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); ValidatorUtils.validateEntity(formDTO, DefaultGroup.class);
return new Result<CreateAgencyResultDTO>().ok(paCustomerService.createAgency(tokenDTO, formDTO)); return new Result<CreateAgencyResultDTO>().ok(paCustomerService.createAgency(tokenDTO, formDTO,source));
} }
/** /**
* @param tokenDTO * @param tokenDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-查询我的信息 * @Description 公众号-查询我的信息
**/ **/
@PostMapping("myinfo") @PostMapping("myinfo")
public Result<MyInfoResultDTO> myInfo(@LoginUser TokenDto tokenDTO) { public Result<MyInfoResultDTO> myInfo(@LoginUser TokenDto tokenDTO,@RequestHeader("source")String source) {
return new Result<MyInfoResultDTO>().ok(paCustomerService.myInfo(tokenDTO)); return new Result<MyInfoResultDTO>().ok(paCustomerService.myInfo(tokenDTO,source));
} }
/** /**

17
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaUserController.java

@ -23,14 +23,15 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserDTO;
import com.epmet.dto.form.CheckPaUserFormDTO;
import com.epmet.dto.form.WxCodeToTokenFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO; import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.excel.PaUserExcel; import com.epmet.excel.PaUserExcel;
import com.epmet.service.PaUserService; import com.epmet.service.PaUserService;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -95,25 +96,25 @@ public class PaUserController {
} }
/** /**
* @param wxMpUser * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId新增或更新用户信息 * @Description 根据openId新增或更新用户信息
**/ **/
@PostMapping(value = "/saveuser") @PostMapping(value = "/saveuser")
public Result<SaveUserResultDTO> saveUser(@RequestBody WxMpUser wxMpUser) { public Result<SaveUserResultDTO> saveUser(@RequestBody WxCodeToTokenFormDTO formDTO) {
return new Result<SaveUserResultDTO>().ok(paUserService.saveUser(wxMpUser)); return new Result<SaveUserResultDTO>().ok(paUserService.saveUser(formDTO));
} }
/** /**
* @param phone * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据手机号查询公众号用户基本信息校验用户是否存在 * @Description 根据手机号查询公众号用户基本信息校验用户是否存在
**/ **/
@PostMapping(value = "/checkpauser/{phone}") @PostMapping(value = "/checkpauser/{phone}")
public Result<CustomerUserResultDTO> checkPaUser(@PathVariable("phone") String phone) { public Result<CustomerUserResultDTO> checkPaUser(@RequestBody CheckPaUserFormDTO formDTO) {
return new Result<CustomerUserResultDTO>().ok(paUserService.checkPaUser(phone)); return new Result<CustomerUserResultDTO>().ok(paUserService.checkPaUser(formDTO));
} }
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java

@ -49,9 +49,9 @@ public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
* @param * @param
* @return * @return
* @Author sun * @Author sun
* @Description 查询所有客户小程序的授权信息 * @Description 根据数据来源查询所有客户小程序的授权信息
**/ **/
List<CustomerMpDTO> selectAll(); List<CustomerMpDTO> selectAll(@Param("source")String source);
/** /**
* @Description 查询授权的数量 * @Description 查询授权的数量

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java

@ -49,9 +49,9 @@ public interface PaCustomerDao extends BaseDao<PaCustomerEntity> {
* @param * @param
* @return * @return
* @Author sun * @Author sun
* @Description 查询公众号注册的客户信息列表 * @Description 根据数据来源查询公众号注册的客户信息列表
**/ **/
List<CustomerAgencyResultDTO> registerInfo(); List<CustomerAgencyResultDTO> registerInfo(@Param("source") String source);
/** /**
* @param dto * @param dto

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerUserAgencyDao.java

@ -38,5 +38,13 @@ public interface PaCustomerUserAgencyDao extends BaseDao<PaCustomerUserAgencyEnt
* @Author sun * @Author sun
* @Description 根据userId查询客户信息 * @Description 根据userId查询客户信息
**/ **/
PaCustomerUserAgencyDTO selectByUserId(@Param("userId") String userId); PaCustomerUserAgencyDTO selectByUserId(@Param("userId") String userId, @Param("source")String source);
/**
* @param userId
* @return
* @Author sun
* @Description 根据userId查询客户信息
**/
PaCustomerUserAgencyDTO selectCustomerIdByUserId(@Param("userId") String userId);
} }

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserDTO;
import com.epmet.dto.form.CheckPaUserFormDTO;
import com.epmet.entity.PaUserEntity; import com.epmet.entity.PaUserEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -35,12 +36,12 @@ import java.util.List;
public interface PaUserDao extends BaseDao<PaUserEntity> { public interface PaUserDao extends BaseDao<PaUserEntity> {
/** /**
* @param phone * @param phone source
* @return * @return
* @Author sun * @Author sun
* @Description 根据手机号查询公众号用户基本信息校验用户是否存在 * @Description 根据数据来源和手机号查询公众号用户基本信息校验用户是否存在
**/ **/
List<PaUserDTO> selectUserByPhone(@Param("phone") String phone); List<PaUserDTO> selectUserByPhone(@Param("phone") String phone, @Param("source") String source);
/** /**
* @param customerId * @param customerId
@ -49,4 +50,12 @@ public interface PaUserDao extends BaseDao<PaUserEntity> {
* @Description 根据客户Id级联查询客户管理员注册信息 * @Description 根据客户Id级联查询客户管理员注册信息
**/ **/
PaUserDTO selectPaUser(@Param("customerId") String customerId); PaUserDTO selectPaUser(@Param("customerId") String customerId);
/**
* @param id source
* @return
* @Author sun
* @Description 根据数据来源和手机号查询公众号用户基本信息校验用户是否存在
**/
PaUserDTO selectUser(@Param("id") String id, @Param("source") String source);
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserVisitedDao.java

@ -36,7 +36,7 @@ public interface PaUserVisitedDao extends BaseDao<PaUserVisitedEntity> {
* @param openId * @param openId
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId查询登陆访问记录数据按时间倒序 * @Description 根据数据来源和openId查询登陆访问记录数据按时间倒序
**/ **/
PaUserVisitedDTO selectByOpenId(@Param("openId") String openId); PaUserVisitedDTO selectByOpenId(@Param("openId") String openId, @Param("source") String source);
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java

@ -38,9 +38,9 @@ public interface PaUserWechatDao extends BaseDao<PaUserWechatEntity> {
* @param openId * @param openId
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId查询user_wechat表信息 * @Description 根据数据来源和openId查询user_wechat表信息
**/ **/
List<PaUserWechatDTO> selectWechatByOpenId(@Param("openId") String openId); List<PaUserWechatDTO> selectWechatByOpenId(@Param("openId") String openId, @Param("source") String source);
/** /**
* @param dto * @param dto

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java

@ -116,19 +116,21 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
/** /**
* @param formDTO * @param formDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-创建组织 * @Description 公众号-创建组织
**/ **/
CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO,String source);
/** /**
* @param tokenDTO * @param tokenDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-查询我的信息 * @Description 公众号-查询我的信息
**/ **/
MyInfoResultDTO myInfo(TokenDto tokenDTO); MyInfoResultDTO myInfo(TokenDto tokenDTO,String source);
/** /**
* @param formDTO * @param formDTO

13
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserService.java

@ -20,10 +20,11 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserDTO;
import com.epmet.dto.form.CheckPaUserFormDTO;
import com.epmet.dto.form.WxCodeToTokenFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO; import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.entity.PaUserEntity; import com.epmet.entity.PaUserEntity;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -97,18 +98,18 @@ public interface PaUserService extends BaseService<PaUserEntity> {
void delete(String[] ids); void delete(String[] ids);
/** /**
* @param wxMpUser * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId新增或更新用户信息 * @Description 根据openId新增或更新用户信息
**/ **/
SaveUserResultDTO saveUser(WxMpUser wxMpUser); SaveUserResultDTO saveUser(WxCodeToTokenFormDTO formDTO);
/** /**
* @param phone * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据手机号查询公众号用户基本信息校验用户是否存在 * @Description 根据数据来源和手机号查询公众号用户基本信息校验用户是否存在
**/ **/
CustomerUserResultDTO checkPaUser(String phone); CustomerUserResultDTO checkPaUser(CheckPaUserFormDTO formDTO);
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java

@ -97,7 +97,7 @@ public interface PaUserWechatService extends BaseService<PaUserWechatEntity> {
* @param openId * @param openId
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId查询user_wechat表信息 * @Description 根据数据来源和openId查询user_wechat表信息
**/ **/
List<PaUserWechatDTO> getWechatByOpenId(String openId); List<PaUserWechatDTO> getWechatByOpenId(String openId, String source);
} }

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java

@ -5,12 +5,12 @@ import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant; import com.epmet.constant.ModuleConstant;
import com.epmet.dao.BindingAccountDao; import com.epmet.dao.BindingAccountDao;
import com.epmet.dao.CustomerMpDao; import com.epmet.dao.CustomerMpDao;
import com.epmet.dao.OpenPlatformAccountDao; import com.epmet.dao.OpenPlatformAccountDao;
import com.epmet.dao.PaCustomerAgencyDao;
import com.epmet.dto.form.GoToAuthFormDTO; import com.epmet.dto.form.GoToAuthFormDTO;
import com.epmet.dto.form.OpenAppIdFormDTO; import com.epmet.dto.form.OpenAppIdFormDTO;
import com.epmet.dto.form.RemoveBindFormDTO; import com.epmet.dto.form.RemoveBindFormDTO;
@ -35,13 +35,9 @@ import java.util.Map;
@Service @Service
public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationService { public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationService {
@Autowired
private PaCustomerAgencyDao paCustomerAgencyDao;
@Autowired @Autowired
private ComponentVerifyTicketService componentVerifyTicketService; private ComponentVerifyTicketService componentVerifyTicketService;
@Autowired @Autowired
private ComponentVerifyTicketServiceImpl componentVerifyTicketServiceImpl;
@Autowired
private OpenPlatformAccountDao openPlatformAccountDao; private OpenPlatformAccountDao openPlatformAccountDao;
@Autowired @Autowired
private CustomerMpDao customerMpDao; private CustomerMpDao customerMpDao;
@ -85,7 +81,7 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic
//查询appId //查询appId
String authAppId = customerMpDao.getAppId(customerId, clientType); String authAppId = customerMpDao.getAppId(customerId, clientType);
Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType); Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType);
AuthorizationInfoResultDTO authorizationInfo = componentVerifyTicketServiceImpl.mapToEntity(authInfo, AuthorizationInfoResultDTO.class); AuthorizationInfoResultDTO authorizationInfo = ConvertUtils.mapToEntity(authInfo, AuthorizationInfoResultDTO.class);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId);
@ -110,7 +106,7 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic
String clientType = formDTO.getClientType(); String clientType = formDTO.getClientType();
String authAppId = customerMpDao.getAppId(customerId, clientType); String authAppId = customerMpDao.getAppId(customerId, clientType);
Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType); Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType);
AuthorizationInfoResultDTO authorizationInfo = componentVerifyTicketServiceImpl.mapToEntity(authInfo, AuthorizationInfoResultDTO.class); AuthorizationInfoResultDTO authorizationInfo = ConvertUtils.mapToEntity(authInfo, AuthorizationInfoResultDTO.class);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.UN_BIND + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData(); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.UN_BIND + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData();

42
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -6,6 +6,7 @@ import com.alibaba.nacos.client.config.utils.IOUtils;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant; import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.constant.ThirdRedisKeyConstant;
@ -31,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN;
@ -175,7 +175,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public void disposeAuthResult(Map<String,String> result){ public void disposeAuthResult(Map<String,String> result){
Map tempMap = result; Map tempMap = result;
Map<String,Object> data = tempMap; Map<String,Object> data = tempMap;
AuthResultRecordFormDTO authResultRecord = mapToEntity(data, AuthResultRecordFormDTO.class); AuthResultRecordFormDTO authResultRecord = ConvertUtils.mapToEntity(data, AuthResultRecordFormDTO.class);
authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME)));
if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) {
authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME))); authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)));
@ -285,7 +285,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData();
HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class); HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class);
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO);
authorizationInfoResultDTO = mapToEntity(map, AuthorizationInfoResultDTO.class); authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class);
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); String authAppId = authorizationInfoResultDTO.getAuthorizer_appid();
log.info("授权信息:"+map); log.info("授权信息:"+map);
String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); String expiresIn = authorizationInfoResultDTO.getExpires_in().toString();
@ -433,7 +433,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO);
if (keyExist == true){ if (keyExist == true){
log.info("授权方为小程序 并 开始插入信息"); log.info("授权方为小程序 并 开始插入信息");
MiniInfoFormDTO miniInfoFormDTO = this.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); MiniInfoFormDTO miniInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, MiniInfoFormDTO.class);
miniInfoFormDTO.setCustomerId(customerId); miniInfoFormDTO.setCustomerId(customerId);
miniInfoFormDTO.setClientType(clientType); miniInfoFormDTO.setClientType(clientType);
//基础信息插入 //基础信息插入
@ -485,7 +485,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
} }
}else { }else {
log.info("授权方为公众号 并 开始插入信息"); log.info("授权方为公众号 并 开始插入信息");
PaInfoFormDTO paInfoFormDTO = this.mapToEntity(authorizerInfo, PaInfoFormDTO.class); PaInfoFormDTO paInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, PaInfoFormDTO.class);
//公众号基本信息插入 //公众号基本信息插入
paInfoDao.insertPaInfo(paInfoFormDTO); paInfoDao.insertPaInfo(paInfoFormDTO);
String primaryId = paInfoFormDTO.getId(); String primaryId = paInfoFormDTO.getId();
@ -611,36 +611,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
} }
} }
/**
* @Description map Entity
* @param map
* @param entity
* @author zxc
*/
public <T> T mapToEntity(Map<String, Object> map, Class<T> entity) {
T t = null;
try {
t = entity.newInstance();
for(Field field : entity.getDeclaredFields()) {
if (map.containsKey(field.getName())) {
boolean flag = field.isAccessible();
field.setAccessible(true);
Object object = map.get(field.getName());
if (object!= null && field.getType().isAssignableFrom(object.getClass())) {
field.set(t, object);
}
field.setAccessible(flag);
}
}
return t;
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return t;
}
/** /**
* @Description 转换过期时间 * @Description 转换过期时间
* @param expiresIn * @param expiresIn
@ -660,7 +630,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
* @author zxc * @author zxc
*/ */
public String getLoginUserCustomerId(TokenDto tokenDto){ public String getLoginUserCustomerId(TokenDto tokenDto){
PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectByUserId(tokenDto.getUserId()); PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectCustomerIdByUserId(tokenDto.getUserId());
return result.getCustomerId(); return result.getCustomerId();
} }

27
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java

@ -164,21 +164,21 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
} }
//1.根据手机号查询到用户信息,判断用户是否存 //1.根据数据来源和手机号查询到用户信息,判断用户是否存
List<PaUserDTO> userList = paUserDao.selectUserByPhone(formDTO.getPhone()); List<PaUserDTO> userList = paUserDao.selectUserByPhone(formDTO.getPhone(), formDTO.getSource());
if (null != userList && userList.size() > NumConstant.ZERO) { if (null != userList && userList.size() > NumConstant.ZERO) {
throw new RenException(EpmetErrorCode.MOBILE_USED.getCode()); throw new RenException(EpmetErrorCode.MOBILE_USED.getCode());
} }
//2.根据token中的userId查询pa_user表数据,根据手机号是否为空判断后续是新增还是更新user数据 //2.根据数据来源和token中的userId查询pa_user表数据,根据手机号是否为空判断后续是新增还是更新user数据
PaUserEntity paUserEntity = paUserDao.selectById(formDTO.getUserId()); PaUserDTO paUserDTO= paUserDao.selectUser(formDTO.getUserId(), formDTO.getSource());
if (null == paUserEntity) { if (null == paUserDTO) {
logger.error("根据token中userId查询pa_user表信息失败,userId->"+formDTO.getUserId()); logger.error("根据数据来源和token中userId查询pa_user表信息失败,数据来源->" + formDTO.getSource() + ",userId->" + formDTO.getUserId());
throw new RenException(PaConstant.SELECT_USER_EXCEPTION); throw new RenException(PaConstant.SELECT_USER_EXCEPTION);
} }
//3.手机号不为空说明是同一个微信用户用第二个手机号注册,手机为空说明当前微信用户用第一个手机号注册 //3.手机号不为空说明是同一个微信用户用第二个手机号注册,手机为空说明当前微信用户用第一个手机号注册
if(StringUtils.isNotBlank(paUserEntity.getPhone())){ if(StringUtils.isNotBlank(paUserDTO.getPhone())){
//手机号不为空说明是同一个微信用户用第二个手机号注册,新增user和user_wechat表数据 //手机号不为空说明是同一个微信用户用第二个手机号注册,新增user和user_wechat表数据
//3-1.user表新增数据 //3-1.user表新增数据
PaUserEntity userEntity = new PaUserEntity(); PaUserEntity userEntity = new PaUserEntity();
@ -289,17 +289,19 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
/** /**
* @param formDTO * @param formDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-创建组织 * @Description 公众号-创建组织
**/ **/
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO) { public CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO,String source) {
//1.客户表初始化数据 //1.客户表初始化数据
PaCustomerEntity entity = new PaCustomerEntity(); PaCustomerEntity entity = new PaCustomerEntity();
entity.setIsInitialize(NumConstant.ZERO); entity.setIsInitialize(NumConstant.ZERO);
entity.setCustomerName(formDTO.getAgencyName()); entity.setCustomerName(formDTO.getAgencyName());
entity.setSource(source);
baseDao.insert(entity); baseDao.insert(entity);
//2.客户组织表初始化数据 //2.客户组织表初始化数据
@ -356,15 +358,16 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
/** /**
* @param tokenDTO * @param tokenDTO
* @param source 服务端类型 dev:开发 test:体验 prod:生产
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-查询我的信息 * @Description 公众号-查询我的信息
**/ **/
@Override @Override
public MyInfoResultDTO myInfo(TokenDto tokenDTO) { public MyInfoResultDTO myInfo(TokenDto tokenDTO,String source) {
//0.根据token中userId查询对应的客户Id,客户Id没有则表示用户没有填写过组织信息,需要继续完善信息 //0.根据token中userId查询对应的客户Id,客户Id没有则表示用户没有填写过组织信息,需要继续完善信息
PaCustomerUserAgencyDTO dto = paCustomerUserAgencyDao.selectByUserId(tokenDTO.getUserId()); PaCustomerUserAgencyDTO dto = paCustomerUserAgencyDao.selectByUserId(tokenDTO.getUserId(),source);
if (null == dto || null == dto.getCustomerId()) { if (null == dto || null == dto.getCustomerId()) {
return new MyInfoResultDTO(); return new MyInfoResultDTO();
} }
@ -408,9 +411,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
//分页参数 //分页参数
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
//1.查询客户组织信息 //1.查询客户组织信息
List<CustomerAgencyResultDTO> list = baseDao.registerInfo(); List<CustomerAgencyResultDTO> list = baseDao.registerInfo(formDTO.getSource());
//2.查询客户小程序授权信息 //2.查询客户小程序授权信息
List<CustomerMpDTO> mpList = customerMpDao.selectAll(); List<CustomerMpDTO> mpList = customerMpDao.selectAll(formDTO.getSource());
//3.封装数据 //3.封装数据
list.forEach(l -> { list.forEach(l -> {
mpList.forEach(mp -> { mpList.forEach(mp -> {

35
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java

@ -34,12 +34,16 @@ import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserVisitedDTO; import com.epmet.dto.PaUserVisitedDTO;
import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.PaUserWechatDTO;
import com.epmet.dto.form.CheckPaUserFormDTO;
import com.epmet.dto.form.SaveUserVisitedFormDTO;
import com.epmet.dto.form.WxCodeToTokenFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO; import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.entity.PaUserEntity; import com.epmet.entity.PaUserEntity;
import com.epmet.entity.PaUserWechatEntity; import com.epmet.entity.PaUserWechatEntity;
import com.epmet.redis.PaUserRedis; import com.epmet.redis.PaUserRedis;
import com.epmet.service.PaUserService; import com.epmet.service.PaUserService;
import com.epmet.service.PaUserVisitedService;
import com.epmet.service.PaUserWechatService; import com.epmet.service.PaUserWechatService;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -72,6 +76,8 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
private PaUserWechatDao paUserWechatDao; private PaUserWechatDao paUserWechatDao;
@Autowired @Autowired
private PaUserVisitedDao paUserVisitedDao; private PaUserVisitedDao paUserVisitedDao;
@Autowired
private PaUserVisitedService paUserVisitedService;
@Override @Override
public PageData<PaUserDTO> page(Map<String, Object> params) { public PageData<PaUserDTO> page(Map<String, Object> params) {
@ -126,22 +132,24 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
} }
/** /**
* @param wxMpUser * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId新增或更新用户信息 * @Description 根据openId新增或更新用户信息
**/ **/
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public SaveUserResultDTO saveUser(WxMpUser wxMpUser) { public SaveUserResultDTO saveUser(WxCodeToTokenFormDTO formDTO) {
WxMpUser wxMpUser = formDTO.getWxMpUser();
SaveUserResultDTO resultDTO = new SaveUserResultDTO(); SaveUserResultDTO resultDTO = new SaveUserResultDTO();
//1.根据openId查询user_wechat表是否存在用户信息(user表和user_wechat表数据多对多关系) //1.根据openId查询user_wechat表是否存在用户信息(user表和user_wechat表数据多对多关系)
List<PaUserWechatDTO> wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); List<PaUserWechatDTO> wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId(), formDTO.getSource());
//2.不存在则新增用户信息,存在则更新user_wechat表信息 //2.不存在则新增用户信息,存在则更新user_wechat表信息
if (null == wechatDTO || wechatDTO.size() < NumConstant.ONE) { if (null == wechatDTO || wechatDTO.size() < NumConstant.ONE) {
//2.1、user表新增数据 //2.1、user表新增数据
PaUserEntity userEntity = new PaUserEntity(); PaUserEntity userEntity = new PaUserEntity();
userEntity.setSource(formDTO.getSource());
baseDao.insert(userEntity); baseDao.insert(userEntity);
//2.2、user_wechat表新增数据 //2.2、user_wechat表新增数据
PaUserWechatEntity wechatEntity = new PaUserWechatEntity(); PaUserWechatEntity wechatEntity = new PaUserWechatEntity();
@ -157,9 +165,16 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
wechatEntity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage()); wechatEntity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage());
paUserWechatService.insert(wechatEntity); paUserWechatService.insert(wechatEntity);
//2.3、pa_user_visited表新增访问记录数据
SaveUserVisitedFormDTO visited = new SaveUserVisitedFormDTO();
visited.setUserId(userEntity.getId());
visited.setLogonUserId(userEntity.getId());
visited.setSource(formDTO.getSource());
paUserVisitedService.saveUserVisited(visited);
resultDTO.setUserId(userEntity.getId()); resultDTO.setUserId(userEntity.getId());
} else { } else {
//2.3、批量更新user_wechat表数据 //2.4、批量更新user_wechat表数据
List<PaUserWechatEntity> wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); List<PaUserWechatEntity> wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class);
for(PaUserWechatEntity entity : wechatEntity){ for(PaUserWechatEntity entity : wechatEntity){
entity.setGender(wxMpUser.getSex().toString()); entity.setGender(wxMpUser.getSex().toString());
@ -172,8 +187,8 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
} }
paUserWechatService.updateBatchById(wechatEntity); paUserWechatService.updateBatchById(wechatEntity);
//2.4、根据openid查询用户登陆访问记录表数据,按登陆时间倒序 //2.5、根据openid查询用户登陆访问记录表数据,按登陆时间倒序
PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId()); PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId(), formDTO.getSource());
if (null == visitedDTO || "".equals(visitedDTO.getUserId())) { if (null == visitedDTO || "".equals(visitedDTO.getUserId())) {
logger.error("根据openid查询用户访问记录表数据失败,openid->"+wxMpUser.getOpenId()); logger.error("根据openid查询用户访问记录表数据失败,openid->"+wxMpUser.getOpenId());
throw new RenException(PaConstant.SELECT_VISITED_EXCEPTION); throw new RenException(PaConstant.SELECT_VISITED_EXCEPTION);
@ -187,16 +202,16 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
} }
/** /**
* @param phone * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 根据手机号查询公众号用户基本信息校验用户是否存在 * @Description 根据手机号查询公众号用户基本信息校验用户是否存在
**/ **/
@Override @Override
public CustomerUserResultDTO checkPaUser(String phone) { public CustomerUserResultDTO checkPaUser(CheckPaUserFormDTO formDTO) {
CustomerUserResultDTO resultDTO = new CustomerUserResultDTO(); CustomerUserResultDTO resultDTO = new CustomerUserResultDTO();
//1.根据手机号查询用户信息 //1.根据手机号查询用户信息
List<PaUserDTO> userList = baseDao.selectUserByPhone(phone); List<PaUserDTO> userList = baseDao.selectUserByPhone(formDTO.getPhone(), formDTO.getSource());
if (null == userList || userList.size() < NumConstant.ONE) { if (null == userList || userList.size() < NumConstant.ONE) {
resultDTO.setPaUserResult(null); resultDTO.setPaUserResult(null);
resultDTO.setPaCustomerResult(null); resultDTO.setPaCustomerResult(null);

1
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserVisitedServiceImpl.java

@ -135,6 +135,7 @@ public class PaUserVisitedServiceImpl extends BaseServiceImpl<PaUserVisitedDao,
entity.setWxOpenId(userEntity.getWxOpenId()); entity.setWxOpenId(userEntity.getWxOpenId());
entity.setOpenId(openId); entity.setOpenId(openId);
entity.setPhone(visited.getPhone()); entity.setPhone(visited.getPhone());
entity.setSource(visited.getSource());
baseDao.insert(entity); baseDao.insert(entity);
} }

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java

@ -105,11 +105,11 @@ public class PaUserWechatServiceImpl extends BaseServiceImpl<PaUserWechatDao, Pa
* @param openId * @param openId
* @return * @return
* @Author sun * @Author sun
* @Description 根据openId查询user_wechat表信息 * @Description 根据数据来源和openId查询user_wechat表信息
**/ **/
@Override @Override
public List<PaUserWechatDTO> getWechatByOpenId(String openId) { public List<PaUserWechatDTO> getWechatByOpenId(String openId, String source) {
return baseDao.selectWechatByOpenId(openId); return baseDao.selectWechatByOpenId(openId, source);
} }
} }

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

@ -1,6 +1,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.nacos.client.config.utils.IOUtils; import com.alibaba.nacos.client.config.utils.IOUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.ModuleConstant; import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant; import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*; import com.epmet.dao.*;
@ -44,8 +45,6 @@ public class WarrantServiceImpl implements WarrantService {
@Value("${third.platform.token}") @Value("${third.platform.token}")
private String token; private String token;
@Autowired @Autowired
private ComponentVerifyTicketServiceImpl componentVerifyTicketService;
@Autowired
private CodeAuditRecordDao codeAuditRecordDao; private CodeAuditRecordDao codeAuditRecordDao;
@Autowired @Autowired
private MiniInfoDao miniInfoDao; private MiniInfoDao miniInfoDao;
@ -96,7 +95,7 @@ public class WarrantServiceImpl implements WarrantService {
if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.EVENT_LOW)) { if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.EVENT_LOW)) {
// TODO 目前来看,msgType = ‘event’ 的是代码审核结果 // TODO 目前来看,msgType = ‘event’ 的是代码审核结果
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class); CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class);
codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString())); codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString()));
String toUserName = codeAuditRecord.getToUserName();//小程序原始ID String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName);
@ -130,7 +129,7 @@ public class WarrantServiceImpl implements WarrantService {
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult);
}else if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.TEXT)){ }else if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.TEXT)){
// TODO 公众号回复消息 // TODO 公众号回复消息
MessagePushTextFormDTO messagePushTextFormDTO = componentVerifyTicketService.mapToEntity(xml, MessagePushTextFormDTO.class); MessagePushTextFormDTO messagePushTextFormDTO = ConvertUtils.mapToEntity(xml, MessagePushTextFormDTO.class);
Object createTime = xml.get(ModuleConstant.CREATE_TIME); Object createTime = xml.get(ModuleConstant.CREATE_TIME);
Date date = componentVerifyTicketServiceImpl.sToDate(createTime.toString()); Date date = componentVerifyTicketServiceImpl.sToDate(createTime.toString());
messagePushTextFormDTO.setWeChatCreateTime(date); messagePushTextFormDTO.setWeChatCreateTime(date);

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaCategoryResult.java

@ -16,26 +16,32 @@ public class WxMaCategoryResult implements Serializable {
/** /**
* 一级类目名称 * 一级类目名称
*/ */
@SerializedName("first_class")
private String firstClass; private String firstClass;
/** /**
* 二级类目名称 * 二级类目名称
*/ */
@SerializedName("second_class")
private String secondClass; private String secondClass;
/** /**
* 三级类目名称 * 三级类目名称
*/ */
@SerializedName("third_class")
private String thirdClass; private String thirdClass;
/** /**
* 一级类目的ID编号 * 一级类目的ID编号
*/ */
@SerializedName("first_id")
private String firstId; private String firstId;
/** /**
* 二级类目的ID编号 * 二级类目的ID编号
*/ */
@SerializedName("second_id")
private String secondId; private String secondId;
/** /**
* 三级类目的ID编号 * 三级类目的ID编号
*/ */
@SerializedName("third_id")
private String thirdId; private String thirdId;
} }

20
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

@ -61,17 +61,21 @@
<select id="selectAll" resultType="com.epmet.dto.CustomerMpDTO"> <select id="selectAll" resultType="com.epmet.dto.CustomerMpDTO">
SELECT SELECT
id, cm.id,
customer_id, cm.customer_id,
client, cm.client,
app_id, cm.app_id,
authorization_flag cm.authorization_flag
FROM FROM
customer_mp customer_mp cm
INNER JOIN pa_customer pc ON cm.customer_id = pc.id
WHERE WHERE
del_flag = '0' cm.del_flag = '0'
AND pc.del_flag = '0'
AND pc.source = '#{source}'
ORDER BY ORDER BY
customer_id ASC, client ASC cm.customer_id ASC,
cm.client ASC
</select> </select>
<select id="selectAuthFlag" resultType="java.lang.Boolean"> <select id="selectAuthFlag" resultType="java.lang.Boolean">
SELECT SELECT

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml

@ -52,6 +52,7 @@
WHERE WHERE
pca.del_flag = '0' pca.del_flag = '0'
AND pc.del_flag = '0' AND pc.del_flag = '0'
AND pc.source = #{source}
ORDER BY ORDER BY
pca.CREATED_TIME DESC pca.CREATED_TIME DESC
</select> </select>
@ -64,6 +65,7 @@
pa_customer pa_customer
WHERE WHERE
del_flag = '0' del_flag = '0'
AND source = #{source}
<if test='null != initState and "" != initState'> <if test='null != initState and "" != initState'>
AND is_initialize = #{initState} AND is_initialize = #{initState}
</if> </if>

32
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerUserAgencyDao.xml

@ -5,15 +5,33 @@
<select id="selectByUserId" resultType="com.epmet.dto.PaCustomerUserAgencyDTO"> <select id="selectByUserId" resultType="com.epmet.dto.PaCustomerUserAgencyDTO">
SELECT SELECT
id, pcua.id,
customer_id, pcua.customer_id,
agency_id, pcua.agency_id,
user_id pcua.user_id
FROM FROM
pa_customer_user_agency pa_customer_user_agency pcua
LEFT JOIN pa_user pu ON pu.id = pcua.user_id
WHERE WHERE
del_flag = '0' pcua.del_flag = '0'
AND user_id = #{userId} AND pu.del_flag = '0'
AND pcua.user_id = #{userId}
AND pu.source = #{source}
</select>
<select id="selectCustomerIdByUserId" resultType="com.epmet.dto.PaCustomerUserAgencyDTO">
SELECT
pcua.id,
pcua.customer_id,
pcua.agency_id,
pcua.user_id
FROM
pa_customer_user_agency pcua
LEFT JOIN pa_user pu ON pu.id = pcua.user_id
WHERE
pcua.del_flag = '0'
AND pu.del_flag = '0'
AND pcua.user_id = #{userId}
</select> </select>
</mapper> </mapper>

19
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml

@ -8,12 +8,14 @@
id, id,
phone, phone,
real_name, real_name,
gender gender,
source
FROM FROM
pa_user pa_user
WHERE WHERE
del_flag = '0' del_flag = '0'
AND phone = #{phone} AND phone = #{phone}
AND source = #{source}
</select> </select>
<select id="selectPaUser" resultType="com.epmet.dto.PaUserDTO"> <select id="selectPaUser" resultType="com.epmet.dto.PaUserDTO">
@ -33,4 +35,19 @@
LIMIT 1 LIMIT 1
</select> </select>
<select id="selectUser" resultType="com.epmet.dto.PaUserDTO">
SELECT
id,
phone,
real_name,
gender,
source
FROM
pa_user
WHERE
del_flag = '0'
AND id = #{id}
AND source = #{source}
</select>
</mapper> </mapper>

4
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserVisitedDao.xml

@ -9,11 +9,13 @@
user_id, user_id,
wx_open_id, wx_open_id,
open_id, open_id,
phone phone,
source
FROM FROM
pa_user_visited pa_user_visited
WHERE WHERE
del_flag = '0' del_flag = '0'
AND source = #{source}
AND wx_open_id = #{openId} AND wx_open_id = #{openId}
ORDER BY ORDER BY
created_time DESC created_time DESC

31
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserWechatDao.xml

@ -5,22 +5,25 @@
<select id="selectWechatByOpenId" resultType="com.epmet.dto.PaUserWechatDTO"> <select id="selectWechatByOpenId" resultType="com.epmet.dto.PaUserWechatDTO">
SELECT SELECT
id, puw.id,
user_id, puw.user_id,
wx_open_id, puw.wx_open_id,
union_id, puw.union_id,
gender, puw.gender,
nickname, puw.nickname,
head_img_url, puw.head_img_url,
country, puw.country,
province, puw.province,
city, puw.city,
`language` puw.`language`
FROM FROM
pa_user_wechat pa_user_wechat puw
INNER JOIN pa_user pu ON puw.user_id = pu.id
WHERE WHERE
del_flag = '0' puw.del_flag = '0'
AND wx_open_id = #{openId} AND pu.del_flag = '0'
AND pu.source = #{source}
AND puw.wx_open_id = #{openId}
</select> </select>
<select id="selectWechatByUserId" resultType="com.epmet.entity.PaUserWechatEntity"> <select id="selectWechatByUserId" resultType="com.epmet.entity.PaUserWechatEntity">

2
epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
oper-crm-server: oper-crm-server:
container_name: oper-crm-server-dev container_name: oper-crm-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.55 image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.56
ports: ports:
- "8090:8090" - "8090:8090"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-module/oper-crm/oper-crm-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.3.55</version> <version>0.3.56</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>oper-crm</artifactId> <artifactId>oper-crm</artifactId>

10
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

@ -18,6 +18,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -27,6 +28,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.RoleKeyConstants; import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.UserWorkType; import com.epmet.constant.UserWorkType;
@ -402,11 +404,12 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void init(CustomerInitFormDTO formDTO) { public void init(CustomerInitFormDTO formDTO) {
//1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息 //1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息
Result<InitCustomerResultDTO> thirdResult = epmetThirdFeignClient.getCustomerAgencyUser(formDTO.getCustomerId()); String url = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/getcustomeragencyuser/" + formDTO.getCustomerId();
Result<String> thirdResult = HttpClientManager.getInstance().sendPostByJSON(url, null);
if (!thirdResult.success()) { if (!thirdResult.success()) {
throw new RenException(thirdResult.getCode(), thirdResult.getInternalMsg()); throw new RenException(thirdResult.getCode(), thirdResult.getInternalMsg());
} }
InitCustomerResultDTO initCustomer = thirdResult.getData(); InitCustomerResultDTO initCustomer = JSONObject.parseObject(thirdResult.getData(), InitCustomerResultDTO.class);
PaCustomerDTO paCustomer = initCustomer.getPaCustomer(); PaCustomerDTO paCustomer = initCustomer.getPaCustomer();
PaCustomerAgencyDTO paAgency = initCustomer.getPaAgency(); PaCustomerAgencyDTO paAgency = initCustomer.getPaAgency();
PaUserDTO paUser = initCustomer.getPaUser(); PaUserDTO paUser = initCustomer.getPaUser();
@ -486,7 +489,8 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
} }
//6.更新第三方数据库中客户数据状态为已初始化 //6.更新第三方数据库中客户数据状态为已初始化
Result customerResult = epmetThirdFeignClient.updateCustomer(formDTO.getCustomerId()); String customerUrl = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/updatecustomer/" + formDTO.getCustomerId();
Result<String> customerResult = HttpClientManager.getInstance().sendPostByJSON(customerUrl, null);
if (!customerResult.success()) { if (!customerResult.success()) {
throw new RenException(customerResult.getCode(), customerResult.getInternalMsg()); throw new RenException(customerResult.getCode(), customerResult.getInternalMsg());
} }

11
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/GuideHttpUrlConstant.java

@ -0,0 +1,11 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 13:56
*/
public interface GuideHttpUrlConstant {
String CUSTOMER_MSG_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
}

32
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java

@ -1,6 +1,8 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -11,7 +13,9 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.GuideHttpUrlConstant;
import com.epmet.constant.StrangerResiGuideConstant; import com.epmet.constant.StrangerResiGuideConstant;
import com.epmet.dao.StrangerAccessRecordDao; import com.epmet.dao.StrangerAccessRecordDao;
import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaCustomerDTO;
@ -255,12 +259,7 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
public Result<List<PublicCustomerGridForStrangerResultDTO>> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO) { public Result<List<PublicCustomerGridForStrangerResultDTO>> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO) {
//0.调用epmet-third服务,根据appId查询客户信息 //0.调用epmet-third服务,根据appId查询客户信息
Result<PublicCustomerResultDTO> result = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId());
if(!result.success()){
throw new RenException(result.getCode());
}
PublicCustomerResultDTO resultDTO = result.getData();
PaCustomerDTO customer = resultDTO.getCustomer();
ThirdCustomerGridListFormDTO third = new ThirdCustomerGridListFormDTO(); ThirdCustomerGridListFormDTO third = new ThirdCustomerGridListFormDTO();
third.setCustomerId(customer.getId()); third.setCustomerId(customer.getId());
@ -306,4 +305,25 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
} }
/**
* @Description 获取客户信息
* @param appId
* @author zxc
*/
public PaCustomerDTO getCustomerInfo(String appId){
JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(GuideHttpUrlConstant.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;
}
} }

Loading…
Cancel
Save