Browse Source

根据客户id查询根客户信息

dev_shibei_match
yinzuomei 5 years ago
parent
commit
18fe79310d
  1. 21
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/CustomerInfoQueryFormDTO.java
  2. 22
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/CustomerInfoQueryResultDTO.java
  3. 6
      epmet-module/epmet-ext/epmet-ext-server/pom.xml
  4. 11
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java
  5. 8
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java
  6. 20
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java
  7. 110
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java
  8. 23
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationInfoResultDTO.java
  9. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  10. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  11. 20
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  12. 35
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java
  13. 77
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java
  14. 116
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java
  15. 12
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  16. 140
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java
  17. 23
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  18. 2
      epmet-module/oper-crm/oper-crm-server/src/main/resources/logback-spring.xml
  19. 16
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml

21
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/CustomerInfoQueryFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 009根据客户id查询根客户信息入参DTO
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/2 22:25
*/
@Data
public class CustomerInfoQueryFormDTO {
/**
* 客户id
*/
@NotBlank(message = "客户id不能为空")
private String customerId;
}

22
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/CustomerInfoQueryResultDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.result;
import lombok.Data;
/**
* 009根据客户id查询根客户信息 返参DTO
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/2 22:26
*/
@Data
public class CustomerInfoQueryResultDTO {
/**
* 当前客户id的根级客户id返回值0代表当前客户是根客户没有上级客户
*/
private String rootCustomerId;
/**
* 客户id
*/
private String customerId;
}

6
epmet-module/epmet-ext/epmet-ext-server/pom.xml

@ -144,6 +144,12 @@
<version>5.1.12.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-crm-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

11
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java

@ -125,5 +125,16 @@ public class OpenUpController {
return new Result<OrganizeTreeResultDTO>().ok(openUpService.organizeTree(formDTO));
}
/**
* @param formDTO
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/2 22:29
**/
@PostMapping("querycustomerinfo")
public Result<CustomerInfoQueryResultDTO> queryCustomerInfo(@RequestBody CustomerInfoQueryFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO);
return new Result<CustomerInfoQueryResultDTO>().ok(openUpService.queryCustomerInfo(formDTO));
}
}

8
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java

@ -46,4 +46,12 @@ public interface OpenUpService {
* @author sun
**/
OrganizeTreeResultDTO organizeTree(OrganizeTreeFormDTO formDTO);
/**
* @param formDTO
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/2 22:30
**/
CustomerInfoQueryResultDTO queryCustomerInfo(CustomerInfoQueryFormDTO formDTO);
}

20
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java

@ -3,12 +3,14 @@ package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
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.ModuleConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.service.OpenUpService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +31,8 @@ public class OpenUpServiceImpl implements OpenUpService {
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
/**
* @Description 网格工作人员 被禁用的未激活的不显示
@ -147,4 +151,20 @@ public class OpenUpServiceImpl implements OpenUpService {
return result.getData();
}
/**
* @param formDTO
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/2 22:30
**/
@Override
public CustomerInfoQueryResultDTO queryCustomerInfo(CustomerInfoQueryFormDTO formDTO) {
//调用oper_crm查询根级客户,如果根级客户是外部客户,则需要调用commonservice获取名称
Result<CustomerRelationInfoResultDTO> crmResult = operCrmOpenFeignClient.queryCustomerInfoByCustomerId(formDTO.getCustomerId());
if (!crmResult.success() && null == crmResult.getData()) {
throw new RenException("调用oper_crm查询客户信息异常"+crmResult.getInternalMsg());
}
return ConvertUtils.sourceToTarget(crmResult.getData(), CustomerInfoQueryResultDTO.class);
}
}

110
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java

@ -0,0 +1,110 @@
/**
* 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;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Data
public class CustomerRelationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 父级客户id;如果是顶级客户此列=0
*/
private String parentCustomerId;
/**
* 当前客户类型取值 external:外部客户internal:内部客户
*/
private String customerType;
/**
* 父级客户类型取值 external:外部客户internal:内部客户;如果是顶级客户此列=0
*/
private String parentCustomerType;
/**
* open,closed是否启用
*/
private String status;
/**
* 当前客户级别社区级community
街道:street,
区县级: district,
市级: city
省级:province
*/
private String level;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String areaCode;
/**
* 删除标识0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

23
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationInfoResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.Data;
/**
* 009根据客户id查询根客户信息 返参DTO
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/3 11:15
*/
@Data
public class CustomerRelationInfoResultDTO {
/**
* 客户id
*/
private String customerId;
/**
* 当前客户id的根级客户id返回值0代表当前客户是根客户没有上级客户
*/
private String rootCustomerId;
}

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

