Browse Source

Merge remote-tracking branch 'remotes/origin/dev_thirdplatform' into dev_heart

# Conflicts:
#	epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
master
jianjun 5 years ago
parent
commit
f9a29ebb11
  1. 2
      epmet-auth/deploy/docker-compose-dev.yml
  2. 2
      epmet-auth/pom.xml
  3. 14
      epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java
  4. 9
      epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java
  5. 40
      epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java
  6. 25
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  7. 2
      epmet-gateway/deploy/docker-compose-prod.yml
  8. 2
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml
  9. 2
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml
  10. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  11. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java
  12. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java
  13. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java
  14. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java
  15. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java
  16. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java
  17. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java
  18. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
  19. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java
  20. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java
  21. 129
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java
  22. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java
  23. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java
  24. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
  25. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java
  26. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java
  27. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
  28. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java
  29. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java
  30. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java
  31. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
  32. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java
  33. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java
  34. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java
  35. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
  36. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml
  37. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml
  38. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
  39. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml
  40. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml
  41. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml
  42. 17
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml
  43. 17
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml
  44. 3
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java
  45. 2
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java
  46. 86
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java
  47. 5
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java
  48. 5
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java
  49. 24
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java
  50. 4
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java
  51. 31
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java
  52. 15
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java
  53. 11
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java
  54. 2
      epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml
  55. 8
      epmet-module/epmet-third/epmet-third-server/pom.xml
  56. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  57. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java
  58. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java
  59. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java
  60. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java
  61. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java
  62. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java
  63. 23
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
  64. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java
  65. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java
  66. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java
  67. 11
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserVisitedDao.java
  68. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java
  69. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java
  70. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java
  71. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  72. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java
  73. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java
  74. 99
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  75. 367
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  76. 111
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  77. 39
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java
  78. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java
  79. 20
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  80. 101
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java
  81. 23
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java
  82. 19
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java
  83. 35
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  84. 15
      epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml
  85. 21
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml
  86. 19
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
  87. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml
  88. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml
  89. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml
  90. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
  91. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml
  92. 20
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  93. 9
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml
  94. 16
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserVisitedDao.xml
  95. 2
      epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml
  96. 2
      epmet-module/gov-org/gov-org-server/pom.xml
  97. 2
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  98. 2
      epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml
  99. 2
      epmet-module/resi-guide/resi-guide-server/pom.xml
  100. 2
      epmet-user/epmet-user-server/deploy/docker-compose-dev.yml

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-auth-server:
container_name: epmet-auth-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.43
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.44
ports:
- "8081:8081"
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"
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>
<version>0.3.43</version>
<version>0.3.44</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>

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

@ -9,6 +9,7 @@ import com.epmet.constant.PublicUserLoginConstant;
import com.epmet.dto.form.LoginByPhoneFormDTO;
import com.epmet.dto.form.PaWxCodeFormDTO;
import com.epmet.dto.form.PublicSendSmsCodeFormDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.PublicUserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,5 +71,18 @@ public class PublicUserLoginController {
return new Result<UserTokenResultDTO>().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO));
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 公众号-手机号注册
**/
@PostMapping(value = "/register")
public Result<UserTokenResultDTO> register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class);
formDTO.setUserId(tokenDTO.getUserId());
return new Result<UserTokenResultDTO>().ok(publicUserLoginService.register(formDTO));
}
}

9
epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.LoginByPhoneFormDTO;
import com.epmet.dto.form.PaWxCodeFormDTO;
import com.epmet.dto.form.PublicSendSmsCodeFormDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
/**
@ -38,4 +39,12 @@ public interface PublicUserLoginService {
**/
UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 公众号-手机号注册
**/
UserTokenResultDTO register(RegisterFormDTO formDTO);
}

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

@ -1,8 +1,10 @@
package com.epmet.service.impl;
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.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils;
@ -14,10 +16,7 @@ import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserWechatDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.dto.result.SendVerificationCodeResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.jwt.JwtTokenProperties;
@ -33,8 +32,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -242,4 +243,35 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
return userTokenResultDTO;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 公众号-手机号注册
**/
@Override
public UserTokenResultDTO register(RegisterFormDTO formDTO) {
//1.调用epmet-third服务,完成信息注册
Result<RegisterResultDTO> result = epmetThirdFeignClient.register(formDTO);
if (!result.success()) {
logger.error("调用epmet_third服务初始化用户信息失败");
throw new RenException(result.getCode());
}
RegisterResultDTO resultDTO = result.getData();
//2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成)
//2-1.生成token
String token = this.generateGovWxmpToken(resultDTO.getUserId());
//2-2.token存入redis
String openid = resultDTO.getOpenId();
String unionId = (null == resultDTO.getUnionId() ? "" : resultDTO.getUnionId());
this.saveLatestGovTokenDto("", resultDTO.getUserId(), openid, unionId, token);
//3.返回token
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return userTokenResultDTO;
}
}

