Browse Source

单客户初始化客户信息接口

dev_shibei_match
sunyuchao 5 years ago
parent
commit
05501ff61a
  1. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 7
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java
  3. 32
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java
  4. 11
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java
  5. 6
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java
  6. 16
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java
  7. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java
  8. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java
  9. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  10. 46
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  11. 34
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml
  12. 17
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
  13. 48
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java
  14. 63
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java
  15. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  16. 6
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  17. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  18. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  19. 64
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  20. 23
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java
  21. 6
      epmet-module/oper-crm/oper-crm-server/pom.xml
  22. 20
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  23. 2
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java
  24. 11
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  25. 102
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  26. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  27. 6
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -85,7 +85,10 @@ public enum EpmetErrorCode {
CUSTOMER_VALIDATE_ERROR(8999, "内部数据校验异常"),
//公众号 865..开头的码
PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册");
PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"),
SELECT_CUSTOMER_ERROR(8652,"未查询到注册客户信息"),
SELECT_AGENCY_ERROR(8653,"根据客户信息未查询到注册客户组织信息"),
SELECT_USER_ERROR(8654,"根据客户信息未查询到注册客户管理员信息");
private int code;

7
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java

@ -19,6 +19,8 @@ package com.epmet.dto;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
@ -52,6 +54,11 @@ public class PaCustomerAgencyDTO implements Serializable {
* 级别
*/
private String level;
/**
* 级别(0.省级1市级2.区县级3.乡镇街道级 4.社区级 5无)
*/
@JsonIgnore
private String levelNum;
/**
* 地区编码

32
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.result;
import com.epmet.dto.PaCustomerAgencyDTO;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO;
import lombok.Data;
import java.io.Serializable;
/**
* @Author sun
* @Description 运营端初始化客户信息-查询客户各项注册信息-接口返参
*/
@Data
public class InitCustomerResultDTO implements Serializable {
private static final long serialVersionUID = 3253989119352850315L;
/**
* 注册客户信息
*/
private PaCustomerDTO paCustomer;
/**
* 注册客户组织信息
*/
private PaCustomerAgencyDTO paAgency;
/**
* 注册客户管理员信息
*/
private PaUserDTO paUser;
}

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

@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.SaveUserVisitedFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.feign.fallback.EpmetThirdFeignClientFallback;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
@ -49,4 +50,14 @@ public interface EpmetThirdFeignClient {
**/
@PostMapping(value = "third/pauservisited/saveuservisited")
Result saveUserVisited(@RequestBody SaveUserVisitedFormDTO visited);
/**
* @param customerId
* @return
* @Author sun
* @Description 根据客户Id查询各项注册信息
**/
@PostMapping(value = "third/pacustomer/getcustomeragencyuser/{customerId}")
Result<InitCustomerResultDTO> getCustomerAgencyUser(@PathVariable("customerId") String customerId);
}

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

@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.SaveUserVisitedFormDTO;
import com.epmet.dto.result.CustomerUserResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.SaveUserResultDTO;
import com.epmet.feign.EpmetThirdFeignClient;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
@ -31,4 +32,9 @@ public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient {
public Result saveUserVisited(SaveUserVisitedFormDTO visited) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveUserVisited", visited);
}
@Override
public Result<InitCustomerResultDTO> getCustomerAgencyUser(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerAgencyUser", customerId);
}
}

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

@ -11,13 +11,11 @@ import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.RegisterInfoFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -101,5 +99,15 @@ public class PaCustomerController {
return new Result<PageData>().ok(paCustomerService.registerInfo(formDTO));
}
/**
* @param customerId
* @return
* @Author sun
* @Description 根据客户Id查询各项注册信息
**/
@PostMapping(value = "getcustomeragencyuser/{customerId}")
public Result<InitCustomerResultDTO> getCustomerAgencyUser(@PathVariable("customerId") String customerId) {
return new Result<InitCustomerResultDTO>().ok(paCustomerService.getCustomerAgencyUser(customerId));
}
}

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

@ -46,4 +46,12 @@ public interface PaCustomerAgencyDao extends BaseDao<PaCustomerAgencyEntity> {
* @Description 公众号-查询客户组织信息
**/
PaCustomerAgencyDTO selectCustomerAgency(@Param("customerId") String customerId);
/**
* @param customerId
* @return
* @Author sun
* @Description 公众号-查询客户组织信息
**/
PaCustomerAgencyDTO selectAgency(@Param("customerId") String customerId);
}

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