@ -9,9 +9,12 @@ import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.CustomerRelationInfoResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -94,4 +97,13 @@ public interface OperCrmOpenFeignClient {
*/
@PostMapping("/oper/crm/parameter/parameterupdate")
Result updateParamInfo(@RequestBody List<CrmParameterResultDTO> formDTOS);
/**
* @param customerId
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/3 12:44
**/
@GetMapping("/oper/crm/customer/querycustomerinfobycustomerid/{customerId}")
Result<CustomerRelationInfoResultDTO> queryCustomerInfoByCustomerId(@PathVariable("customerId") String customerId);
}

12
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java

@ -10,6 +10,7 @@ import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.CustomerRelationInfoResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.springframework.stereotype.Component;
@ -69,4 +70,15 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result updateParamInfo(List<CrmParameterResultDTO> formDTOS) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS);
}
/**
* @param customerId
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/3 12:44
**/
@Override
public Result<CustomerRelationInfoResultDTO> queryCustomerInfoByCustomerId(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "queryCustomerInfoByCustomerId", customerId);
}
}

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

@ -31,13 +31,11 @@ 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.*;
import com.epmet.dto.result.CustomerDetailResultDTO;
import com.epmet.dto.result.CustomerInfoResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.dto.result.ValidCustomerResultDTO;
import com.epmet.dto.result.*;
import com.epmet.excel.CustomerExcel;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.service.CustomerService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -330,4 +328,18 @@ public class CustomerController {
return new Result();
}
/**
* @param customerId
* @author yinzuomei
* @description 009根据客户id查询根客户信息
* @Date 2021/2/3 12:52
**/
@GetMapping("querycustomerinfobycustomerid/{customerId}")
public Result<CustomerRelationInfoResultDTO> queryCustomerInfoByCustomerId(@PathVariable("customerId") String customerId){
if(StringUtils.isNotBlank(customerId)){
CustomerRelationInfoResultDTO resultDTO=customerService.queryCustomerInfoByCustomerId(customerId);
return new Result<CustomerRelationInfoResultDTO>().ok(resultDTO);
}
return new Result<>();
}
}

35
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java

@ -0,0 +1,35 @@
/**
* 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.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.entity.CustomerRelationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Mapper
public interface CustomerRelationDao extends BaseDao<CustomerRelationEntity> {
CustomerRelationDTO selectByCustomerId(String customerId);
}

77
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java

@ -0,0 +1,77 @@
/**
* 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.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_relation")
public class CustomerRelationEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 父级客户id;如果是顶级客户此列=0
*/
private String parentCustomerId;
/**
* 当前客户类型取值 external:外部客户internal:内部客户
*/
private String customerType;
/**
* 父级客户类型取值 external:外部客户internal:内部客户;如果是顶级客户此列=0
*/
private String parentCustomerType;
/**
* open,closed是否启用
*/
private String status;
/**
* 当前客户级别社区级community
街道:street,
区县级: district,
市级: city
省级:province
*/
private String level;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String areaCode;
}

116
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java