25
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -23,7 +23,9 @@ import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
@ -46,6 +48,8 @@ import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -170,12 +174,21 @@ public class HttpClientManager {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
FileBody fileBody = new FileBody(file);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("media", fileBody).build();
httppost.setEntity(reqEntity);
return execute(httppost,false);
String boundaryStr = "------------" + System.currentTimeMillis();
httppost.addHeader("Connection", "keep-alive");
httppost.addHeader("Accept", "*/*");
httppost.addHeader("Content-Type", "multipart/form-data;boundary=" + boundaryStr);
httppost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
MultipartEntityBuilder meb = MultipartEntityBuilder.create();
meb.setBoundary(boundaryStr).setCharset(StandardCharsets.UTF_8).setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
meb.addBinaryBody("media", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
HttpEntity entity = meb.build();
httppost.setEntity(entity);
// FileBody fileBody = new FileBody(file);
// HttpEntity reqEntity = MultipartEntityBuilder.create()
// .addPart("media", fileBody).build();
// httppost.setEntity(reqEntity);
return execute(httppost);
} catch (Exception e) {
log.error("send exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());

2
epmet-gateway/deploy/docker-compose-prod.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-gateway-server:
container_name: epmet-gateway-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.25
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.26
ports:
- "8080:8080"
network_mode: host # 使用现有网络

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

@ -2,7 +2,7 @@ version: "3.7"
services:
data-statistical-server:
container_name: data-statistical-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.39
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.41
ports:
- "8108:8108"
network_mode: host # 使用现有网络

2
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
data-statistical-server:
container_name: data-statistical-server-test
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/data-statistical-server:0.3.39
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/data-statistical-server:0.3.41
ports:
- "8108:8108"
network_mode: host # 使用现有网络

2
epmet-module/data-statistical/data-statistical-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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.39</version>
<version>0.3.41</version>
<parent>
<artifactId>data-statistical</artifactId>
<groupId>com.epmet</groupId>

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java

@ -43,4 +43,6 @@ public interface CustomerDao extends BaseDao<CustomerEntity> {
List<CustomerEntity> listValidCustomersByCreateTime(
@Param("createTimeFrom") Date createTimeFrom,
@Param("createTimeTo") Date createTimeTo);
List<CustomerEntity> listValidCustomersByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java

@ -38,4 +38,5 @@ public interface CustomerDepartmentDao extends BaseDao<CustomerDepartmentEntity>
@Param("createdTimeFrom") Date createdTimeFrom,
@Param("createdTimeTo") Date createdTimeTo);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java

@ -59,4 +59,12 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @author zxc
*/
List<GridIdListByCustomerResultDTO> getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId);
/**
* 根据更新时间查询列表
* @param startTime
* @param endTime
* @return
*/
List<CustomerGridEntity> listUpdatedGridsByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java

@ -20,4 +20,6 @@ public interface StatsCustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
List<AgencySubTreeDto> selectAllAgency();
List<AgencySubTreeDto> selectSubAgencyByPid(@Param("pid")String pid);
List<CustomerAgencyEntity> listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java

@ -124,4 +124,6 @@ public interface DimAgencyDao extends BaseDao<DimAgencyEntity> {
String getPidByAgencyId(@Param("agencyId") String agencyId);
DimAgencyEntity getLatestCreatedAgencyDimEntity();
DimAgencyEntity getLatestUpdatedAgencyDimEntity();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java

@ -47,4 +47,6 @@ public interface DimCustomerDao extends BaseDao<DimCustomerEntity> {
void insertOne(DimCustomerEntity dim);
DimCustomerEntity getLatestCreatedDimEntity();
DimCustomerEntity getLatestUpdatedDimEntity();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java

@ -42,4 +42,6 @@ public interface DimDepartmentDao extends BaseDao<DimDepartmentEntity> {
List<DimDepartmentEntity> getDepartmentListByCustomerId(@Param("customerId") String customerId);
DimDepartmentEntity getLatestCreatedDimEntity();
DimDepartmentEntity getLatestUpdatedDimEntity();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java

@ -58,4 +58,6 @@ public interface DimGridDao extends BaseDao<DimGridEntity> {
* @author zxc
*/
List<SubAgencyIdResultDTO> selectSubAgencyId(@Param("formDTO")List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java

@ -9,4 +9,5 @@ public interface CustomerService {
List<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo);
List<CustomerEntity> listValidCustomersByUpdatedTime(Date updatedTime, Date initTime);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java

@ -22,4 +22,9 @@ public class CustomerServiceImpl implements CustomerService {
public List<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) {
return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo);
}
@Override
public List<CustomerEntity> listValidCustomersByUpdatedTime(Date startTime, Date endTime) {
return customerDao.listValidCustomersByUpdateTime(startTime, endTime);
}
}

129
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java

@ -1,8 +1,6 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.RobotConstant;
import com.epmet.constant.StatsSubject;
import com.epmet.entity.crm.CustomerEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
@ -18,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -54,6 +53,17 @@ public class StatsDimServiceImpl implements StatsDimService {
@Override
public void initGridDim() {
List<DimGridEntity> newDimGrids = getNewDimGrids();
List<DimGridEntity> changedGrids = getChangedGrids();
dimGridService.initGridDims(newDimGrids, changedGrids);
}
/**
* 初始化新建网格
* @return
*/
public List<DimGridEntity> getNewDimGrids() {
DimGridEntity lastDimEntity = dimGridService.getLastCreatedGridDim();
List<CustomerGridEntity> grids;
Date now = new Date();
@ -65,10 +75,36 @@ public class StatsDimServiceImpl implements StatsDimService {
grids = customerGridService.listGridsByCreateTime(lastInitTime, now);
}
List<DimGridEntity> gridDims = convertCustomerGrid2GridDim(grids, now);
if (!CollectionUtils.isEmpty(gridDims)) {
dimGridService.initGridDims(gridDims);
return convertCustomerGrid2GridDim(grids, now);
}
/**
* 初始化变更的网格
* @return
*/
public List<DimGridEntity> getChangedGrids() {
DimGridEntity lastUpdatedGridDim = dimGridService.getLastUpdatedGridDim();
List<CustomerGridEntity> updatedGrids;
Date now = new Date();
if (lastUpdatedGridDim != null) {
Date lastInitTime = lastUpdatedGridDim.getUpdatedTime();
updatedGrids = customerGridService.listUpdatedGridsByUpdateTime(lastInitTime, now);
ArrayList<DimGridEntity> dimGrids = new ArrayList<>();
for (CustomerGridEntity updatedGrid : updatedGrids) {
DimGridEntity dimGrid = dimGridService.selectById(updatedGrid.getId());
if (dimGrid != null) {
dimGrid.setGridName(updatedGrid.getGridName());
dimGrid.setUpdatedTime(now);
dimGrid.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
dimGrids.add(dimGrid);
}
}
return dimGrids;
}
return new ArrayList<>();
}
/**
@ -98,19 +134,41 @@ public class StatsDimServiceImpl implements StatsDimService {
*/
@Override
public void initAgencyDim() {
Date now = new Date();
List<CustomerAgencyEntity> agencies2Add = listAgencies2Add(now);
List<CustomerAgencyEntity> agencies2Update = listAgencies2Update(now);
dimAgencyService.initAgencyDims(agencies2Add, agencies2Update, now);
}
/**
* 查询需要添加的机关ç
* @return
*/
public List<CustomerAgencyEntity> listAgencies2Add(Date endDate) {
DimAgencyEntity latestCreatedAgencyDim = dimAgencyService.getLatestCreatedAgencyDimEntity();
Date now = new Date();
Date lastInitTime = null;
if (latestCreatedAgencyDim != null) {
lastInitTime = latestCreatedAgencyDim.getCreatedTime();
}
List<CustomerAgencyEntity> agencies = customerAgencyService.listAgenciesByCreateTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(agencies)) {
dimAgencyService.initAgencyDims(agencies, now);
return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate);
}
/**
* 查询需要更新的机关
* @return
*/
public List<CustomerAgencyEntity> listAgencies2Update(Date endDate) {
DimAgencyEntity latestUpdatedAgencyDim = dimAgencyService.getLatestUpdatedAgencyDimEntity();
if (latestUpdatedAgencyDim != null) {
// 不是首次初始化,可以更新
Date updatedTime = latestUpdatedAgencyDim.getUpdatedTime();
return customerAgencyService.listAgenciesByUpdatedTime(updatedTime, endDate);
}
return new ArrayList<>();
}
/**
@ -118,24 +176,59 @@ public class StatsDimServiceImpl implements StatsDimService {
*/
@Override
public void initCustomerDim() {
Date now = new Date();
List<CustomerEntity> newCustomers = listNewCustomers(now);
List<CustomerEntity> updatedCustomers = listUpdatedCustomers(now);
// System.out.println(666);
dimCustomerService.initCustomerDims(newCustomers, updatedCustomers, now);
}
/**
* 查询新增的客户列表
* @param initTime
* @return
*/
public List<CustomerEntity> listNewCustomers(Date initTime) {
DimCustomerEntity lastCreateDim = dimCustomerService.getLatestCreatedDimEntity();
Date now = new Date();
Date lastInitTime = null;
if (lastCreateDim != null) {
lastInitTime = lastCreateDim.getCreatedTime();
}
List<CustomerEntity> customers = customerService.listValidCustomersByCreateTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(customers)) {
dimCustomerService.initCustomerDims(customers, now);
List<CustomerEntity> customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime);
return customers;
}
/**
* 查询更新的客户列表
* @param initTime
* @return
*/
public List<CustomerEntity> listUpdatedCustomers(Date initTime) {
DimCustomerEntity lastCreatedDim = dimCustomerService.getLatestUpdatedDimEntity();
if (lastCreatedDim != null) {
// 说明不是首次初始化
List<CustomerEntity> customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime);
return customers;
}
return new ArrayList<>();
}
/**
* 初始化部门维度
*/
@Override
public void initDepartmentDim() {
Date now = new Date();
List<CustomerDepartmentEntity> newDepartments = listNewDepartments(now);
List<CustomerDepartmentEntity> updatedDepartments = listUpdatedDepartments(now);
dimDepartmentService.initDepartmentDims(newDepartments, updatedDepartments, now);
}
public List<CustomerDepartmentEntity> listNewDepartments(Date initTime) {
DimDepartmentEntity lastCreatedDeptDim = dimDepartmentService.getLatestCreatedDimEntity();
Date now = new Date();
@ -144,10 +237,14 @@ public class StatsDimServiceImpl implements StatsDimService {
if (lastCreatedDeptDim != null) {
lastInitTime = lastCreatedDeptDim.getCreatedTime();
}
return departmentService.listDepartmentsByCreatedTime(lastInitTime, now);
}
List<CustomerDepartmentEntity> departments = departmentService.listDepartmentsByCreatedTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(departments)) {
dimDepartmentService.initDepartmentDims(departments, now);
public List<CustomerDepartmentEntity> listUpdatedDepartments(Date initTime) {
DimDepartmentEntity lastUpdatedDeptDim = dimDepartmentService.getLatestUpdatedDimEntity();
if (lastUpdatedDeptDim != null) {
return departmentService.listDepartmentsByUpdatedTime(lastUpdatedDeptDim.getCreatedTime(), initTime);
}
return new ArrayList<>();
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java

@ -7,4 +7,6 @@ import java.util.List;
public interface CustomerAgencyService {
List<CustomerAgencyEntity> listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime);
List<CustomerAgencyEntity> listAgenciesByUpdatedTime(Date updatedTime, Date now);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java

@ -8,4 +8,6 @@ import java.util.List;
public interface CustomerDepartmentService {
List<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date createdTime, Date initTime);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java

@ -32,4 +32,12 @@ public interface CustomerGridService {
* @author zxc
*/
List<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId);
/**
* 根据更新时间查询变更过的网格列表
* @param lastInitTime
* @param now
* @return
*/
List<CustomerGridEntity> listUpdatedGridsByUpdateTime(Date lastInitTime, Date now);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java

@ -22,4 +22,9 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService {
public List<CustomerAgencyEntity> listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) {
return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime);
}
@Override
public List<CustomerAgencyEntity> listAgenciesByUpdatedTime(Date startTime, Date endTime) {
return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime);
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java

@ -28,4 +28,9 @@ public class CustomerDepartmentServiceImpl implements CustomerDepartmentService
public List<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) {
return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo);
}
@Override
public List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date startTime, Date endTime) {
return departmentDao.listDepartmentsByUpdatedTime(startTime, endTime);
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java

@ -46,4 +46,9 @@ public class CustomerGridServiceImpl implements CustomerGridService {
public List<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId) {
return customerGridDao.getCustomerGridIdList(customerId, dateId);
}
@Override
public List<CustomerGridEntity> listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) {
return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now);
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java

@ -107,9 +107,8 @@ public interface DimAgencyService extends BaseService<DimAgencyEntity> {
/**
* 初始化机关维度
* @param agencies
*/
void initAgencyDims(List<CustomerAgencyEntity> agencies, Date initTime);
void initAgencyDims(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date initTime);
/**
* @Description 查询所有机关以及它下级机关的信息
@ -175,4 +174,6 @@ public interface DimAgencyService extends BaseService<DimAgencyEntity> {
String getPidByAgencyId(String agencyId);
DimAgencyEntity getLatestCreatedAgencyDimEntity();
DimAgencyEntity getLatestUpdatedAgencyDimEntity();
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java

@ -110,9 +110,10 @@ public interface DimCustomerService extends BaseService<DimCustomerEntity> {
/**
* 添加客户维度
* @param customers
*/
void initCustomerDims(List<CustomerEntity> customers, Date initTime);
void initCustomerDims(List<CustomerEntity> newCustomers, List<CustomerEntity> updatedCustomers, Date initTime);
DimCustomerEntity getLatestCreatedDimEntity();
DimCustomerEntity getLatestUpdatedDimEntity();
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java

@ -95,7 +95,7 @@ public interface DimDepartmentService extends BaseService<DimDepartmentEntity> {
*/
void delete(String[] ids);
void initDepartmentDims(List<CustomerDepartmentEntity> departments, Date initTime);
void initDepartmentDims(List<CustomerDepartmentEntity> newDepartments, List<CustomerDepartmentEntity> updatedDepartments, Date initTime);
/**
* desc: 根据客户Id获取 部门数据
@ -108,4 +108,6 @@ public interface DimDepartmentService extends BaseService<DimDepartmentEntity> {
List<DimDepartmentEntity> getDepartmentListByCustomerId(String customerId);
DimDepartmentEntity getLatestCreatedDimEntity();
DimDepartmentEntity getLatestUpdatedDimEntity();
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java

@ -101,9 +101,8 @@ public interface DimGridService extends BaseService<DimGridEntity> {
/**
* 初始化网格维度
* @param gridDims
*/
void initGridDims(List<DimGridEntity> gridDims);
void initGridDims(List<DimGridEntity> newDimGrids, List<DimGridEntity> changedGrids);
/**
* desc: 根据客户Id获取 该客户下所有的网格数据
@ -128,4 +127,6 @@ public interface DimGridService extends BaseService<DimGridEntity> {
* @author zxc
*/
List<SubAgencyIdResultDTO> selectSubAgencyId(List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
}

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java

@ -123,12 +123,25 @@ public class DimAgencyServiceImpl extends BaseServiceImpl<DimAgencyDao, DimAgenc
@Transactional(rollbackFor = Exception.class)
@Override
public void initAgencyDims(List<CustomerAgencyEntity> agencies, Date initTime) {
for (CustomerAgencyEntity agency : agencies) {
public void initAgencyDims(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date initTime) {
// 添加新增的机关维度
for (CustomerAgencyEntity agency : agencies2Add) {
initAgencyAllDim(agency, initTime);
initAgencySelfDim(agency, initTime);
}
// 更新变更过的机关维度
for (CustomerAgencyEntity agency : agencies2Update) {
DimAgencyEntity existsDimAgency = baseDao.selectById(agency.getId());
if (existsDimAgency != null) {
//说明是已存在的,不是新增的
existsDimAgency.setAgencyName(agency.getOrganizationName());
existsDimAgency.setUpdatedTime(initTime);
existsDimAgency.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
baseDao.updateById(existsDimAgency);
}
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_AGENCY);
}
@ -255,4 +268,9 @@ public class DimAgencyServiceImpl extends BaseServiceImpl<DimAgencyDao, DimAgenc
return baseDao.getLatestCreatedAgencyDimEntity();
}
@Override
public DimAgencyEntity getLatestUpdatedAgencyDimEntity() {
return baseDao.getLatestUpdatedAgencyDimEntity();
}
}

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java

@ -120,8 +120,9 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
@Transactional(rollbackFor = Exception.class)
@Override
public void initCustomerDims(List<CustomerEntity> customers, Date initTime) {
for (CustomerEntity customer : customers) {
public void initCustomerDims(List<CustomerEntity> newCustomers, List<CustomerEntity> updatedCustomers, Date initTime) {
// 添加新增的客户维度
for (CustomerEntity customer : newCustomers) {
DimCustomerEntity dim = new DimCustomerEntity();
dim.setCustomerName(customer.getCustomerName());
dim.setCreatedBy(RobotConstant.DIMENSION_ROBOT);
@ -131,6 +132,18 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
dim.setUpdatedTime(initTime);
baseDao.insert(dim);
}
// 更新已存在的客户维度
for (CustomerEntity updatedCustomer : updatedCustomers) {
DimCustomerEntity existsCustomerDim = baseDao.selectById(updatedCustomer.getId());
if (existsCustomerDim != null) {
existsCustomerDim.setCustomerName(updatedCustomer.getCustomerName());
existsCustomerDim.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
existsCustomerDim.setUpdatedTime(initTime);
baseDao.updateById(existsCustomerDim);
}
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_CUSTOMER);
}
@ -138,4 +151,9 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
public DimCustomerEntity getLatestCreatedDimEntity() {
return baseDao.getLatestCreatedDimEntity();
}
@Override
public DimCustomerEntity getLatestUpdatedDimEntity() {
return baseDao.getLatestUpdatedDimEntity();
}
}

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java

@ -109,8 +109,9 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
@Transactional(rollbackFor = Exception.class)
@Override
public void initDepartmentDims(List<CustomerDepartmentEntity> departments, Date initTime) {
for (CustomerDepartmentEntity department : departments) {
public void initDepartmentDims(List<CustomerDepartmentEntity> newDepartments, List<CustomerDepartmentEntity> updatedDepartments, Date initTime) {
// 新增科室初始化
for (CustomerDepartmentEntity department : newDepartments) {
DimDepartmentEntity dim = new DimDepartmentEntity();
dim.setAgencyId(department.getAgencyId());
dim.setCustomerId(department.getCustomerId());
@ -122,6 +123,18 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
dim.setUpdatedTime(initTime);
baseDao.insert(dim);
}
// 修改科室初始化
for (CustomerDepartmentEntity updatedDepartment : updatedDepartments) {
DimDepartmentEntity dimDepartment = baseDao.selectById(updatedDepartment.getId());
if (dimDepartment != null) {
dimDepartment.setDepartmentName(updatedDepartment.getDepartmentName());
dimDepartment.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
dimDepartment.setUpdatedTime(initTime);
baseDao.updateById(dimDepartment);
}
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_DEPARTMENT);
}
@ -137,4 +150,9 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
public DimDepartmentEntity getLatestCreatedDimEntity() {
return baseDao.getLatestCreatedDimEntity();
}
@Override
public DimDepartmentEntity getLatestUpdatedDimEntity() {
return baseDao.getLatestUpdatedDimEntity();
}
}

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java

@ -117,13 +117,16 @@ public class DimGridServiceImpl extends BaseServiceImpl<DimGridDao, DimGridEntit
/**
* 初始化网格维度
* @param gridDims
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void initGridDims(List<DimGridEntity> gridDims) {
for (DimGridEntity gridDim : gridDims) {
baseDao.insert(gridDim);
public void initGridDims(List<DimGridEntity> newDimGrids, List<DimGridEntity> changedGrids) {
for (DimGridEntity newGridDim : newDimGrids) {
baseDao.insert(newGridDim);
}
for (DimGridEntity updatedGridDim : changedGrids) {
baseDao.updateById(updatedGridDim);
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_GRID);
@ -156,4 +159,9 @@ public class DimGridServiceImpl extends BaseServiceImpl<DimGridDao, DimGridEntit
public List<SubAgencyIdResultDTO> selectSubAgencyId(List<AgencyDTO> formDTO) {
return baseDao.selectSubAgencyId(formDTO);
}
@Override
public DimGridEntity getLastUpdatedGridDim() {
return baseDao.getLastUpdatedGridDim();
}
}

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml

@ -41,4 +41,27 @@
CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC
</select>
<select id="listValidCustomersByUpdateTime" resultType="com.epmet.entity.crm.CustomerEntity">
select id,
customer_name,
title,
organization_number,
organization_img,
validity_time,
customer_admin,
customer_password,
organization_levels,
logo,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
organization_level
from customer
where UPDATED_TIME >= #{startTime}
and UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
</mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml

@ -16,4 +16,24 @@
</if>
</where>
</select>
<select id="listDepartmentsByUpdatedTime" resultType="com.epmet.entity.org.CustomerDepartmentEntity">
select
id,
customer_id,
agency_id,
department_name,
department_duty,
total_user,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from customer_department
where UPDATED_TIME > #{startTime}
and UPDATED_TIME <![CDATA[<=]]> #{endTime}
</select>
</mapper>

21
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -47,4 +47,25 @@
AND customer_id = #{customerId}
AND DATE_FORMAT( created_time, '%Y%m%d' ) <![CDATA[ <= ]]> #{dateId}
</select>
<select id="listUpdatedGridsByUpdateTime" resultType="com.epmet.entity.org.CustomerGridEntity">
SELECT id,
customer_id,
grid_name,
longitude,
latitude,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
manage_district,
total_user,
pid,
pids
FROM customer_grid
WHERE UPDATED_TIME >= #{startTime}
AND UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
</mapper>

25
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml

@ -75,4 +75,29 @@
grid.ID
</select>
<select id="listAgenciesByUpdatedTime" resultType="com.epmet.entity.org.CustomerAgencyEntity">
select
id,
customer_id,
pid,
pids,
all_parent_name,
organization_name,
level,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
total_user,
province,
city,
district
from customer_agency
where UPDATED_TIME >= #{startTime}
and UPDATED_TIME <![CDATA[<=]]> #{endTime}
</select>
</mapper>

21
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

@ -277,4 +277,25 @@
LIMIT 1
</select>
<!-- 最后一次更新的时间-->
<select id="getLatestUpdatedAgencyDimEntity" resultType="com.epmet.entity.stats.DimAgencyEntity">
select id,
agency_name,
customer_id,
pid,
pids,
all_parent_name,
level,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
agency_dim_type
from dim_agency
order by UPDATED_TIME desc
limit 1
</select>
</mapper>

15
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml

@ -25,4 +25,19 @@
ORDER BY CREATED_TIME DESC
LIMIT 1
</select>
<select id="getLatestUpdatedDimEntity" resultType="com.epmet.entity.stats.DimCustomerEntity">
select
id,
customer_name,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_customer
order by UPDATED_TIME desc
limit 1;
</select>
</mapper>

17
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml

@ -35,4 +35,21 @@
ORDER BY CREATED_TIME DESC
LIMIT 1
</select>
<select id="getLatestUpdatedDimEntity" resultType="com.epmet.entity.stats.DimDepartmentEntity">
select
id,
department_name,
agency_id,
customer_id,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_department
order by UPDATED_TIME desc
limit 1
</select>
</mapper>

17
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml

@ -52,4 +52,21 @@
</foreach>
</select>
<select id="getLastUpdatedGridDim" resultType="com.epmet.entity.stats.DimGridEntity">
select id,
grid_name,
customer_id,
agency_id,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_grid
order by UPDATED_TIME desc
limit 1;
</select>
</mapper>

3
epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java

@ -8,6 +8,7 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import com.epmet.commons.tools.utils.Result;
@ -25,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
* @author Mark sunlightcs@gmail.c om
* @since 1.1.0
*/
@FeignClient(name = "renren-oss-server", configuration = OssFeignClient.MultipartSupportConfig.class)
@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class)
public interface OssFeignClient {
/**
* 文件上传

2
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java

@ -61,7 +61,7 @@ public class CodeOperationHistoryDTO implements Serializable {
/**
* 描述
*/
private String describe;
private String description;
/**
* 乐观锁

86
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java

@ -0,0 +1,86 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author zxc
* @CreateTime 2020/7/24 9:22
*/
@Data
public class AuthResultRecordFormDTO implements Serializable {
private static final long serialVersionUID = -5359209459022630868L;
/**
* ID
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* resi居民端work工作端
*/
private String clientType;
/**
* 第三方平台AppId 第三方平台AppId
*/
private String componentAppId;
/**
* 微信返回创建时间 微信返回创建时间
*/
private Date wechatCreateTime;
/**
* 通知类型
*/
private String InfoType;
/**
* 授权方AppId
*/
private String AuthorizerAppid;
/**
* 授权码auth_code
*/
private String AuthorizationCode;
/**
* 授权码过期时间
*/
private Date ExpiredTime;
/**
* 预授权码
*/
private String PreAuthCode;
/**
* 删除状态
*/
private Integer delFlag = 0;
/**
* 乐观锁
*/
private Integer revision = 0;
/**
* 创建人
*/
private String createdBy = "APP_USER";
/**
* 更新人
*/
private String updatedBy = "APP_USER";
}

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

@ -44,6 +44,11 @@ public class AuthorizationInfoFormDTO implements Serializable {
*/
private String clientType;
/**
* 权限列表
*/
private String funcInfo;
private Integer delFlag = 0;
private String createdBy = "APP_USER";

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

@ -34,6 +34,11 @@ public class AuthorizerAccessTokenFormDTO implements Serializable {
*/
private String authAppid;
/**
* 客户端类型resi居民端work工作端
*/
private String clientType;
/**
* 客户ID
*/

24
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java

@ -43,84 +43,100 @@ public class SubmitAuditFormDTO implements Serializable {
/**
* 用户生成内容场景UGC信息安全声明
*/
private List<UgcDeclareBean> ugcDeclare;
private UgcDeclareBean ugcDeclare;
@NoArgsConstructor
@Data
private static class ItemListBean {
public static class ItemListBean {
/**
* 小程序的页面可通过获取小程序的页面列表接口获得
*/
@SerializedName("address")
private String address;
/**
* 小程序的标签用空格分隔标签至多 10 标签长度至多 20
*/
@SerializedName("tag")
private String tag;
/**
* 一级类目名称
*/
@SerializedName("first_class")
private String firstClass;
/**
* 二级类目名称
*/
@SerializedName("second_class")
private String secondClass;
/**
* 三级类目名称
*/
@SerializedName("third_class")
private String thirdClass;
/**
* 一级类目的 ID
*/
@SerializedName("first_id")
private String firstId;
/**
* 二级类目的 ID
*/
@SerializedName("second_id")
private String secondId;
/**
* 三级类目的 ID
*/
@SerializedName("third_id")
private String thirdId;
/**
* 小程序页面的标题,标题长度至多 32
*/
@SerializedName("title")
private String title;
}
@NoArgsConstructor
@Data
private static class PreviewInfoBean {
public static class PreviewInfoBean {
/**
* 录屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("Video_id_list")
private List<String> videoIdList;
/**
* 截屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("pic_id_list")
private List<String> picIdList;
}
@NoArgsConstructor
@Data
private static class UgcDeclareBean {
public static class UgcDeclareBean {
/**
* UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段
*/
@SerializedName("scene")
private List<Integer> scene;
/**
* 当scene选其他时的说明,不超时256字
*/
@SerializedName("other_scene_desc")
private String otherSceneDesc;
/**
* 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关
*/
@SerializedName("method")
private List<Integer> method;
/**
* 是否有审核团队, 0.,1.,默认0
*/
@SerializedName("has_audit_team")
private Integer hasAuditTeam;
/**
* 说明当前对UGC内容的审核机制,不超过256字
*/
@SerializedName("audit_desc")
private String auditDesc;
}
}

4
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java

@ -38,9 +38,9 @@ public class UploadListFormDTO implements Serializable {
/**
* 页数
*/
private Integer page;
private Integer pageNo;
/**
* 页面条数
*/
private Integer limit;
private Integer pageSize;
}

31
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author sun
* @Description 公众号-手机号注册-接口返参
*/
@Data
public class RegisterResultDTO implements Serializable {
private static final long serialVersionUID = 3253989119352850315L;
/**
* userId
*/
private String userId;
/**
* 用户微信openid
*/
private String openId;
/**
* 用户微信unionId
*/
private String unionId;
}

15
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java

@ -3,12 +3,10 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.SaveUserVisitedFormDTO;
import com.epmet.dto.form.WxLoginFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.PublicCustomerResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.dto.result.*;
import com.epmet.feign.fallback.EpmetThirdFeignClientFallback;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.cloud.openfeign.FeignClient;
@ -106,4 +104,13 @@ public interface EpmetThirdFeignClient {
**/
@PostMapping(value = "third/customermp/getcustomermsg/{appId}")
Result<PublicCustomerResultDTO> getCustomerMsg(@PathVariable("appId") String appId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 用户登陆新增访问记录数据
**/
@PostMapping(value = "third/pacustomer/register")
Result<RegisterResultDTO> register(@RequestBody RegisterFormDTO formDTO);
}

11
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java

@ -4,12 +4,10 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.SaveUserVisitedFormDTO;
import com.epmet.dto.form.WxLoginFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.PublicCustomerResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetThirdFeignClient;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.stereotype.Component;
@ -65,4 +63,9 @@ public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient {
public Result<PublicCustomerResultDTO> getCustomerMsg(String appId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerMsg", appId);
}
@Override
public Result<RegisterResultDTO> register(RegisterFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "register", formDTO);
}
}

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

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

8
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"
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>
<version>0.0.39</version>
<version>0.0.48</version>
<parent>
<groupId>com.epmet</groupId>
@ -135,6 +135,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

5
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -22,9 +22,12 @@ public interface ModuleConstant {
String AUTHORIZATION_CODE_HUMP = "AuthorizationCode";
String UNAUTHORIZED = "unauthorized";
String AUTHORIZED = "authorized";
String UPDATE_AUTHORIZED = "updateauthorized";
String NULL_CHAR = "";
String SUCCESS = "success";
String AUTHORIZER_APP_ID_HUMP = "AuthorizerAppid";
String PRE_AUTH_CODE_HUMP = "PreAuthCode";
String AUTHORIZATION_CODE_EXPIRED_TIME = "AuthorizationCodeExpiredTime";
// 获取 component_access_token 如下
String COMPONENT_APPID = "component_appid";
@ -65,7 +68,7 @@ public interface ModuleConstant {
String COMPONENT_APP_ID = "component_appid";
String AUTHORIZER_APP_ID = "authorizer_appid";
String AUTHORIZER_INFO = "authorizer_info";
String MINI_PROGRAM_INFO = "miniprograminfo";
String MINI_PROGRAM_INFO = "MiniProgramInfo";
String BUSINESS_INFO = "business_info";
String CATEGORIES = "categories";
String NETWORK = "network";

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java

@ -22,6 +22,14 @@ public interface PaConstant {
* 保存用户访问记录数据失败
*/
String SAVE_VISITED_EXCEPTION = "保存用户访问记录数据失败";
/**
* 保存用户数据失败
*/
String SAVE_USER_EXCEPTION = "保存用户数据失败";
/**
* 保存用户微信基本数据失败
*/
String SAVE_WECHAT_EXCEPTION = "保存用户微信信息失败";
/**
* 组织级别对应的keyname

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java

@ -44,7 +44,7 @@ public interface ThirdRedisKeyConstant {
/**
* authorization_info 授权信息
*/
String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo";
String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo:";
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java

@ -46,7 +46,7 @@ public interface ThirdRunTimeInfoConstant {
String END_GET_AUTH_INFO = "=====================结束获取【authorization_info】=====================";
String CREATE_AND_BIND_SUCCESS = "创建开放平台帐号并绑定公众号/小程序";
String CREATE_AND_BIND_SUCCESS = "开始创建开放平台帐号并绑定公众号/小程序";
String BIND_SUCCESS = "绑定公众号/小程序到开放平台";
@ -82,4 +82,6 @@ public interface ThirdRunTimeInfoConstant {
String VERIFY_TICKET = "msgSignature = %s, timeStamp = %s, nonce = %s, encryptType = %s, signature = %s";
String REFRESH_AUTH_ACCESS_TOKEN = "查询到新的 授权方【access_token】";
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java

@ -49,7 +49,7 @@ public class CodeController {
* @date 2020/7/17 16:22
*/
@PostMapping("getextjson")
public Result<String> getExtJson(CodeUploadFormDTO formDTO) {
public Result<String> getExtJson(@RequestBody CodeUploadFormDTO formDTO) {
String extJson = codeService.getExtJson(formDTO);
return new Result<String>().ok(extJson);
}
@ -175,7 +175,7 @@ public class CodeController {
* @date 2020/7/17 11:20
*/
@PostMapping("mediaupload")
public Result<String> mediaUpload(@RequestBody MediaUploadFormDTO formDTO) {
public Result<String> mediaUpload(MediaUploadFormDTO formDTO) {
String result = codeService.mediaUpload(formDTO);
return new Result<String>().ok(result);
}

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

@ -45,11 +45,8 @@ public class PaCustomerController {
* @Description 公众号-手机号注册
**/
@PostMapping("register")
public Result register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class);
formDTO.setUserId(tokenDTO.getUserId());
paCustomerService.register(formDTO);
return new Result();
public Result<RegisterResultDTO> register(@RequestBody RegisterFormDTO formDTO) {
return new Result<RegisterResultDTO>().ok(paCustomerService.register(formDTO));
}
/**

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.AuthResultRecordFormDTO;
import com.epmet.entity.AuthResultRecordEntity;
import org.apache.ibatis.annotations.Mapper;
@ -29,5 +30,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface AuthResultRecordDao extends BaseDao<AuthResultRecordEntity> {
/**
* @Description 插入授权结果记录
* @param formDTO
* @author zxc
*/
void insertAuthResultRecord(AuthResultRecordFormDTO formDTO);
}

23
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.AuthorizationInfoDTO;
import com.epmet.dto.form.AuthorizationInfoFormDTO;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.result.AuthCodeResultDTO;
import com.epmet.dto.result.WillOverDueResultDTO;
import com.epmet.entity.AuthorizationInfoEntity;
import org.apache.ibatis.annotations.Mapper;
@ -44,13 +45,6 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
*/
void insertAuthorizationInfo(AuthorizationInfoFormDTO formDTO);
/**
* @Description 逻辑删除授权信息
* @param customerId
* @author zxc
*/
void updateOldAuthorizationInfo(@Param("customerId")String customerId);
/**
* 根据客户ID客户端类型获取授权信息
* @author zhaoqifeng
@ -60,7 +54,13 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
* @return com.epmet.dto.AuthorizationInfoDTO
*/
AuthorizationInfoDTO getAuthInfoByCustomer(@Param("customerId") String customerId, @Param("clientType") String clientType);
void updateOldAuthorizationInfo(@Param("customerId")String customerId,@Param("clientType")String clientType);
/**
* @Description 逻辑删除授权信息
* @param authAppId
* @author zxc
*/
void updateOldAuthorizationInfo(@Param("authAppId")String authAppId);
/**
* @Description 查询即将过期的 authorizer_access_token
@ -83,4 +83,11 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
*/
void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType);
/**
* @Description 根据 authAppId 查询客户ID和客户端类型
* @param authAppId
* @author zxc
*/
AuthCodeResultDTO selectCustomerIdByAuthAppId(@Param("authAppId")String authAppId);
}

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

@ -39,10 +39,10 @@ public interface ComponentVerifyTicketDao extends BaseDao<ComponentVerifyTicketE
void insertComponentVerifyTicket(ComponentVerifyTicketFormDTO formDTO);
/**
* @Description 逻辑删除 component_verify_ticket
* @Description 物理删除 component_verify_ticket
* @param
* @author zxc
*/
void updateOldComponentVerifyTicket();
void deleteOldComponentVerifyTicket();
}

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

@ -58,7 +58,7 @@ public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
* @param customerId
* @author zxc
*/
Integer selectAuthCount(@Param("customerId")String customerId);
List<String> selectAuthCount(@Param("customerId")String customerId);
/**
* @Description 回填customer_mp的appId
@ -107,4 +107,12 @@ public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
* @Description 根据appId查询客户信息
**/
PaCustomerDTO selectCustomerByAppId(@Param("appId") String appId);
/**
* @Description 校验此小程序是不是绑定别的客户端
* @param authAppId
* @param clientType
* @author zxc
*/
Integer checkBind(String authAppId,String clientType);
}

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java

@ -41,6 +41,13 @@ public interface OpenPlatformAccountDao extends BaseDao<OpenPlatformAccountEntit
*/
void insertOpenPlatFormAccount(CreateOpenFormDTO coForm);
/**
* @Description 删除客户下报废的开放平台账号信息
* @param customerId
* @author zxc
*/
void deleteOldOpenPlatFprmAccount(@Param("customerId")String customerId);
/**
* @Description 根据客户Id查询已绑定开放平台的账号ID
* @param customerId

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

@ -18,8 +18,10 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaUserVisitedDTO;
import com.epmet.entity.PaUserVisitedEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 公众号登陆记录表
@ -29,5 +31,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface PaUserVisitedDao extends BaseDao<PaUserVisitedEntity> {
/**
* @param openId
* @return
* @Author sun
* @Description 根据openId查询登陆访问记录数据按时间倒序
**/
PaUserVisitedDTO selectByOpenId(@Param("openId") String openId);
}

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

@ -23,6 +23,8 @@ import com.epmet.entity.PaUserWechatEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 公众号用户信息
*
@ -38,7 +40,7 @@ public interface PaUserWechatDao extends BaseDao<PaUserWechatEntity> {
* @Author sun
* @Description 根据openId查询user_wechat表信息
**/
PaUserWechatDTO selectWechatByOpenId(@Param("openId") String openId);
List<PaUserWechatDTO> selectWechatByOpenId(@Param("openId") String openId);
/**
* @param dto

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java

@ -61,6 +61,6 @@ public class CodeOperationHistoryEntity extends BaseEpmetEntity {
/**
* 描述
*/
private String describe;
private String description;
}

5
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java

@ -121,8 +121,9 @@ public class RedisThird {
* @author zxc
*/
public void setAuthInfo(AuthorizationInfoResultDTO authInfo,String customerId,String clientType){
String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY+ThirdRedisKeyConstant.COLON+customerId+ThirdRedisKeyConstant.COLON+clientType;
redisUtils.set(key,authInfo,-1);
Map<String, Object> map = BeanUtil.beanToMap(authInfo, false, true);
String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + customerId+ThirdRedisKeyConstant.COLON + clientType;
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

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

@ -105,7 +105,7 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
* @Author sun
* @Description 公众号-手机号注册
**/
void register(RegisterFormDTO formDTO);
RegisterResultDTO register(RegisterFormDTO formDTO);
/**
* @return

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

@ -99,5 +99,5 @@ public interface PaUserWechatService extends BaseService<PaUserWechatEntity> {
* @Author sun
* @Description 根据openId查询user_wechat表信息
**/
PaUserWechatDTO getWechatByOpenId(String openId);
List<PaUserWechatDTO> getWechatByOpenId(String openId);
}

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java

@ -107,7 +107,7 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl<CodeCustomerDao, Co
@Override
public PageData getCodeList(UploadListFormDTO formDTO) {
PageHelper.startPage(formDTO.getPage(), formDTO.getLimit());
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
List<UploadListResultDTO> list = baseDao.selectCodeList(formDTO);
PageInfo<UploadListResultDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());

99
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java

@ -13,8 +13,12 @@ import com.epmet.dao.AuthorizationInfoDao;
import com.epmet.dao.ComponentAccessTokenDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.dto.result.CodeHistoryResultDTO;
import com.epmet.dto.result.QrCodeResultDTO;
import com.epmet.dto.result.ReasonResultDTO;
import com.epmet.dto.result.TemplateListResultDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.*;
import com.epmet.wxapi.param.WxMaCodeAuditStatusReq;
import com.epmet.wxapi.param.WxMaCodeCommitReq;
@ -24,8 +28,6 @@ import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -63,6 +65,8 @@ public class CodeServiceImpl implements CodeService {
private CodeMediaService codeMediaService;
@Autowired
private CodeExtService codeExtService;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public List<TemplateListResultDTO> templateList() {
@ -101,7 +105,7 @@ public class CodeServiceImpl implements CodeService {
@Transactional(rollbackFor = Exception.class)
public void upload(CodeUploadFormDTO formDTO) {
//是否授权
if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) {
if (!customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -148,6 +152,7 @@ public class CodeServiceImpl implements CodeService {
CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class);
codeCustomerDTO.setCustomerName(customerInfo.getData().getCustomerName());
codeCustomerDTO.setExtJson(formDTO.getExtJson());
codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid());
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED);
codeCustomerService.save(codeCustomerDTO);
@ -156,39 +161,40 @@ public class CodeServiceImpl implements CodeService {
@Override
public PageData uploadList(UploadListFormDTO formDTO) {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == authInfo) {
throw new RenException("未授权");
}
List<CodeCustomerDTO> auditingList = codeCustomerService.getAuditingCodeList();
auditingList.forEach(code -> {
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId());
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq();
request.setAuditId(auditResult.getAuditId());
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request);
if (wxAuditResult.success()) {
WxMaAuditStatusResult result = wxAuditResult.getData();
if (result.getStatus() == NumConstant.ZERO) {
code.setStatus(CodeConstant.AUDIT_SUCCESS);
auditResult.setResult(CodeConstant.AUDIT_SUCCESS);
codeOperationHistoryService.updateDescribe(code.getId(), "审核成功");
} else if (result.getStatus() == NumConstant.ONE) {
code.setStatus(CodeConstant.AUDIT_FAILED);
auditResult.setResult(CodeConstant.AUDIT_FAILED);
auditResult.setReason(result.getReason());
codeOperationHistoryService.updateDescribe(code.getId(), result.getReason());
} else if (result.getStatus() == NumConstant.FOUR) {
code.setStatus(CodeConstant.DELAY);
auditResult.setResult(CodeConstant.DELAY);
codeOperationHistoryService.updateDescribe(code.getId(), "审核延后");
if (null != auditingList && auditingList.size() > NumConstant.ZERO) {
auditingList.forEach(code -> {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(code.getCustomerId(), code.getClientType());
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId());
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq();
request.setAuditId(auditResult.getAuditId());
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request);
if (wxAuditResult.success()) {
WxMaAuditStatusResult result = wxAuditResult.getData();
if (result.getStatus() == NumConstant.ZERO) {
code.setStatus(CodeConstant.AUDIT_SUCCESS);
auditResult.setResult(CodeConstant.AUDIT_SUCCESS);
codeOperationHistoryService.updateDescribe(code.getId(), "审核成功");
} else if (result.getStatus() == NumConstant.ONE) {
code.setStatus(CodeConstant.AUDIT_FAILED);
auditResult.setResult(CodeConstant.AUDIT_FAILED);
auditResult.setReason(result.getReason());
auditResult.setScreenShot(result.getScreenshot());
codeOperationHistoryService.updateDescribe(code.getId(), result.getReason());
} else if (result.getStatus() == NumConstant.FOUR) {
code.setStatus(CodeConstant.DELAY);
auditResult.setResult(CodeConstant.DELAY);
auditResult.setReason(result.getReason());
codeOperationHistoryService.updateDescribe(code.getId(), "审核延后");
}
codeCustomerService.update(code);
codeAuditResultService.update(auditResult);
}
codeCustomerService.update(code);
codeAuditResultService.update(auditResult);
}
});
});
}
return codeCustomerService.getCodeList(formDTO);
}
@ -197,7 +203,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -206,7 +212,13 @@ public class CodeServiceImpl implements CodeService {
throw new RenException("未授权");
}
//调用微信API上提交审核
WxMaCodeSubmitAuditRequest request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeSubmitAuditRequest.class);
WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest();
request.setVersionDesc(formDTO.getVersionDesc());
request.setFeedbackInfo(formDTO.getFeedbackInfo());
request.setFeedbackStuff(formDTO.getFeedbackStuff());
request.setItemList(formDTO.getItemList());
request.setPreviewInfo(formDTO.getPreviewInfo());
request.setUgcDeclare(formDTO.getUgcDeclare());
WxResult<String> wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request);
if (!wxResult.success()) {
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT,
@ -232,7 +244,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取审核结果信息
@ -277,7 +289,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -308,7 +320,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType());
@ -343,7 +355,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -370,6 +382,7 @@ public class CodeServiceImpl implements CodeService {
@Override
public String mediaUpload(MediaUploadFormDTO formDTO) {
try {
// Result<UploadDTO> uploadDTOResult = ossFeignClient.upload(formDTO.getMedia());
File file = MultipartFileToFileUtils.multipartFileToFile(formDTO.getMedia());
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
@ -383,7 +396,7 @@ public class CodeServiceImpl implements CodeService {
CodeMediaDTO codeMediaDTO = new CodeMediaDTO();
codeMediaDTO.setCodeId(formDTO.getCodeId());
codeMediaDTO.setMediaId(wxResult.getData().getMediaId());
codeMediaDTO.setMediaName(formDTO.getMedia().getName());
codeMediaDTO.setMediaName(formDTO.getMedia().getOriginalFilename());
codeMediaDTO.setMediaType(wxResult.getData().getType());
codeMediaService.save(codeMediaDTO);
return wxResult.getData().getMediaId();
@ -399,7 +412,7 @@ public class CodeServiceImpl implements CodeService {
operationDTO.setCodeId(codeId);
operationDTO.setVersion(version);
operationDTO.setOperation(operation);
operationDTO.setDescribe(describe);
operationDTO.setDescription(describe);
codeOperationHistoryService.save(operationDTO);
}

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

@ -1,7 +1,9 @@
package com.epmet.service.impl;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
@ -12,10 +14,8 @@ import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AuthCodeResultDTO;
import com.epmet.dto.result.AuthorizationInfoResultDTO;
import com.epmet.dto.result.CreateOpenResultDTO;
import com.epmet.dto.result.WillOverDueResultDTO;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.mpaes.WXBizMsgCrypt;
import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.redis.RedisThird;
@ -32,9 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.*;
@ -79,6 +77,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
private MiniCategoryInfoDao miniCategoryInfoDao;
@Autowired
private BusinessInfoDao businessInfoDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private AuthResultRecordDao authResultRecordDao;
@Value("${third.platform.appId}")
private String componentAppId;
@ -109,20 +111,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String nonce = request.getParameter(ModuleConstant.NONCE);
String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE);
String signature = request.getParameter(ModuleConstant.SIGNATURE);
log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature));
// 从请求中读取整个post数据
InputStream inputStream;
String postData = null;
inputStream = request.getInputStream();
postData= IOUtils.toString(inputStream,ModuleConstant.UTF8);
log.info("postData = "+postData);
WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId);
String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData);
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg));
// 将xml转为map
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg);
String infotype = result.get(ModuleConstant.INFO_TYPE); //获取infotype,注:微信开放平台文档中标明固定为:"component_verify_ticket",但参考其他代码,还包含authorized???
log.info(infotype);
String infotype = result.get(ModuleConstant.INFO_TYPE);
switch (infotype){
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY);
@ -133,29 +132,22 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
ticketFormDTO.setComponentAppId(componentAppId);
ticketFormDTO.setComponentVerifyTicket(ComponentVerifyTicket);
//先逻辑删
ticketDao.updateOldComponentVerifyTicket();
ticketDao.deleteOldComponentVerifyTicket();
ticketDao.insertComponentVerifyTicket(ticketFormDTO);
log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket);
break;
case ModuleConstant.AUTHORIZED: //授权成功
// 更改customer_mp 授权信息,appId,并绑定
// String authAppId = result.get(ModuleConstant.APP_ID);
String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP);
log.info("=============================="+authCode);
AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode);
String clientType = authCodeResultDTO.getClientType();
String customerId = authCodeResultDTO.getCustomerId();
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authAppId = authorizerRefreshToken.get("authorizerAppid").toString();
this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType);
// this.authInfoByAuthCode(authCode, customerId,clientType);
authCodeDao.updateAppId(customerId,clientType,authAppId);
this.saveAuthAccountInfo(customerId,authAppId,clientType);
// customerMpDao.updateAuthorizationFlag(authAppId);
this.disposeAuthResult(result);
break;
case ModuleConstant.UNAUTHORIZED://用户取消授权
//todo 取消授权
String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP);
customerMpDao.updateAuthorizationFlag(authorizerAppId);
this.disposeAuthResult(result);
break;
case ModuleConstant.UPDATE_AUTHORIZED://授权变更
this.disposeAuthResult(result);
break;
}
} catch (Exception e) {
log.error(e.getMessage());
@ -170,6 +162,24 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
return ModuleConstant.SUCCESS;
}
/**
* @Description 授权结果插入
* @param result
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void disposeAuthResult(Map<String,String> result){
Map tempMap = result;
Map<String,Object> data = tempMap;
AuthResultRecordFormDTO authResultRecord = mapToEntity(data, AuthResultRecordFormDTO.class);
authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME)));
if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) {
authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)));
}
authResultRecord.setComponentAppId(componentAppId);
authResultRecordDao.insertAuthResultRecord(authResultRecord);
}
/**
* @Description 定时获取 (令牌component_access_token) 第三方与微信交互使用的component_access_token
* 每十分钟执行一次,判断是否有马上超时的15分钟以内算马上超时
@ -283,28 +293,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
authInfoDTO.setExpiresInTime(expiresInTime);
authInfoDTO.setCustomerId(customerId);
authInfoDTO.setClientType(clientType);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizationInfo(customerId,clientType);
authorizationInfoDao.insertAuthorizationInfo(authInfoDTO);
// 2. 权限列表
log.info(START_INSERT_FUNC_INFO);
List<FuncInfoFormDTO> funcInfos = new ArrayList<>();
List<Map> func_info = authorizationInfoResultDTO.getFunc_info();
log.info("权限列表信息:"+func_info);
/*func_info.forEach(func -> {
func.forEach((key,value) -> {
FuncInfoFormDTO fu = new FuncInfoFormDTO();
fu.setFuncscopeCategory((String) key);
Map funcScope = (Map) value;
fu.setFuncscopeId(funcScope.get(ModuleConstant.ID).toString());
fu.setAuthorizationInfoAppid(authAppId);
fu.setCustomerId(customerId);
funcInfos.add(fu);
});
});*/
// todo 先逻辑删除,在插入
/*funcInfoDao.updateOldFuncInfo(customerId,authAppId);
funcInfoDao.insertFuncInfo(funcInfos);*/
String funcInfo = JSON.toJSONString(func_info);
authInfoDTO.setFuncInfo(funcInfo);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizationInfo(authAppId);
authorizationInfoDao.insertAuthorizationInfo(authInfoDTO);
// 授权信息放入缓存
redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType);
//authorizer_refresh_token 放入缓存
@ -338,27 +333,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String componentAccessToken = redisThird.getComponentAccessToken();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();
Map map = JSON.parseObject(data, HashMap.class);
//authorizer_access_token
String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString();
String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString();
String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString();
Date expiresInTime = this.countExpirationTime(expiresIn);
//更新DB
AuthorizerAccessTokenFormDTO formDTO = new AuthorizerAccessTokenFormDTO();
AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO();
BeanUtils.copyProperties(formDTO,authorizationInfo);
authorizationInfo.setAuthorizerAppid(authAppId);
formDTO.setAuthorizerAccessToken(authorizerAccessToken);
formDTO.setAuthorizerRefreshToken(authorizerRefreshToken);
formDTO.setExpiresInTime(expiresInTime);
formDTO.setCustomerId(customerId);
formDTO.setAuthAppid(authAppId);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizerAccessToken(willOverDueDTO.getCustomerId(),clientType);
authorizationInfoDao.insertAuthorizerAccessToken(formDTO);
//缓存 refreshAuthorizerAccessToken
redisThird.setAuthorizerRefreshToken(authorizationInfo);
if (!map.containsKey(ModuleConstant.ERR_CODE)) {
log.info(REFRESH_AUTH_ACCESS_TOKEN);
String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString();
String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString();
String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString();
Date expiresInTime = this.countExpirationTime(expiresIn);
//更新DB
AuthorizerAccessTokenFormDTO formDTO = new AuthorizerAccessTokenFormDTO();
AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO();
BeanUtils.copyProperties(formDTO, authorizationInfo);
authorizationInfo.setAuthorizerAppid(authAppId);
formDTO.setAuthorizerAccessToken(authorizerAccessToken);
formDTO.setAuthorizerRefreshToken(authorizerRefreshToken);
formDTO.setExpiresInTime(expiresInTime);
formDTO.setCustomerId(customerId);
formDTO.setAuthAppid(authAppId);
formDTO.setClientType(clientType);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType);
authorizationInfoDao.insertAuthorizerAccessToken(formDTO);
//缓存 refreshAuthorizerAccessToken
redisThird.setAuthorizerRefreshToken(authorizationInfo);
}
});
log.info("更新authorizer_access_token成功");
}
@ -375,27 +372,31 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){
log.info("开始执行回调URL");
String authCode = authCodeAndTime.getAuthCode();
String client = authCodeAndTime.getClientType();
String clientType = authCodeAndTime.getClientType();
String expiresIn = authCodeAndTime.getExpiresIn();
String customerId = tokenDto.getCustomerId();
customerId = "f530774b31e0609a3c7f0f83794cda0c";
String customerId = this.getLoginUserCustomerId(tokenDto);
Date expiresInTime = this.countExpirationTime(expiresIn);
if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){
log.info("客户ID = "+customerId+", 客户端类型为 = "+client+", 授权码为 = "+authCode+", 有效期 = "+expiresIn);
}
//authCode存数据库
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setAuthCode(authCode);
formDTO.setExpiresInTime(expiresInTime);
formDTO.setClientType(client);
//授权方AppId
formDTO.setClientType(clientType);
formDTO.setCustomerId(customerId);
log.info(formDTO.toString());
authCodeDao.deleteCustomerAuthCode(customerId,client);
authCodeDao.deleteCustomerAuthCode(customerId,clientType);
authCodeDao.insertRedirectAuthCode(formDTO);
//authCode存缓存
redisThird.setAuthCode(formDTO);
this.authInfoByAuthCode(authCode, customerId,client);
// 1. 开始获取授权信息(使用授权码)
AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType);
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid();
// 2. 创建开放平台账号并绑定 或者 直接绑定开放平台
this.createAndBindOpenAccount(customerId,authAppId,clientType);
// 3. 更新 customer_mp 表授权状态和AuthAppId
this.updateCustomerMpAppId(customerId,authAppId,clientType);
authCodeDao.updateAppId(customerId,clientType,authAppId);
// 4. 保存授权方账户信息
this.saveAuthAccountInfo(customerId,authAppId,clientType);
log.info("回调结束");
}
@ -456,18 +457,20 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
//todo 小程序配置的类目信息插入
List<MiniCategoryInfoFormDTO> categoryInfoList = new ArrayList<>();
List<Map> categories = (List<Map>) miniProgramInfo.get(ModuleConstant.CATEGORIES);
categories.forEach(category -> {
category.forEach((key,value) -> {
MiniCategoryInfoFormDTO categoryInfo = new MiniCategoryInfoFormDTO();
categoryInfo.setCustomerId(customerId);
categoryInfo.setClientType(clientType);
categoryInfo.setCategorySort(key.toString());
categoryInfo.setCategoryName(value.toString());
categoryInfo.setPrimaryId(primaryId);
categoryInfoList.add(categoryInfo);
if (categories.size() != NumConstant.ZERO) {
categories.forEach(category -> {
category.forEach((key, value) -> {
MiniCategoryInfoFormDTO categoryInfo = new MiniCategoryInfoFormDTO();
categoryInfo.setCustomerId(customerId);
categoryInfo.setClientType(clientType);
categoryInfo.setCategorySort(key.toString());
categoryInfo.setCategoryName(value.toString());
categoryInfo.setPrimaryId(primaryId);
categoryInfoList.add(categoryInfo);
});
});
});
miniCategoryInfoDao.insertCategoryInfo(categoryInfoList);
miniCategoryInfoDao.insertCategoryInfo(categoryInfoList);
}
}else {
log.info("授权方为公众号 并 开始插入信息");
PaInfoFormDTO paInfoFormDTO = this.mapToEntity(authorizerInfo, PaInfoFormDTO.class);
@ -493,89 +496,107 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 1.创建开放平台账号并绑定 2.回填 customer_mp appId
* @Description 回填 customer_mp appId , 更改授权状态
* @param
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){
log.info("开始创建开放平台账号并绑定");
Integer authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){
log.info("==========回填customer_mp开始==========");
Integer checkBindCount = customerMpDao.checkBind(authAppId, clientType);
if (checkBindCount == NumConstant.ZERO) {
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setClientType(clientType);
formDTO.setAuthAppId(authAppId);
formDTO.setCustomerId(customerId);
//回填customer_mp的appId 只需以上三个字段
customerMpDao.updateAppIDByCustomerIdAndClient(formDTO);
}
log.info("==========回填customer_mp结束==========");
}
public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString();
if (authCount==NumConstant.ZERO){
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
// 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG));
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID));
switch (createOpen.getErrCode()){
case NumConstant.ONE:
log.info(CREATE_AND_BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
JSONObject bindInfoForm = new JSONObject();
bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId);
String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData();
Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class);
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID);
if (bindStatus != true) {
log.info(CREATE_AND_BIND_SUCCESS);
List<String> authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
if (authCount.size() > 0) {
openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId);
}
CreateOpenFormDTO coForm = new CreateOpenFormDTO();
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID));
coForm.setCustomerId(customerId);
//插入 open_platform_account 表
openPlatformAccountDao.insertOpenPlatFormAccount(coForm);
openPlatformId = coForm.getId();
}else if (authCount>NumConstant.ZERO){
log.info("该客户已创建过开放平台账号,直接绑定");
String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId);
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG));
switch (createOpen.getErrCode()){
case NumConstant.ONE:
log.info(BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE:
throw new RenException(NOT_SAME_CONTRACTOR);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE:
throw new RenException(NOT_ALLOWED_OPERATE);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR:
throw new RenException(TO_LIMIT);
if (authCount.size() == NumConstant.ZERO) {
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId);
// 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String, Object> map = JSON.parseObject(data, Map.class);
openPlatformId = map.get(ModuleConstant.OPEN_APP_ID).toString();
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString());
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID).toString());
switch (createOpen.getErrCode()) {
case NumConstant.ZERO:
log.info(CREATE_AND_BIND_SUCCESS);
CreateOpenFormDTO coForm = new CreateOpenFormDTO();
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID).toString());
coForm.setCustomerId(customerId);
//插入 open_platform_account 表
openPlatformAccountDao.deleteOldOpenPlatFprmAccount(customerId);
openPlatformAccountDao.insertOpenPlatFormAccount(coForm);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
}
} else if (authCount.size() > NumConstant.ZERO && !authCount.contains(authAppId)) {
log.info("该客户已创建过开放平台账号,直接绑定");
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID, openPlatformId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String, Object> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString());
switch (createOpen.getErrCode()) {
case NumConstant.ZERO:
log.info(BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE:
throw new RenException(NOT_SAME_CONTRACTOR);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE:
throw new RenException(NOT_ALLOWED_OPERATE);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR:
throw new RenException(TO_LIMIT);
}
}
//插入 binding_account
BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO();
bindingAccount.setOpenPlatformAccountId(openPlatformId);
bindingAccount.setAuthAppId(authAppId);
bindingAccount.setClientType(clientType);
bindingAccount.setCustomerId(customerId);
bindingAccountDao.insertBindingAccount(bindingAccount);
log.info("创建绑定账号结束");
}
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setClientType(clientType);
formDTO.setAuthAppId(authAppId);
formDTO.setCustomerId(customerId);
//回填customer_mp的appId 只需以上三个字段
customerMpDao.updateAppIDByCustomerIdAndClient(formDTO);
//插入 binding_account
BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO();
bindingAccount.setOpenPlatformAccountId(openPlatformId);
bindingAccount.setAuthAppId(authAppId);
bindingAccount.setClientType(clientType);
bindingAccount.setCustomerId(customerId);
bindingAccountDao.insertBindingAccount(bindingAccount);
log.info("创建绑定账号结束");
}
/**
@ -620,4 +641,28 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
date.setTime(l);
return date;
}
/**
* @Description 查询客户Id
* @param tokenDto
* @author zxc
*/
public String getLoginUserCustomerId(TokenDto tokenDto){
LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO();
BeanUtils.copyProperties(tokenDto,dto);
LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData();
return data.getCustomerId();
}
/**
* @Description 时间戳秒级转换 Date
* @param t
* @author zxc
*/
public Date sToDate(String t){
Long aLong = Long.valueOf(t + "000");
Date date = new Date();
date.setTime(aLong);
return date;
}
}

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