@ -41,4 +41,12 @@ public interface PaUserDao extends BaseDao<PaUserEntity> {
* @Description 根据手机号查询公众号用户基本信息校验用户是否存在
**/
List<PaUserDTO> selectUserByPhone(@Param("phone") String phone);
/**
* @param customerId
* @return
* @Author sun
* @Description 根据客户Id级联查询客户管理员注册信息
**/
PaUserDTO selectPaUser(@Param("customerId") String customerId);
}

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

@ -26,6 +26,7 @@ import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.RegisterInfoFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.InitCustomerResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.entity.PaCustomerEntity;
@ -138,4 +139,13 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
* @Description 查询公众号注册的客户信息列表
**/
PageData registerInfo(RegisterInfoFormDTO formDTO);
/**
* @param customerId
* @return
* @Author sun
* @Description 根据客户Id查询各项注册信息
**/
InitCustomerResultDTO getCustomerAgencyUser(String customerId);
}

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

@ -37,10 +37,7 @@ import com.epmet.dto.*;
import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.RegisterInfoFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.CustomerAgencyResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
import com.epmet.redis.PaCustomerRedis;
import com.epmet.service.CustomerMpService;
@ -312,7 +309,7 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
//0.根据token中userId查询对应的客户Id,客户Id没有则表示用户没有填写过组织信息,需要继续完善信息
PaCustomerUserAgencyDTO dto = paCustomerUserAgencyDao.selectByUserId(tokenDTO.getUserId());
if(null==dto||null==dto.getCustomerId()){
if (null == dto || null == dto.getCustomerId()) {
return new MyInfoResultDTO();
}
String customerId = dto.getCustomerId();
@ -348,7 +345,7 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
* @param formDTO
* @return
* @Author sun
* @Description 查询公众号注册的客户信息列表
* @Description 查询公众号注册的客户信息列表
**/
@Override
public PageData registerInfo(RegisterInfoFormDTO formDTO) {
@ -377,6 +374,43 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
return new PageData<>(list, pageInfo.getTotal());
}
/**
* @param customerId
* @return
* @Author sun
* @Description 根据客户Id查询各项注册信息
**/
@Override
public InitCustomerResultDTO getCustomerAgencyUser(String customerId) {
InitCustomerResultDTO result = new InitCustomerResultDTO();
//1.查询注册客户信息,并判断是否已完成初始化
PaCustomerEntity entity = baseDao.selectById(customerId);
//未查询到注册客户信息
if (null == entity) {
throw new RenException(EpmetErrorCode.SELECT_CUSTOMER_ERROR.getCode());
}
//客户已完成初始化
if (NumConstant.ONE == entity.getIsInitialize()) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode());
}
PaCustomerDTO paCustomer = ConvertUtils.sourceToTarget(entity, PaCustomerDTO.class);
result.setPaCustomer(paCustomer);
//2.查询注册客户对应的组织信息
PaCustomerAgencyDTO paAgency = paCustomerAgencyDao.selectAgency(customerId);
if (null == paAgency) {
throw new RenException(EpmetErrorCode.SELECT_AGENCY_ERROR.getCode());
}
result.setPaAgency(paAgency);
//3.查询组织客户对应的管理员信息
PaUserDTO paUser = paUserDao.selectPaUser(customerId);
if (null == paUser) {
throw new RenException(EpmetErrorCode.SELECT_USER_ERROR.getCode());
}
result.setPaUser(paUser);
return result;
}
}

34
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml

@ -48,4 +48,38 @@
LIMIT 1
</select>
<select id="selectAgency" resultType="com.epmet.dto.PaCustomerAgencyDTO">
SELECT
id,
customer_id,
agency_name,
`level`,
(
CASE
WHEN `level` = 'province' THEN
'0'
WHEN `level` = 'city' THEN
'1'
WHEN `level` = 'district' THEN
'2'
WHEN `level` = 'street' THEN
'3'
WHEN `level` = 'community' THEN
'4'
ELSE
'5'
END
) AS "levelNum",
area_code,
IFNULL(province,"") AS "province",
IFNULL(city,"") AS "city",
IFNULL(district,"") AS "district",
partybranchnum
FROM
pa_customer_agency
WHERE del_flag = '0'
AND customer_id = #{customerId}
LIMIT 1
</select>
</mapper>

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

