diff --git a/epmet-auth/deploy/docker-compose-dev.yml b/epmet-auth/deploy/docker-compose-dev.yml index b2609df0b1..03a7a57ee3 100644 --- a/epmet-auth/deploy/docker-compose-dev.yml +++ b/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 # 使用现有网络 diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index ab11a183fc..7c5f5d6a62 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.43 + 0.3.44 com.epmet epmet-cloud diff --git a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java index d083b2a26b..85163f625c 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java +++ b/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().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO)); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + @PostMapping(value = "/register") + public Result register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class); + formDTO.setUserId(tokenDTO.getUserId()); + return new Result().ok(publicUserLoginService.register(formDTO)); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java b/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java index 0ee6449c90..80fd7ea305 100644 --- a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java +++ b/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); + } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java index 6d0e615944..f626ec6814 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java +++ b/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 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; + } + + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 5061222074..9f8ba52d28 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/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()); diff --git a/epmet-gateway/deploy/docker-compose-prod.yml b/epmet-gateway/deploy/docker-compose-prod.yml index 35a4e7e1e2..cec8fb60da 100644 --- a/epmet-gateway/deploy/docker-compose-prod.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml index 811a2df85c..e86909b2c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml index 3b3123c312..4d3be03e5d 100644 --- a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 971d0c956a..1709484e94 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -2,7 +2,7 @@ - 0.3.39 + 0.3.41 data-statistical com.epmet diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java index bfe699c25e..f3618f4e06 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java +++ b/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 { List listValidCustomersByCreateTime( @Param("createTimeFrom") Date createTimeFrom, @Param("createTimeTo") Date createTimeTo); + + List listValidCustomersByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java index 2b9b4705ab..8db5a46efb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java +++ b/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 @Param("createdTimeFrom") Date createdTimeFrom, @Param("createdTimeTo") Date createdTimeTo); + List listDepartmentsByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index faccf553a2..9f26b8b98d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/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 { * @author zxc */ List getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * 根据更新时间查询列表 + * @param startTime + * @param endTime + * @return + */ + List listUpdatedGridsByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index b3de9cfd02..eb02051e91 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/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 { List selectAllAgency(); List selectSubAgencyByPid(@Param("pid")String pid); + + List listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java index 419a54ef2c..8788232a7b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java +++ b/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 { String getPidByAgencyId(@Param("agencyId") String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java index 1834b73ffc..8bd2c3cf8d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java +++ b/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 { void insertOne(DimCustomerEntity dim); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java index 5098869983..0b58bc2220 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java +++ b/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 { List getDepartmentListByCustomerId(@Param("customerId") String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java index 669e8a08a0..c1671131b1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java +++ b/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 { * @author zxc */ List selectSubAgencyId(@Param("formDTO")List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java index e562a08365..dbc2cc03f9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java @@ -9,4 +9,5 @@ public interface CustomerService { List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo); + List listValidCustomersByUpdatedTime(Date updatedTime, Date initTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java index 3db2f197bd..056df4e50e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java +++ b/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 listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) { return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo); } + + @Override + public List listValidCustomersByUpdatedTime(Date startTime, Date endTime) { + return customerDao.listValidCustomersByUpdateTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java index dde7d9f14e..5c09458416 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java +++ b/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 newDimGrids = getNewDimGrids(); + List changedGrids = getChangedGrids(); + + dimGridService.initGridDims(newDimGrids, changedGrids); + } + + /** + * 初始化新建网格 + * @return + */ + public List getNewDimGrids() { DimGridEntity lastDimEntity = dimGridService.getLastCreatedGridDim(); List grids; Date now = new Date(); @@ -65,10 +75,36 @@ public class StatsDimServiceImpl implements StatsDimService { grids = customerGridService.listGridsByCreateTime(lastInitTime, now); } - List gridDims = convertCustomerGrid2GridDim(grids, now); - if (!CollectionUtils.isEmpty(gridDims)) { - dimGridService.initGridDims(gridDims); + return convertCustomerGrid2GridDim(grids, now); + } + + /** + * 初始化变更的网格 + * @return + */ + public List getChangedGrids() { + DimGridEntity lastUpdatedGridDim = dimGridService.getLastUpdatedGridDim(); + + List updatedGrids; + Date now = new Date(); + if (lastUpdatedGridDim != null) { + Date lastInitTime = lastUpdatedGridDim.getUpdatedTime(); + updatedGrids = customerGridService.listUpdatedGridsByUpdateTime(lastInitTime, now); + ArrayList 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 agencies2Add = listAgencies2Add(now); + List agencies2Update = listAgencies2Update(now); + dimAgencyService.initAgencyDims(agencies2Add, agencies2Update, now); + } + + /** + * 查询需要添加的机关ç + * @return + */ + public List listAgencies2Add(Date endDate) { DimAgencyEntity latestCreatedAgencyDim = dimAgencyService.getLatestCreatedAgencyDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (latestCreatedAgencyDim != null) { lastInitTime = latestCreatedAgencyDim.getCreatedTime(); } - List agencies = customerAgencyService.listAgenciesByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(agencies)) { - dimAgencyService.initAgencyDims(agencies, now); + return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate); + } + + /** + * 查询需要更新的机关 + * @return + */ + public List 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 newCustomers = listNewCustomers(now); + List updatedCustomers = listUpdatedCustomers(now); +// System.out.println(666); + dimCustomerService.initCustomerDims(newCustomers, updatedCustomers, now); + } + + /** + * 查询新增的客户列表 + * @param initTime + * @return + */ + public List listNewCustomers(Date initTime) { DimCustomerEntity lastCreateDim = dimCustomerService.getLatestCreatedDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (lastCreateDim != null) { lastInitTime = lastCreateDim.getCreatedTime(); } - List customers = customerService.listValidCustomersByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(customers)) { - dimCustomerService.initCustomerDims(customers, now); + List customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime); + + return customers; + } + + /** + * 查询更新的客户列表 + * @param initTime + * @return + */ + public List listUpdatedCustomers(Date initTime) { + DimCustomerEntity lastCreatedDim = dimCustomerService.getLatestUpdatedDimEntity(); + if (lastCreatedDim != null) { + // 说明不是首次初始化 + List customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime); + return customers; } + return new ArrayList<>(); } + /** + * 初始化部门维度 + */ @Override public void initDepartmentDim() { + Date now = new Date(); + List newDepartments = listNewDepartments(now); + List updatedDepartments = listUpdatedDepartments(now); + dimDepartmentService.initDepartmentDims(newDepartments, updatedDepartments, now); + } + public List 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 departments = departmentService.listDepartmentsByCreatedTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(departments)) { - dimDepartmentService.initDepartmentDims(departments, now); + public List listUpdatedDepartments(Date initTime) { + DimDepartmentEntity lastUpdatedDeptDim = dimDepartmentService.getLatestUpdatedDimEntity(); + if (lastUpdatedDeptDim != null) { + return departmentService.listDepartmentsByUpdatedTime(lastUpdatedDeptDim.getCreatedTime(), initTime); } + return new ArrayList<>(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 034499e955..96669f2ae9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/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 listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime); + + List listAgenciesByUpdatedTime(Date updatedTime, Date now); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java index 1aa2c2f7db..15178715ed 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java +++ b/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 listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo); + + List listDepartmentsByUpdatedTime(Date createdTime, Date initTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index 00b46e8b75..b2b7a5b129 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/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 getCustomerGridIdList(String customerId, String dateId); + + /** + * 根据更新时间查询变更过的网格列表 + * @param lastInitTime + * @param now + * @return + */ + List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index 2912ca0cca..4813309176 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/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 listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime); } + + @Override + public List listAgenciesByUpdatedTime(Date startTime, Date endTime) { + return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java index ac430a3abd..0a7a4e380a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java +++ b/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 listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) { return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo); } + + @Override + public List listDepartmentsByUpdatedTime(Date startTime, Date endTime) { + return departmentDao.listDepartmentsByUpdatedTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index fc95a3de29..5bab5596a7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/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 getCustomerGridIdList(String customerId, String dateId) { return customerGridDao.getCustomerGridIdList(customerId, dateId); } + + @Override + public List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) { + return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java index df58489fd0..aad2cae314 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java +++ b/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 { /** * 初始化机关维度 - * @param agencies */ - void initAgencyDims(List agencies, Date initTime); + void initAgencyDims(List agencies2Add, List agencies2Update, Date initTime); /** * @Description 查询所有机关以及它下级机关的信息 @@ -175,4 +174,6 @@ public interface DimAgencyService extends BaseService { String getPidByAgencyId(String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java index d3562d01db..9d53593957 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java +++ b/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 { /** * 添加客户维度 - * @param customers */ - void initCustomerDims(List customers, Date initTime); + void initCustomerDims(List newCustomers, List updatedCustomers, Date initTime); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java index fe839ac0c9..767d5b8ffe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java +++ b/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 { */ void delete(String[] ids); - void initDepartmentDims(List departments, Date initTime); + void initDepartmentDims(List newDepartments, List updatedDepartments, Date initTime); /** * desc: 根据客户Id获取 部门数据 @@ -108,4 +108,6 @@ public interface DimDepartmentService extends BaseService { List getDepartmentListByCustomerId(String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java index 312659eb96..b937efdf9e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java +++ b/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 { /** * 初始化网格维度 - * @param gridDims */ - void initGridDims(List gridDims); + void initGridDims(List newDimGrids, List changedGrids); /** * desc: 根据客户Id获取 该客户下所有的网格数据 @@ -128,4 +127,6 @@ public interface DimGridService extends BaseService { * @author zxc */ List selectSubAgencyId(List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 0d21b5525f..d40987c1bc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/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 agencies, Date initTime) { - for (CustomerAgencyEntity agency : agencies) { + public void initAgencyDims(List agencies2Add, List 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 customers, Date initTime) { - for (CustomerEntity customer : customers) { + public void initCustomerDims(List newCustomers, List 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 departments, Date initTime) { - for (CustomerDepartmentEntity department : departments) { + public void initDepartmentDims(List newDepartments, List 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 gridDims) { - for (DimGridEntity gridDim : gridDims) { - baseDao.insert(gridDim); + public void initGridDims(List newDimGrids, List 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 selectSubAgencyId(List formDTO) { return baseDao.selectSubAgencyId(formDTO); } + + @Override + public DimGridEntity getLastUpdatedGridDim() { + return baseDao.getLastUpdatedGridDim(); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml index 0aac258069..382edefac3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml +++ b/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 + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml index 6d3bc43ce3..365ae56b8a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml @@ -16,4 +16,24 @@ + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 6a5253e473..48c5176a78 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/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' ) #{dateId} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml index 3e22e1b5c3..268782eb3d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml @@ -75,4 +75,29 @@ grid.ID + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index 74c52efaa6..dedf82d8fe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml @@ -277,4 +277,25 @@ LIMIT 1 + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml index 7b8ad49e3c..13bc6a3e01 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml +++ b/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 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml index 68de10bef6..4f0a68ed28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml +++ b/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 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index 783230dc55..eef43456f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -52,4 +52,21 @@ + + \ No newline at end of file diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 1a64ebab62..a22f95bf71 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/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 { /** * 文件上传 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java index c668daeaea..65fa58f1cd 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java +++ b/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; /** * 乐观锁 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java new file mode 100644 index 0000000000..6223eafc66 --- /dev/null +++ b/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"; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java index 2004536f1c..1340896baf 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java +++ b/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"; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java index 2e5528ea64..08f038f317 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java +++ b/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 */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java index e88d58e3f9..82867159cf 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java +++ b/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 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 videoIdList; /** * 截屏mediaid列表,可以通过提审素材上传接口获得 */ + @SerializedName("pic_id_list") private List picIdList; } @NoArgsConstructor @Data - private static class UgcDeclareBean { + public static class UgcDeclareBean { /** * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 */ + @SerializedName("scene") private List scene; /** * 当scene选其他时的说明,不超时256字 */ + @SerializedName("other_scene_desc") private String otherSceneDesc; /** * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 */ + @SerializedName("method") private List method; /** * 是否有审核团队, 0.无,1.有,默认0 */ + @SerializedName("has_audit_team") private Integer hasAuditTeam; /** * 说明当前对UGC内容的审核机制,不超过256字 */ + @SerializedName("audit_desc") private String auditDesc; } } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java index 64f3483f55..64a2b42e87 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java +++ b/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; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java new file mode 100644 index 0000000000..2198a52459 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java index 5a91825392..ff62e37885 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java +++ b/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 getCustomerMsg(@PathVariable("appId") String appId); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 用户登陆,新增访问记录数据 + **/ + @PostMapping(value = "third/pacustomer/register") + Result register(@RequestBody RegisterFormDTO formDTO); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java index fda713210f..d3d97faa1a 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java +++ b/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 getCustomerMsg(String appId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerMsg", appId); } + + @Override + public Result register(RegisterFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "register", formDTO); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index 494df190a6..de278b5785 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 6c831bfb2f..2efc3df332 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.39 + 0.0.48 com.epmet @@ -135,6 +135,12 @@ 2.0.0 compile + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java index 5e72094a57..d787e30ed1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java +++ b/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"; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java index cbed19f1c2..4651738fd4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java +++ b/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 = "保存用户微信信息失败"; /** * 组织级别对应的key、name diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java index 13fa20c226..c6cbaa6894 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java +++ b/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:"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java index 2e4e5e7083..b7dc98d4b4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java +++ b/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】"; + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java index c24e502e47..e2b7901ed6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java +++ b/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 getExtJson(CodeUploadFormDTO formDTO) { + public Result getExtJson(@RequestBody CodeUploadFormDTO formDTO) { String extJson = codeService.getExtJson(formDTO); return new Result().ok(extJson); } @@ -175,7 +175,7 @@ public class CodeController { * @date 2020/7/17 11:20 */ @PostMapping("mediaupload") - public Result mediaUpload(@RequestBody MediaUploadFormDTO formDTO) { + public Result mediaUpload(MediaUploadFormDTO formDTO) { String result = codeService.mediaUpload(formDTO); return new Result().ok(result); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 519a1a4cc4..8ed2ff7fd9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/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 register(@RequestBody RegisterFormDTO formDTO) { + return new Result().ok(paCustomerService.register(formDTO)); } /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java index ca98874003..42bb397220 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java +++ b/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 { + + /** + * @Description 插入授权结果记录 + * @param formDTO + * @author zxc + */ + void insertAuthResultRecord(AuthResultRecordFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index 3e98b5a623..f4fde172f6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/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 { */ 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 { * @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 { */ void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType); + /** + * @Description 根据 authAppId 查询客户ID和客户端类型 + * @param authAppId + * @author zxc + */ + AuthCodeResultDTO selectCustomerIdByAuthAppId(@Param("authAppId")String authAppId); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java index 9c29569f0e..87cb38b046 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java @@ -39,10 +39,10 @@ public interface ComponentVerifyTicketDao extends BaseDao { * @param customerId * @author zxc */ - Integer selectAuthCount(@Param("customerId")String customerId); + List selectAuthCount(@Param("customerId")String customerId); /** * @Description 回填customer_mp的appId @@ -107,4 +107,12 @@ public interface CustomerMpDao extends BaseDao { * @Description 根据appId查询客户信息 **/ PaCustomerDTO selectCustomerByAppId(@Param("appId") String appId); + + /** + * @Description 校验此小程序是不是绑定别的客户端 + * @param authAppId + * @param clientType + * @author zxc + */ + Integer checkBind(String authAppId,String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java index 2ec5ef1588..00913eac71 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java @@ -41,6 +41,13 @@ public interface OpenPlatformAccountDao extends BaseDao { - + + /** + * @param openId + * @return + * @Author sun + * @Description 根据openId查询登陆访问记录数据,按时间倒序 + **/ + PaUserVisitedDTO selectByOpenId(@Param("openId") String openId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java index 8d3f6a6351..78d08c42dc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java +++ b/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 { * @Author sun * @Description 根据openId查询user_wechat表信息 **/ - PaUserWechatDTO selectWechatByOpenId(@Param("openId") String openId); + List selectWechatByOpenId(@Param("openId") String openId); /** * @param dto diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java index fe56ddd312..706351f4f7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java +++ b/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; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java index 9317ce418e..e367e13227 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java +++ b/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 map = BeanUtil.beanToMap(authInfo, false, true); + String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + customerId+ThirdRedisKeyConstant.COLON + clientType; + redisUtils.hMSet(key, map,NOT_EXPIRE); } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 87bd164d01..addf9d6d53 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -105,7 +105,7 @@ public interface PaCustomerService extends BaseService { * @Author sun * @Description 公众号-手机号注册 **/ - void register(RegisterFormDTO formDTO); + RegisterResultDTO register(RegisterFormDTO formDTO); /** * @return diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java index 31c520d793..bc873038ac 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java @@ -99,5 +99,5 @@ public interface PaUserWechatService extends BaseService { * @Author sun * @Description 根据openId查询user_wechat表信息 **/ - PaUserWechatDTO getWechatByOpenId(String openId); + List getWechatByOpenId(String openId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java index f2e9d5fd4c..1962b917a9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java +++ b/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 list = baseDao.selectCodeList(formDTO); PageInfo pageInfo = new PageInfo<>(list); return new PageData<>(list, pageInfo.getTotal()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 4b9bfe1757..8e18dadcbf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java +++ b/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 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 auditingList = codeCustomerService.getAuditingCodeList(); - auditingList.forEach(code -> { - //获取审核结果信息 - CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); - //调用微信API获取最新审核状态 - WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); - request.setAuditId(auditResult.getAuditId()); - WxResult 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 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 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 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); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index 30517d5cb7..69302821e7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/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 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 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 result){ + Map tempMap = result; + Map 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 funcInfos = new ArrayList<>(); List 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 categoryInfoList = new ArrayList<>(); List categories = (List) 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 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 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 bindInfo = JSON.parseObject(bindResult, Map.class); + boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); + if (bindStatus != true) { + log.info(CREATE_AND_BIND_SUCCESS); + List 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 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 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 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; + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 63290cfb9f..62fdde3a8c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/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 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 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; } /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java index dfdb56af5f..680bf4fec4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java +++ b/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 private PaCustomerDao paCustomerDao; @Autowired private PaUserWechatDao paUserWechatDao; + @Autowired + private PaUserVisitedDao paUserVisitedDao; @Override public PageData page(Map params) { @@ -127,11 +131,11 @@ public class PaUserServiceImpl extends BaseServiceImpl @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 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 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 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 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java index 9fb9089c5e..46726a9823 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java +++ b/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 getWechatByOpenId(String openId) { return baseDao.selectWechatByOpenId(openId); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index e98f7a4701..8ec83ac350 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/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"; + + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java index c9fa07b8e4..1c63b9ed3a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java +++ b/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 itemList; + private List itemList; /** * 预览信息(小程序页面截图和操作录屏) */ @SerializedName("preview_info") - private List previewInfo; + private List previewInfo; /** * 用户生成内容场景(UGC)信息安全声明 */ @SerializedName("ugc_declare") - private List 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 videoIdList; - /** - * 截屏mediaid列表,可以通过提审素材上传接口获得 - */ - @SerializedName("pic_id_list") - private List picIdList; - } - - @NoArgsConstructor - @Data - private static class UgcDeclareBean { - /** - * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 - */ - @SerializedName("scene") - private List scene; - /** - * 当scene选其他时的说明,不超时256字 - */ - @SerializedName("other_scene_desc") - private String otherSceneDesc; - /** - * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 - */ - @SerializedName("method") - private List method; - /** - * 是否有审核团队, 0.无,1.有,默认0 - */ - @SerializedName("has_audit_team") - private Integer hasAuditTeam; - /** - * 说明当前对UGC内容的审核机制,不超过256字 - */ - @SerializedName("audit_desc") - private String auditDesc; - } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java new file mode 100644 index 0000000000..694dd0f262 --- /dev/null +++ b/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 requestDomain; + private List wsRequestDomain; + private List uploadDomain; + private List downloadDomain; + private List webviewDomain; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java index 8ae28634de..6edf2fbbd0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java +++ b/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 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 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 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 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.返回结果 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java index dfc9bb5cc9..e0ae3823e5 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java +++ b/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 requestDomain; - @Value("${third.domain.wsrequestdomain}") - private List wsRequestDomain; - @Value("${third.domain.uploaddomain}") - private List uploadDomain; - @Value("${third.domain.downloaddomain}") - private List downloadDomain; - @Value("${third.domain.webviewdomain}") - private List webviewDomain; + + @Autowired + private WxMaDomainDTO wxMaDomainDTO; @Override public WxResult> getTemplateList(String accessToken) { WxResult> result = new WxResult<>(); - String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + String url = WxMaCodeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken; Result 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 getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request) { WxResult result = new WxResult<>(); - String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + String url = WxMaCodeConstant.GET_AUDIT_STATUS_URL + "?" + "access_token=" + accessToken; Result 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 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 modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); if (!modifyResult.success()) { result.setErrorCode(modifyResult.getCode()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml index 34cba72036..82188b3697 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml +++ b/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" \ No newline at end of file + 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 \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml index d0c2ba2654..9cc47df530 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml @@ -3,4 +3,25 @@ + + + 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() + ) + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index 406a9fd06c..d8ab9821eb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -5,7 +5,7 @@ - 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 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} @@ -41,7 +42,6 @@ WHERE del_flag = 0 AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) 900 - AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) > 0 @@ -68,6 +68,7 @@ update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml index 8547b41dcf..d0d3d49815 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml +++ b/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() diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml index 22d77316e6..dbfe38c5e7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml +++ b/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' diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml index 277beabe35..66041c4ea0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml @@ -9,7 +9,7 @@ - + @@ -19,7 +19,7 @@ UPDATE code_operation_history SET - `DESCRIBE` = #{describe} + `DESCRIPTION` = #{describe} WHERE CODE_ID = #{codeId} AND OPERATION = 'audit' @@ -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 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml index 53e1820b8a..c48019c3a3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml +++ b/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' diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml index ba33593a48..c875223478 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml @@ -21,9 +21,9 @@ - - update component_verify_ticket set del_flag = 1 - + + DELETE FROM component_verify_ticket WHERE del_flag = 0 + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index 4612ca8c88..f4e6b6403a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -19,9 +19,9 @@ client ASC - 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} @@ -51,7 +51,7 @@ + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml index efaa55adad..4b4842e478 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml +++ b/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 @@ ) + + + UPDATE open_platform_account set del_flag = 1 where customer_id = #{customerId} + + + 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 + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml index d1c7b78043..0b247eae18 100644 --- a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 191856ef70..3d9f8fd97c 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.75 + 0.3.76 com.epmet gov-org diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index b14ab6036d..5b220aa698 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/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 getCustomerInfo(CustomerDTO dto); } diff --git a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml b/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml index a8b5a7a663..20aac7e3ec 100644 --- a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml +++ b/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 # 使用现有网络 diff --git a/epmet-module/resi-guide/resi-guide-server/pom.xml b/epmet-module/resi-guide/resi-guide-server/pom.xml index d93427f6b0..48851b561e 100644 --- a/epmet-module/resi-guide/resi-guide-server/pom.xml +++ b/epmet-module/resi-guide/resi-guide-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.17 + 0.3.18 com.epmet resi-guide diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index 88d224e76e..a16884cdcd 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/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 # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 2c3f938f56..9ec79e461e 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.76 + 0.3.77 com.epmet epmet-user