@ -154,14 +154,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void register(RegisterFormDTO formDTO) {
//1.根据手机号查询到用户信息,判断用户是否存
List<PaUserDTO> userList = paUserDao.selectUserByPhone(formDTO.getPhone());
if (null != userList && userList.size() > NumConstant.ZERO) {
throw new RenException(PaConstant.PHONE_EXCEPTION);
}
//2.校验验证码是否正确
public RegisterResultDTO register(RegisterFormDTO formDTO) {
RegisterResultDTO resultDTO = new RegisterResultDTO();
//0.校验验证码是否正确
String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, formDTO.getPhone());
String rightSmsCode = (String) redisUtils.get(smsCodeKey);
if (!formDTO.getSmsCode().equals(rightSmsCode)) {
@ -169,31 +164,87 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
//3.pa_user表更新数据
PaUserEntity userEntity = new PaUserEntity();
userEntity.setId(formDTO.getUserId());
userEntity.setPhone(formDTO.getPhone());
userEntity.setRealName(formDTO.getSurName());
userEntity.setGender(formDTO.getGender().toString());
if (paUserDao.updateById(userEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.UPDATE_USER_EXCEPTION);
//1.根据手机号查询到用户信息,判断用户是否存
List<PaUserDTO> userList = paUserDao.selectUserByPhone(formDTO.getPhone());
if (null != userList && userList.size() > NumConstant.ZERO) {
throw new RenException(PaConstant.PHONE_EXCEPTION);
}
//2.访问记录表新增数据
PaUserWechatDTO dto = new PaUserWechatDTO();
dto.setUserId(formDTO.getUserId());
PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto);
if (null == wechatEntity) {
throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION);
}
PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity();
visitedEntity.setUserId(formDTO.getUserId());
visitedEntity.setWxOpenId(wechatEntity.getWxOpenId());
visitedEntity.setOpenId(wechatEntity.getWxOpenId());
visitedEntity.setPhone(formDTO.getPhone());
if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION);
//2.根据token中的userId查询pa_user表数据,根据手机号是否为空判断后续是新增还是更新user数据
PaUserEntity paUserEntity = paUserDao.selectById(formDTO.getUserId());
//3.手机号不为空说明是同一个微信用户用第二个手机号注册,手机为空说明当前微信用户用第一个手机号注册
if(null != paUserEntity.getPhone() && StringUtils.isNotBlank(paUserEntity.getPhone())){
//手机号不为空说明是同一个微信用户用第二个手机号注册,新增user和user_wechat表数据
//3-1.user表新增数据
PaUserEntity userEntity = new PaUserEntity();
userEntity.setPhone(formDTO.getPhone());
userEntity.setRealName(formDTO.getSurName());
userEntity.setGender(formDTO.getGender().toString());
if (paUserDao.insert(userEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.SAVE_USER_EXCEPTION);
}
//3-2.根据token中的userId查询用户的微信信息
PaUserWechatDTO dto = new PaUserWechatDTO();
dto.setUserId(formDTO.getUserId());
PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto);
if (null == wechatEntity) {
throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION);
}
//3-3.新增用户微信信息
wechatEntity.setId(null);
wechatEntity.setUserId(userEntity.getId());
if (paUserWechatDao.insert(wechatEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.SAVE_WECHAT_EXCEPTION);
}
//3-4.访问记录表新增数据
PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity();
visitedEntity.setUserId(userEntity.getId());
visitedEntity.setWxOpenId(wechatEntity.getWxOpenId());
visitedEntity.setOpenId(wechatEntity.getWxOpenId());
visitedEntity.setPhone(formDTO.getPhone());
if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION);
}
resultDTO.setUserId(userEntity.getId());
resultDTO.setOpenId(wechatEntity.getWxOpenId());
resultDTO.setUnionId(null == wechatEntity.getUnionId() ? "" : wechatEntity.getUnionId());
}else {
//手机为空说明当前微信用户用第一个手机号注册,更新user表数据
//3-1.pa_user表更新数据
PaUserEntity userEntity = new PaUserEntity();
userEntity.setId(formDTO.getUserId());
userEntity.setPhone(formDTO.getPhone());
userEntity.setRealName(formDTO.getSurName());
userEntity.setGender(formDTO.getGender().toString());
if (paUserDao.updateById(userEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.UPDATE_USER_EXCEPTION);
}
//3-2.访问记录表新增数据
PaUserWechatDTO dto = new PaUserWechatDTO();
dto.setUserId(formDTO.getUserId());
PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto);
if (null == wechatEntity) {
throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION);
}
PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity();
visitedEntity.setUserId(formDTO.getUserId());
visitedEntity.setWxOpenId(wechatEntity.getWxOpenId());
visitedEntity.setOpenId(wechatEntity.getWxOpenId());
visitedEntity.setPhone(formDTO.getPhone());
if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) {
throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION);
}
resultDTO.setUserId(userEntity.getId());
resultDTO.setOpenId(wechatEntity.getWxOpenId());
resultDTO.setUnionId(null == wechatEntity.getUnionId() ? "" : wechatEntity.getUnionId());
}
return resultDTO;
}
/**

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

@ -26,9 +26,11 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.PaCustomerDao;
import com.epmet.dao.PaUserDao;
import com.epmet.dao.PaUserVisitedDao;
import com.epmet.dao.PaUserWechatDao;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserVisitedDTO;
import com.epmet.dto.PaUserWechatDTO;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
@ -64,6 +66,8 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
private PaCustomerDao paCustomerDao;
@Autowired
private PaUserWechatDao paUserWechatDao;
@Autowired
private PaUserVisitedDao paUserVisitedDao;
@Override
public PageData<PaUserDTO> page(Map<String, Object> params) {
@ -127,11 +131,11 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
@Transactional(rollbackFor = Exception.class)
public SaveUserResultDTO saveUser(WxMpUser wxMpUser) {
SaveUserResultDTO resultDTO = new SaveUserResultDTO();
//1.根据openId查询user_wechat表是否存在用户信息
PaUserWechatDTO wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId());
//1.根据openId查询user_wechat表是否存在用户信息(user表和user_wechat表数据时多对多关系)
List<PaUserWechatDTO> wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId());
//2.不存在则新增用户信息,存在则更新user_wechat表信息
if (null == wechatDTO || null == wechatDTO.getId()) {
if (null == wechatDTO || wechatDTO.size() < NumConstant.ONE) {
//2.1、user表新增数据
PaUserEntity userEntity = new PaUserEntity();
baseDao.insert(userEntity);
@ -151,18 +155,23 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity>
resultDTO.setUserId(userEntity.getId());
} else {
//2.3、更新user_wechat表数据
PaUserWechatEntity wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class);
wechatEntity.setGender(wxMpUser.getSex().toString());
wechatEntity.setNickname(wxMpUser.getNickname());
wechatEntity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl());
wechatEntity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry());
wechatEntity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince());
wechatEntity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity());
wechatEntity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage());
paUserWechatService.updateById(wechatEntity);
resultDTO.setUserId(wechatDTO.getUserId());
//2.3、批量更新user_wechat表数据
List<PaUserWechatEntity> wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class);
for(PaUserWechatEntity entity : wechatEntity){
entity.setGender(wxMpUser.getSex().toString());
entity.setNickname(wxMpUser.getNickname());
entity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl());
entity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry());
entity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince());
entity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity());
entity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage());
}
paUserWechatService.updateBatchById(wechatEntity);
//2.4、根据openid查询用户登陆访问记录表数据,按登陆时间倒序
PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId());
resultDTO.setUserId(visitedDTO.getUserId());
}
//3.返回userId

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

@ -108,7 +108,7 @@ public class PaUserWechatServiceImpl extends BaseServiceImpl<PaUserWechatDao, Pa
* @Description 根据openId查询user_wechat表信息
**/
@Override
public PaUserWechatDTO getWechatByOpenId(String openId) {
public List<PaUserWechatDTO> getWechatByOpenId(String openId) {
return baseDao.selectWechatByOpenId(openId);
}

20
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -33,16 +33,18 @@ public interface WxMaCodeConstant {
/**
* 前端地址 授权之后的跳转的地址
*/
String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/#/info?clientType=";
String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/#/info?clientType=";
/**
* 授权注册页面扫码授权
* component_appid:第三方AppId
* pre_auth_code预授权码
* redirect_uri回调url获取授权码
* 上面url为扫码形式
* 下面注释url为按钮形式
*/
// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s";
String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect";
String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s";
// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect";
/**
* 创建开放平台帐号并绑定公众号/小程序
@ -59,6 +61,11 @@ public interface WxMaCodeConstant {
*/
String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=";
/**
* 获取公众号/小程序所绑定的开放平台帐号
*/
String API_OPEN_GET = "https://api.weixin.qq.com/cgi-bin/open/get?access_token=";
/**
* 为授权的小程序帐号上传小程序代码.
*/
@ -143,4 +150,11 @@ public interface WxMaCodeConstant {
* 新增临时素材
*/
String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain";
/**
* 新增临时素材
*/
String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist";
}

101
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java

@ -1,5 +1,6 @@
package com.epmet.wxapi.param;
import com.epmet.dto.form.SubmitAuditFormDTO;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -36,110 +37,16 @@ public class WxMaCodeSubmitAuditRequest implements Serializable {
* 审核项列表选填至多填写 5
*/
@SerializedName("item_list")
private List<ItemListBean> itemList;
private List<SubmitAuditFormDTO.ItemListBean> itemList;
/**
* 预览信息小程序页面截图和操作录屏
*/
@SerializedName("preview_info")
private List<PreviewInfoBean> previewInfo;
private List<SubmitAuditFormDTO.PreviewInfoBean> previewInfo;
/**
* 用户生成内容场景UGC信息安全声明
*/
@SerializedName("ugc_declare")
private List<UgcDeclareBean> ugcDeclare;
private SubmitAuditFormDTO.UgcDeclareBean ugcDeclare;
@NoArgsConstructor
@Data
private static class ItemListBean {
/**
* 小程序的页面可通过获取小程序的页面列表接口获得
*/
@SerializedName("address")
private String address;
/**
* 小程序的标签用空格分隔标签至多 10 标签长度至多 20
*/
@SerializedName("tag")
private String tag;
/**
* 一级类目名称
*/
@SerializedName("first_class")
private String firstClass;
/**
* 二级类目名称
*/
@SerializedName("second_class")
private String secondClass;
/**
* 三级类目名称
*/
@SerializedName("third_class")
private String thirdClass;
/**
* 一级类目的 ID
*/
@SerializedName("first_id")
private String firstId;
/**
* 二级类目的 ID
*/
@SerializedName("second_id")
private String secondId;
/**
* 三级类目的 ID
*/
@SerializedName("third_id")
private String thirdId;
/**
* 小程序页面的标题,标题长度至多 32
*/
@SerializedName("title")
private String title;
}
@NoArgsConstructor
@Data
private static class PreviewInfoBean {
/**
* 录屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("Video_id_list")
private List<String> videoIdList;
/**
* 截屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("pic_id_list")
private List<String> picIdList;
}
@NoArgsConstructor
@Data
private static class UgcDeclareBean {
/**
* UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段
*/
@SerializedName("scene")
private List<Integer> scene;
/**
* 当scene选其他时的说明,不超时256字
*/
@SerializedName("other_scene_desc")
private String otherSceneDesc;
/**
* 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关
*/
@SerializedName("method")
private List<Integer> method;
/**
* 是否有审核团队, 0.,1.,默认0
*/
@SerializedName("has_audit_team")
private Integer hasAuditTeam;
/**
* 说明当前对UGC内容的审核机制,不超过256字
*/
@SerializedName("audit_desc")
private String auditDesc;
}
}

23
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java

@ -0,0 +1,23 @@
package com.epmet.wxapi.param;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/7/17 17:44
*/
@Data
@Component
@ConfigurationProperties(prefix = "third.domain")
public class WxMaDomainDTO {
private List<String> requestDomain;
private List<String> wsRequestDomain;
private List<String> uploadDomain;
private List<String> downloadDomain;
private List<String> webviewDomain;
}

19
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.dto.UserWechatDTO;
import com.epmet.wxapi.constant.WxLoginConstant;
import com.epmet.wxapi.service.WxLoginService;
@ -45,29 +46,33 @@ public class WxLoginServiceImpl implements WxLoginService {
map.put("js_code", wxCode);
map.put("grant_type", "authorization_code");
map.put("component_appid", componentAppId);
String componentAccessToken = (String) redisUtils.get("epmet:wechartthird:componentaccesstoken");
String componentAccessToken = (String) redisUtils.get(ThirdRedisKeyConstant.ACCESS_TOKEN_REDIS_KEY);
map.put("component_access_token", componentAccessToken);
String resultStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.WXCODE_BY_OPENID, map).getData();
HashMap<String, String> hashMap = JSON.parseObject(resultStr, HashMap.class);
if (null != hashMap.get("errorCode")) {
if (null != hashMap.get("errcode")) {
logger.error("wxcode换取openid接口调用失败");
throw new RenException(hashMap.get("errorMsg"));
throw new RenException(hashMap.get("errmsg"));
}
String openid = hashMap.get("openid");
String sessionKey = hashMap.get("session_key");
//2.换取用户基本信息
//小程序access_token
String access_token = (String) redisUtils.get("epmet:wechartthird:authinfo" + ":" + customerId + ":" + clientType);
Map<String, Object> accessMap = redisUtils.hGetAll(ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + ":" + customerId + ":" + clientType);
if(null==accessMap.get("authorizer_access_token")){
logger.error("获取缓存中小程序access_token失败");
throw new RenException("access_token获取失败");
}
Map<String, Object> hash = new HashMap<>();
hash.put("access_token", access_token);
hash.put("access_token", accessMap.get("authorizer_access_token"));
hash.put("openid", openid);
hash.put("lang", "zh_CN");
String getStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.OPENID_TO_INFORMATION, map).getData();
HashMap<String, String> resultMap = JSON.parseObject(getStr, HashMap.class);
if (null != resultMap.get("errorCode")) {
if (null != resultMap.get("errcode")) {
logger.error("openid和access_token换取微信用户基本信息接口调用失败");
throw new RenException(resultMap.get("errorMsg"));
throw new RenException(resultMap.get("errormsg"));
}
//3.返回结果

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

@ -10,14 +10,19 @@ import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -30,21 +35,14 @@ import java.util.List;
public class WxMaCodeServiceImpl implements WxMaCodeService {
private static final String ERR_CODE = "errcode";
private static final String ERR_MSG = "errmsg";
@Value("${third.domain.requestdomain}")
private List<String> requestDomain;
@Value("${third.domain.wsrequestdomain}")
private List<String> wsRequestDomain;
@Value("${third.domain.uploaddomain}")
private List<String> uploadDomain;
@Value("${third.domain.downloaddomain}")
private List<String> downloadDomain;
@Value("${third.domain.webviewdomain}")
private List<String> webviewDomain;
@Autowired
private WxMaDomainDTO wxMaDomainDTO;
@Override
public WxResult<List<WxMaTemplateResult>> getTemplateList(String accessToken) {
WxResult<List<WxMaTemplateResult>> result = new WxResult<>();
String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken;
String url = WxMaCodeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken;
Result<String> templateListResult = HttpClientManager.getInstance().sendGet(url, null);
if (!templateListResult.success()) {
result.setErrorCode(templateListResult.getCode());
@ -54,7 +52,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
Gson gson = new Gson();
WxMaTemplateListResult templateList = gson.fromJson(templateListResult.getData(), WxMaTemplateListResult.class);
result.setErrorCode(templateList.getErrCode());
result.setErrorMsg(templateList.getErrMsg());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateList.getErrCode()));
result.setData(templateList.getTemplateList());
return result;
}
@ -153,7 +151,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
@Override
public WxResult<WxMaAuditStatusResult> getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request) {
WxResult<WxMaAuditStatusResult> result = new WxResult<>();
String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken;
String url = WxMaCodeConstant.GET_AUDIT_STATUS_URL + "?" + "access_token=" + accessToken;
Result<String> statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!statusResult.success()) {
result.setErrorCode(statusResult.getCode());
@ -213,6 +211,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
return result;
}
Gson gson = new Gson();
InputStream inputStream = gson.fromJson(statusResult.getData(), InputStream.class);
WxMaNewsResult newsResult = gson.fromJson(statusResult.getData(), WxMaNewsResult.class);
result.ok(newsResult);
return result;
@ -224,10 +223,10 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
String url = WxMaCodeConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken;
WxMaModifyDomainReq request = new WxMaModifyDomainReq();
request.setAction("set");
request.setRequestDomain(requestDomain);
request.setUploadDomain(uploadDomain);
request.setWsRequestDomain(wsRequestDomain);
request.setDownloadDomain(downloadDomain);
request.setRequestDomain(wxMaDomainDTO.getRequestDomain());
request.setUploadDomain(wxMaDomainDTO.getUploadDomain());
request.setWsRequestDomain(wxMaDomainDTO.getWsRequestDomain());
request.setDownloadDomain(wxMaDomainDTO.getDownloadDomain());
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!modifyResult.success()) {
result.setErrorCode(modifyResult.getCode());
@ -246,7 +245,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
String url = WxMaCodeConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken;
WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq();
request.setAction("set");
request.setWebViewDomain(webviewDomain);
request.setWebViewDomain(wxMaDomainDTO.getWebviewDomain());
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!modifyResult.success()) {
result.setErrorCode(modifyResult.getCode());

15
epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml

@ -105,8 +105,13 @@ third:
aesKey: d6dbde92c67e11eabac1c03fd56f7847qazxswedcvg
token: 1ae5f230c67f11eabac1c03fd56f7847
domain:
requestdomain: "https://epmet-cloud.elinkservice.cn"
wsrequestdomain: "https://epmet-cloud.elinkservice.cn"
uploaddomain: "https://epmet-cloud.elinkservice.cn"
downloaddomain: "https://epmet-cloud.elinkservice.cn"
webviewdomain: "https://epmet-cloud.elinkservice.cn"
requestDomain:
- https://epmet-cloud.elinkservice.cn
wsRequestDomain:
- https://epmet-cloud.elinkservice.cn
uploadDomain:
- https://epmet-cloud.elinkservice.cn
downloadDomain:
- https://epmet-cloud.elinkservice.cn
webviewDomain:
- https://epmet-cloud.elinkservice.cn

21
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml

@ -3,4 +3,25 @@
<mapper namespace="com.epmet.dao.AuthResultRecordDao">
<!-- 插入授权结果记录 -->
<insert id="insertAuthResultRecord">
INSERT INTO auth_result_record ( ID, COMPONENT_APP_ID, WECHAT_CREATE_TIME, INFO_TYPE, AUTHORIZER_APP_ID, AUTHORIZATION_CODE, EXPIRES_IN_TIME, PRE_AUTH_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
(
REPLACE(UUID(),'-',''),
#{componentAppId},
#{wechatCreateTime},
#{InfoType},
#{AuthorizerAppid},
#{AuthorizationCode},
#{ExpiredTime},
#{PreAuthCode},
#{delFlag},
#{revision},
#{createdBy},
NOW(),
#{updatedBy},
NOW()
)
</insert>
</mapper>

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

@ -5,7 +5,7 @@
<!-- 插入 授权信息 -->
<insert id="insertAuthorizationInfo" parameterType="com.epmet.dto.form.AuthorizationInfoFormDTO">
INSERT INTO authorization_info ( ID, CUSTOMER_ID, AUTHORIZER_APPID, AUTHORIZER_ACCESS_TOKEN, EXPIRES_IN_TIME, AUTHORIZER_REFRESH_TOKEN, CLIENT_TYPE, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO authorization_info ( ID, CUSTOMER_ID, AUTHORIZER_APPID, AUTHORIZER_ACCESS_TOKEN, EXPIRES_IN_TIME, AUTHORIZER_REFRESH_TOKEN, FUNC_INFO, CLIENT_TYPE, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
(
REPLACE ( UUID(), '-', '' ),
@ -14,6 +14,7 @@
#{authorizerAccessToken},
#{expiresInTime},
#{authorizerRefreshToken},
#{funcInfo},
#{clientType},
#{delFlag},
#{createdBy},
@ -25,7 +26,7 @@
<!-- 逻辑删除授权信息 -->
<update id="updateOldAuthorizationInfo">
update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType}
update authorization_info set del_flag = 1 where authorizer_appid = #{authAppId}
</update>
<!-- 询即将过期的 authorizer_access_token -->
@ -41,7 +42,6 @@
WHERE
del_flag = 0
AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) <![CDATA[ <= ]]> 900
AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) > 0
</select>
<!-- 插入 authorizer_access_token -->
@ -68,6 +68,7 @@
<update id="updateOldAuthorizerAccessToken">
update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType}
</update>
<select id="getAuthInfoByCustomer" resultType="com.epmet.dto.AuthorizationInfoDTO">
SELECT AUTHORIZER_APPID,
AUTHORIZER_ACCESS_TOKEN
@ -78,4 +79,16 @@
AND EXPIRES_IN_TIME > NOW()
</select>
<!-- 根据 authAppId 查询客户ID和客户端类型 -->
<select id="selectCustomerIdByAuthAppId" resultType="com.epmet.dto.result.AuthCodeResultDTO">
SELECT
customer_id AS customerId,
client_type AS clientType
FROM
authorization_info
WHERE
del_flag = 0
AND authorizer_appid = #{authAppId}
</select>
</mapper>

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

@ -15,7 +15,7 @@
#{clientType},
#{delFlag},
#{revision},
#{createDBy},
#{createdBy},
NOW(),
#{updatedBy},
NOW()

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

@ -31,8 +31,8 @@
cc.USER_VERSION AS "version",
cc.USER_DESC AS "codeInfo",
cc.STATUS,
DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d') AS "uploadTime",
IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d'),'') AS "auditTime",
DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d %T') AS "uploadTime",
IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d %T'),'') AS "auditTime",
car.AUDIT_ID
FROM code_customer cc
LEFT JOIN code_audit_result car ON cc.ID = car.CODE_ID AND car.DEL_FLAG = '0'

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml

@ -9,7 +9,7 @@
<result property="codeId" column="CODE_ID"/>
<result property="version" column="VERSION"/>
<result property="operation" column="OPERATION"/>
<result property="describe" column="DESCRIBE"/>
<result property="description" column="DESCRIPTION"/>
<result property="revision" column="REVISION"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="createdBy" column="CREATED_BY"/>
@ -19,7 +19,7 @@
</resultMap>
<update id="updateDescribeByCodeId">
UPDATE code_operation_history SET
`DESCRIBE` = #{describe}
`DESCRIPTION` = #{describe}
WHERE CODE_ID = #{codeId}
AND OPERATION = 'audit'
</update>
@ -28,7 +28,7 @@
DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d') AS "operationTime",
coh.VERSION,
coh.OPERATION,
coh.`DESCRIBE`
coh.`DESCRIPTION`
FROM code_operation_history coh
INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID
WHERE

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

@ -28,7 +28,7 @@
COMPONENT_ACCESS_TOKEN
FROM
component_access_token
WHERE delFlag = '0'
WHERE DEL_FLAG = '0'
</select>
<!-- 查询component_access_token 数量 -->

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml

@ -21,9 +21,9 @@
</insert>
<!-- 逻辑删除 【component_verify_ticket】 -->
<update id="updateOldComponentVerifyTicket">
update component_verify_ticket set del_flag = 1
</update>
<delete id="deleteOldComponentVerifyTicket">
DELETE FROM component_verify_ticket WHERE del_flag = 0
</delete>
</mapper>

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

@ -19,9 +19,9 @@
client ASC
</select>
<!-- 查询授权的数量 -->
<select id="selectAuthCount" resultType="java.lang.Integer">
<select id="selectAuthCount" resultType="java.lang.String">
SELECT
COUNT(*) AS notAuthCount
app_id AS authAppId
FROM
customer_mp
WHERE
@ -37,7 +37,7 @@
WHERE
customer_id = #{customerId}
AND del_flag = '0'
AND client = #{client}
AND client = #{clientType}
</update>
<!-- 修改小程序授权的状态 -->
@ -51,7 +51,7 @@
<!-- 根据 客户Id和授权方AppId查询clientType -->
<select id="selectClientTypeByCustomerIdAndAuthId" resultType="java.lang.String">
SELECT
client_type AS clientType
client AS clientType
FROM
customer_mp
WHERE
@ -115,4 +115,16 @@
AND cm.app_id = #{appId}
</select>
<!-- 校验此小程序是不是绑定别的客户端 -->
<select id="checkBind" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
customer_mp
WHERE
del_flag = 0
AND app_id = #{authAppId}
AND client != #{clientType}
</select>
</mapper>

9
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml

@ -12,7 +12,7 @@
VALUES
(
REPLACE ( UUID(), '-', '' ),
#{openAppId},
#{openid},
#{customerId},
#{delFlag},
#{revision},
@ -23,12 +23,17 @@
)
</insert>
<!-- 删除客户下报废的开放平台账号信息 -->
<update id="deleteOldOpenPlatFprmAccount">
UPDATE open_platform_account set del_flag = 1 where customer_id = #{customerId}
</update>
<!-- 根据客户Id查询已绑定开放平台的账号ID -->
<select id="selectOpenAppIdByCustomerId" resultType="java.lang.String">
SELECT
open_app_id AS openAppId
FROM
open_flatform_account
open_platform_account
WHERE
del_flag = 0
AND customer_id = #{customerId}

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

@ -3,5 +3,21 @@
<mapper namespace="com.epmet.dao.PaUserVisitedDao">
<select id="selectByOpenId" resultType="com.epmet.dto.PaUserVisitedDTO">
SELECT
id,
user_id,
wx_open_id,
open_id,
phone
FROM
pa_user_visited
WHERE
del_flag = '0'
AND wx_open_id = #{openId}
ORDER BY
created_time DESC
LIMIT 1
</select>
</mapper>

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

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-org-server:
container_name: gov-org-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.75
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.76
ports:
- "8092:8092"
network_mode: host # 使用现有网络

2
epmet-module/gov-org/gov-org-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"
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>
<version>0.3.75</version>
<version>0.3.76</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>gov-org</artifactId>

2
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -21,6 +21,6 @@ public interface OperCrmOpenFeignClient {
* @param dto
* @return
*/
@PostMapping("/oper/crm/getcostomerInfo")
@PostMapping("/oper/crm/customer/getcostomerInfo")
Result<CustomerDTO> getCustomerInfo(CustomerDTO dto);
}

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

@ -2,7 +2,7 @@ version: "3.7"
services:
resi-guide-server:
container_name: resi-guide-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/resi-guide-server:0.3.17
image: 192.168.1.130:10080/epmet-cloud-dev/resi-guide-server:0.3.18
ports:
- "8091:8091"
network_mode: host # 使用现有网络

2
epmet-module/resi-guide/resi-guide-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"
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>
<version>0.3.17</version>
<version>0.3.18</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>resi-guide</artifactId>

2
epmet-user/epmet-user-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-user-server:
container_name: epmet-user-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.76
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.77
ports:
- "8087:8087"
network_mode: host # 不会创建新的网络

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save