@ -16,4 +16,21 @@
AND phone = #{phone}
</select>
<select id="selectPaUser" resultType="com.epmet.dto.PaUserDTO">
SELECT
pu.id,
pu.phone,
pu.real_name,
pu.gender
FROM
pa_user pu
INNER JOIN pa_customer_user_agency pcua ON pu.id = pcua.user_id
WHERE
pu.del_flag = '0'
AND pcua.del_flag = '0'
AND pcua.customer_id = #{customerId}
ORDER BY pcua.created_time DESC
LIMIT 1
</select>
</mapper>

48
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java

@ -0,0 +1,48 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import com.epmet.dto.CustomerAgencyDTO;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 单客户-添加根组织及管理员-接口入参
*
* @author sun
*/
@Data
public class AddAgencyAndStaffFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 根级组织对象
*/
private CustomerAgencyDTO agencyDTO;
/**
* 客户管理员信息
*/
private AdminStaffFromDTO staffDTO;
}

63
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java

@ -0,0 +1,63 @@
package com.epmet.dto.form;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;
/**
* @author sun
* @dscription 客户管理员信息
*/
@NoArgsConstructor
@Data
public class AdminStaffFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 人员ID
*/
private String staffId;
/**
* 姓名
*/
@Length(max = 15, message = "姓名仅允许输入15个字符")
private String name;
/**
* 手机
*/
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号")
private String mobile;
/**
* 性别
*/
private Integer gender;
/**
* 专兼职
*/
private String workType;
/**
* 角色id列表
*/
private List<String> roles;
/**
* 来源app(政府端:gov居民端:resi运营端:oper)
*/
private String app;
/**
* 来源client(PC端:web微信小程序:wxmp)
*/
private String client;
}

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -4,6 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.AddRootAgencyFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.result.GridInfoResultDTO;
@ -15,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -131,4 +134,13 @@ public interface GovOrgOpenFeignClient {
**/
@GetMapping(value = "gov/org/customerpartybranch/decrPartyBranchMember/{partyBranchId}")
Result decrPartyBranchMember(@PathVariable("partyBranchId") String partyBranchId);
/**
* @param agencyAndStaff
* @return
* @Author sun
* @Description 单客户-添加根组织及客户管理员信息
**/
@PostMapping("/gov/org/agency/saverootagency")
Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff);
}

6
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.result.GridInfoResultDTO;
@ -77,4 +78,9 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
public Result decrPartyBranchMember(String partyBranchId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "decrPartyBranchMember",partyBranchId);
}
@Override
public Result saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "saveRootAgency", agencyAndStaff);
}
}

13
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -219,4 +219,17 @@ public class AgencyController {
return new Result().ok(customerRootAgencies);
}
/**
* @param agencyAndStaff
* @return
* @Author sun
* @Description 单客户-添加根组织及客户管理员信息
* @Date 2020/7/16 17:13
**/
@PostMapping("saverootagency")
public Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff) {
agencyService.saveRootAgency(agencyAndStaff);
return new Result();
}
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java

@ -99,4 +99,13 @@ public interface AgencyService {
CustomerAgencyDTO getCustomerRootAgency(String customerId);
String addRootAgency(AddRootAgencyFormDTO form);
/**
* @param agencyAndStaff
* @return
* @Author sun
* @Description 单客户-添加根组织及客户管理员信息
* @Date 2020/7/16 17:13
**/
void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff);
}