@ -0,0 +1,116 @@
/**
* 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.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.entity.CustomerRelationEntity;
import java.util.List;
import java.util.Map;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
public interface CustomerRelationService extends BaseService<CustomerRelationEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CustomerRelationDTO>
* @author generator
* @date 2021-02-03
*/
PageData<CustomerRelationDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CustomerRelationDTO>
* @author generator
* @date 2021-02-03
*/
List<CustomerRelationDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CustomerRelationDTO
* @author generator
* @date 2021-02-03
*/
CustomerRelationDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-02-03
*/
void save(CustomerRelationDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-02-03
*/
void update(CustomerRelationDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-02-03
*/
void delete(String[] ids);
/**
* 根据客户id查询客户关系表
*
* @param customerId
* @return void
* @author generator
* @date 2021-02-03
*/
CustomerRelationDTO getByCustomerId(String customerId);
/**
* 获取某个客户的根客户id
*
* @param customerId
* @return void
* @author generator
* @date 2021-02-03
*/
String getRootCustomerId(String customerId);
}

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

@ -22,10 +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.*;
import com.epmet.dto.result.CustomerDetailResultDTO;
import com.epmet.dto.result.CustomerInfoResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.dto.result.ValidCustomerResultDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerEntity;
import java.text.ParseException;
@ -222,4 +219,11 @@ public interface CustomerService extends BaseService<CustomerEntity> {
*/
void updateCustomerParameter(UpdateCustomerParameterFormDTO formDTO) throws ParseException;
/**
* @param customerId
* @author yinzuomei
* @description 009根据客户id查询根客户信息 返参DTO
* @Date 2021/2/3 12:52
**/
CustomerRelationInfoResultDTO queryCustomerInfoByCustomerId(String customerId);
}

140
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java

@ -0,0 +1,140 @@
/**
* 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.service.impl;
import com.alibaba.fastjson.JSON;
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.constant.StrConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.CustomerRelationDao;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.entity.CustomerRelationEntity;
import com.epmet.service.CustomerRelationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Slf4j
@Service
public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelationDao, CustomerRelationEntity> implements CustomerRelationService {
@Override
public PageData<CustomerRelationDTO> page(Map<String, Object> params) {
IPage<CustomerRelationEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerRelationDTO.class);
}
@Override
public List<CustomerRelationDTO> list(Map<String, Object> params) {
List<CustomerRelationEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerRelationDTO.class);
}
private QueryWrapper<CustomerRelationEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerRelationEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CustomerRelationDTO get(String id) {
CustomerRelationEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerRelationDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerRelationDTO dto) {
CustomerRelationEntity entity = ConvertUtils.sourceToTarget(dto, CustomerRelationEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerRelationDTO dto) {
CustomerRelationEntity entity = ConvertUtils.sourceToTarget(dto, CustomerRelationEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* 根据客户id查询客户关系表
*
* @param customerId
* @return void
* @author generator
* @date 2021-02-03
*/
@Override
public CustomerRelationDTO getByCustomerId(String customerId) {
return baseDao.selectByCustomerId(customerId);
}
/**
* 获取某个客户的根客户id
*
* @param customerId
* @return void
* @author generator
* @date 2021-02-03
*/
@Override
public String getRootCustomerId(String customerId) {
CustomerRelationDTO customerRelationDTO=this.getByCustomerId(customerId);
if (null == customerRelationDTO) {
log.info(String.format("根据客户id:%s查找customer_relation为空",customerId));
return StrConstant.EPMETY_STR;
}
log.info(JSON.toJSONString(customerRelationDTO,true));
if (!NumConstant.ZERO_STR.equals(customerRelationDTO.getParentCustomerId())) {
log.info("parentCustomerId is not equals 0 so continue");
return getRootCustomerId(customerRelationDTO.getParentCustomerId());
}
return customerRelationDTO.getCustomerId();
}
}

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

@ -42,6 +42,7 @@ import com.epmet.dto.result.*;
import com.epmet.entity.CustomerEntity;
import com.epmet.feign.*;
import com.epmet.redis.CustomerRedis;
import com.epmet.service.CustomerRelationService;
import com.epmet.service.CustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -84,6 +85,8 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private CustomerRelationService customerRelationService;
@Override
public PageData<CustomerDTO> page(Map<String, Object> params) {
@ -738,4 +741,24 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
}
}
/**
* @param customerId
* @author yinzuomei
* @description 009根据客户id查询根客户信息 返参DTO
* @Date 2021/2/3 12:52
**/
@Override
public CustomerRelationInfoResultDTO queryCustomerInfoByCustomerId(String customerId) {
CustomerRelationInfoResultDTO resultDTO = new CustomerRelationInfoResultDTO();
resultDTO.setCustomerId(customerId);
resultDTO.setRootCustomerId(NumConstant.ZERO_STR);
CustomerRelationDTO customerRelationDTO=customerRelationService.getByCustomerId(customerId);
if (null != customerRelationDTO) {
//查询根客户id
resultDTO.setRootCustomerId(customerRelationService.getRootCustomerId(customerId));
}
return resultDTO;
}
}

2
epmet-module/oper-crm/oper-crm-server/src/main/resources/logback-spring.xml

@ -139,7 +139,7 @@
</appender>
<!-- 开发、测试环境 -->
<springProfile name="dev,test">
<springProfile name="dev,test,local">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/>

16
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.CustomerRelationDao">
<select id="selectByCustomerId" resultType="com.epmet.dto.CustomerRelationDTO" parameterType="java.lang.String">
SELECT
cr.*
FROM
customer_relation cr
WHERE
cr.DEL_FLAG = '0'
AND cr.CUSTOMER_ID =#{customerId}
</select>
</mapper>
Loading…
Cancel
Save