64
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -17,17 +17,23 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
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.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.UserWorkType;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService;
@ -54,9 +60,12 @@ public class AgencyServiceImpl implements AgencyService {
private CustomerAgencyDao customerAgencyDao;
@Autowired
private CustomerAgencyService customerAgencyService;
@Autowired
private CustomerAgencyRedis customerAgencyRedis;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private StaffServiceImpl staffServiceImpl;
/**
* @param formDTO
@ -291,4 +300,57 @@ public class AgencyServiceImpl implements AgencyService {
customerAgencyDao.insert(entity);
return entity.getId();
}
/**
* @param agencyAndStaff
* @return
* @Author sun
* @Description 单客户-添加根组织及客户管理员信息
* @Date 2020/7/16 17:13
**/
@Override
public void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) {
CustomerAgencyDTO agencyDTO = agencyAndStaff.getAgencyDTO();
AdminStaffFromDTO staffDTO = agencyAndStaff.getStaffDTO();
//1.判断当前客户是否已存在根级组织
CustomerAgencyDTO rootAgencyExists = customerAgencyDao.getCustomerRootAgency(agencyDTO.getCustomerId());
if (rootAgencyExists != null) {
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getCode(),
EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getMsg());
}
//2.新增根级组织
CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(agencyDTO, CustomerAgencyEntity.class);
entity.setPid("0");
entity.setPids("");
entity.setAllParentName("");
entity.setTotalUser(0);
if (customerAgencyDao.insert(entity) < NumConstant.ONE) {
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR.getCode());
}
//3.查询客户具有指定RoleKey的角色信息
CustomerRoleFormDTO customerRoleForm = new CustomerRoleFormDTO();
customerRoleForm.setCustomerId(agencyDTO.getCustomerId());
customerRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER);
Result<GovStaffRoleDTO> getRoleResult = epmetUserOpenFeignClient.getRoleOfCustomer(customerRoleForm);
if (!getRoleResult.success() || getRoleResult.getData() == null) {
log.error("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString()));
throw new RenException("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString()));
}
//4.新增客户管理员信息
StaffSubmitFromDTO staffSubmitFrom = ConvertUtils.sourceToTarget(staffDTO, StaffSubmitFromDTO.class);
staffSubmitFrom.setRoles(Arrays.asList(getRoleResult.getData().getId()));
staffSubmitFrom.setApp("gov");
staffSubmitFrom.setClient("wxmp");
Result staffResult = staffServiceImpl.addStaff(staffSubmitFrom);
if (!staffResult.success()) {
log.error(String.format("新增客户管理员失败,调用gov-org-server服务异常%s", JSON.toJSONString(staffResult)));
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_MANAGER_ERROR.getCode(), staffResult.getMsg());
}
}
}

23
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description 运营端-初始化在公众号注册的客户-接口入参
* @Author sun
*/
@Data
public class CustomerInitFormDTO implements Serializable {
public interface GetCustomerDetailGroup {
}
@NotBlank(message = "客户Id不能为空", groups = {GetCustomerDetailGroup.class})
private String customerId;
}

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

@ -81,6 +81,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-third-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

20
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java

@ -30,10 +30,7 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.AddRootAgencyFormDTO;
import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.PageQueryFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerDetailResultDTO;
import com.epmet.dto.result.ValidCustomerResultDTO;
import com.epmet.excel.CustomerExcel;
@ -235,4 +232,19 @@ public class CustomerController {
ValidatorUtils.validateEntity(formDTO);
return new Result<PageData>().ok(customerService.pageQuery(formDTO));
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 单客户-运营端-初始化在公众号注册的客户
* @Date 2020/7/16 17:13
**/
@PostMapping("init")
public Result init(@RequestBody CustomerInitFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.GetCustomerDetailGroup.class);
customerService.init(formDTO);
return new Result();
}
}

2
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java

@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
//@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class, url = "localhost:8089")
@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class)
@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class,url="localhost:8089")
public interface OperCustomizeFeignClient {
/**

11
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.dto.form.CustomerInitFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.PageQueryFormDTO;
import com.epmet.dto.result.CustomerDetailResultDTO;
@ -158,4 +159,14 @@ public interface CustomerService extends BaseService<CustomerEntity> {
* @Description 运营端-客户列表查询
**/
PageData pageQuery(PageQueryFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 单客户-运营端-初始化在公众号注册的客户
* @Date 2020/7/16 17:13
**/
void init(CustomerInitFormDTO formDTO);
}

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

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
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.page.PageData;
@ -30,16 +31,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.UserWorkType;
import com.epmet.dao.CustomerDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.CustomerHomeDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.OperCustomizeFeignClient;
import com.epmet.feign.*;
import com.epmet.redis.CustomerRedis;
import com.epmet.service.CustomerService;
import com.github.pagehelper.PageHelper;
@ -64,18 +60,18 @@ import java.util.stream.Collectors;
public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEntity> implements CustomerService {
private static final Logger log = LoggerFactory.getLogger(CustomerServiceImpl.class);
@Autowired
private CustomerRedis customerRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private OperCustomizeFeignClient operCustomizeFeignClient;
@Autowired
private EpmetThirdFeignClient epmetThirdFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public PageData<CustomerDTO> page(Map<String, Object> params) {
@ -394,4 +390,88 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
return resultDTO;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 单客户-运营端-初始化在公众号注册的客户
* @Date 2020/7/16 17:13
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void init(CustomerInitFormDTO formDTO) {
//1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息
Result<InitCustomerResultDTO> thirdResult = epmetThirdFeignClient.getCustomerAgencyUser(formDTO.getCustomerId());
if (!thirdResult.success()) {
throw new RenException(thirdResult.getCode(), thirdResult.getInternalMsg());
}
InitCustomerResultDTO initCustomer = thirdResult.getData();
PaCustomerDTO paCustomer = initCustomer.getPaCustomer();
PaCustomerAgencyDTO paAgency = initCustomer.getPaAgency();
PaUserDTO paUser = initCustomer.getPaUser();
//2.校验当前客户是否已初始化,不存在则初始客户信息
CustomerEntity entity = baseDao.selectById(formDTO.getCustomerId());
if (null != entity) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode());
}
//2-1.新增客户信息
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setId(formDTO.getCustomerId());
customerEntity.setCustomerName(paCustomer.getCustomerName());
customerEntity.setTitle("");
customerEntity.setOrganizationNumber("");
customerEntity.setOrganizationImg("");
customerEntity.setValidityTime(getValidityTime());
customerEntity.setOrganizationLevel(paAgency.getLevelNum());
customerEntity.setLogo("");
if (baseDao.insert(customerEntity) < NumConstant.ONE) {
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode());
}
//3.调用epmet-user服务,初始化客户对应的角色;调用access服务给角色分配权限信息
Result initResult = epmetUserFeignClient.initGovStaffRolesForCustomer(formDTO.getCustomerId());
if (!initResult.success()) {
throw new RenException("客户新增:调用user服务为客户初始化角色数据失败:".concat(initResult.toString()));
}
//4.调用oper-customize服务,初始化客户定制化首页模板数据
CustomerHomeDTO initHomeForm = new CustomerHomeDTO();
initHomeForm.setCustomerId(formDTO.getCustomerId());
Result initHomeResult = operCustomizeFeignClient.init(initHomeForm);
if (!initHomeResult.success()) {
throw new RenException("初始化客户首页数据失败:".concat(initHomeResult.getInternalMsg()));
}
//5.调用gov-org服务,初始化客户根级组织信息、客户管理员信息
AddAgencyAndStaffFormDTO agencyAndStaff = new AddAgencyAndStaffFormDTO();
//客户组织信息
CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO();
agencyDTO.setId(paAgency.getId());
agencyDTO.setCustomerId(formDTO.getCustomerId());
agencyDTO.setOrganizationName(paAgency.getAgencyName());
agencyDTO.setLevel(paAgency.getLevel());
agencyDTO.setAreaCode(paAgency.getAreaCode());
agencyDTO.setProvince(paAgency.getProvince());
agencyDTO.setCity(paAgency.getCity());
agencyDTO.setDistrict(paAgency.getDistrict());
agencyAndStaff.setAgencyDTO(agencyDTO);
//客户管理员信息
AdminStaffFromDTO staffSubmitFrom = new AdminStaffFromDTO();
staffSubmitFrom.setCustomerId(formDTO.getCustomerId());
staffSubmitFrom.setAgencyId(paAgency.getId());
staffSubmitFrom.setGender(Integer.parseInt(paUser.getGender()));
staffSubmitFrom.setMobile(paUser.getPhone());
staffSubmitFrom.setName(paUser.getRealName());
staffSubmitFrom.setWorkType(UserWorkType.FULL_TIME);
agencyAndStaff.setStaffDTO(staffSubmitFrom);
Result agencyResult = govOrgOpenFeignClient.saveRootAgency(agencyAndStaff);
if (!agencyResult.success()) {
throw new RenException(agencyResult.getCode(), agencyResult.getInternalMsg());
}
}
}

9
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -3,6 +3,7 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallback;
@ -86,4 +87,12 @@ public interface EpmetUserOpenFeignClient {
**/
@PostMapping(value = "/epmetuser/customerstaff/resetstaffpassword", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result resetStaffPassword(@RequestBody StaffResetPwFormDTO staffResetPwFormDTO);
/**
* 根据客户ID和角色key查询角色信息
* @param form
* @return
*/
@PostMapping("/epmetuser/staffrole/roleofcustomer")
Result<GovStaffRoleDTO> getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form);
}

6
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -4,6 +4,7 @@ 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.CustomerStaffDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
@ -55,4 +56,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "resetStaffPassword", staffResetPwFormDTO);
}
@Override
public Result<GovStaffRoleDTO> getRoleOfCustomer(CustomerRoleFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRoleOfCustomer", form);
}
}

Loading…
Cancel
Save