Browse Source

新增客户本地初始化(不通过小程序和公众号)

feature/evaluate
wxz 3 years ago
parent
commit
22847c8889
  1. 51
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java
  2. 14
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  3. 5
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  4. 69
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

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

@ -3,6 +3,7 @@ package com.epmet.dto.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -12,11 +13,55 @@ import java.io.Serializable;
@Data @Data
public class CustomerInitFormDTO implements Serializable { public class CustomerInitFormDTO implements Serializable {
public interface GetCustomerDetailGroup { /**
} * 初始化带小程序的客户
*/
public interface InitMiniAppCustomerGroup {}
/**
* 初始化本地客户
*/
public interface InitLocalCustomerGroup {}
@NotBlank(message = "客户Id不能为空", groups = {GetCustomerDetailGroup.class}) @NotBlank(message = "客户Id不能为空", groups = {InitMiniAppCustomerGroup.class})
private String customerId; private String customerId;
@NotNull(message = "缺少paCustomer信息", groups = InitLocalCustomerGroup.class)
private PaCustomer paCustomer;
@NotNull(message = "缺少paCustomerAgency信息", groups = InitLocalCustomerGroup.class)
private PaCustomerAgency paAgency;
@NotNull(message = "缺少paUser信息", groups = InitLocalCustomerGroup.class)
private PaUser paUser;
@Data
public static class PaCustomer {
private String customerName;
private String isInitialize;
private String source;
private String type;
}
@Data
public static class PaCustomerAgency {
private String id;
private String agencyName;
private String areaCode;
private String city;
private String customerId;
private String district;
private String level;
private String levelNum;
private Integer partybranchnum;
private String province;
}
@Data
public static class PaUser {
private String gender;
private String phone;
private String realName;
}
} }

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

@ -257,11 +257,23 @@ public class CustomerController {
**/ **/
@PostMapping("init") @PostMapping("init")
public Result init(@RequestBody CustomerInitFormDTO formDTO) { public Result init(@RequestBody CustomerInitFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.GetCustomerDetailGroup.class); ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.InitMiniAppCustomerGroup.class);
customerService.init(formDTO); customerService.init(formDTO);
return new Result(); return new Result();
} }
/**
* 本地初始化客户不经过小程序
* @param formDTO
* @return
*/
@PostMapping("initLocally")
public Result initLocally(@RequestBody CustomerInitFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.InitLocalCustomerGroup.class);
customerService.initLocal(formDTO);
return new Result();
}
/** /**
* desc:获取所有未删除的客户 * desc:获取所有未删除的客户
* @return * @return

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

@ -166,6 +166,11 @@ public interface CustomerService extends BaseService<CustomerEntity> {
**/ **/
void init(CustomerInitFormDTO formDTO); void init(CustomerInitFormDTO formDTO);
/**
* 本地初始化(不走小程序)
*/
void initLocal(CustomerInitFormDTO input);
/** /**
* desc获取所有客户列表 * desc获取所有客户列表
* @return * @return

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

@ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
@ -585,6 +586,74 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
} }
@Override
public void initLocal(CustomerInitFormDTO input) {
//1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息
//PaUserDTO paUser = ConvertUtils.mapToEntity(map3, PaUserDTO.class);
String customerId = IdWorker.getIdStr();
String agencyId = IdWorker.getIdStr();
//2.校验当前客户是否已初始化,不存在则初始客户信息
CustomerEntity entity = baseDao.selectById(customerId);
if (null != entity) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode());
}
CustomerInitFormDTO.PaCustomer paCustomer = input.getPaCustomer();
CustomerInitFormDTO.PaCustomerAgency paCustomerAgency = input.getPaAgency();
CustomerInitFormDTO.PaUser paUser = input.getPaUser();
paCustomerAgency.setId(agencyId);
//2-1.新增客户信息
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setId(customerId);
customerEntity.setCustomerName(paCustomer.getCustomerName());
customerEntity.setTitle("");
customerEntity.setOrganizationNumber("");
customerEntity.setOrganizationImg("");
customerEntity.setValidityTime(getValidityTime());
customerEntity.setOrganizationLevel(paCustomerAgency.getLevel());
customerEntity.setLogo("");
//新客户默认可以创建三个网格
customerEntity.setGridNumber(NumConstant.THREE);
if (baseDao.insert(customerEntity) < NumConstant.ONE) {
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode());
}
// *.发送初始化客户信息到mq,让监听者完成初始化操作
InitCustomerMQMsg msgContent = new InitCustomerMQMsg();
msgContent.setCustomerId(customerId);
msgContent.setAgency(constructAgencyInfo4CustomerInit(ConvertUtils.sourceToTarget(paCustomerAgency, PaCustomerAgencyDTO.class)));
msgContent.setStaff(constructStaffInfo4CustomerInit(agencyId, ConvertUtils.sourceToTarget(paUser, PaUserDTO.class)));
SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO();
systemMsgFormDTO.setMessageType(SystemMessageType.INIT_CUSTOMER);
systemMsgFormDTO.setContent(msgContent);
Result sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO);
if (! sendMsgResult.success()) {
throw new RenException("发送(初始化客户信息)系统消息到message服务失败:{}", sendMsgResult.getInternalMsg());
}
//2021.1.25 sun 新增初始化客户积分规则和评价指标权重 start
//8.客户初始化已有的积分规则
Result<InitPointRuleResultDTO> resultPoint = epmetPointOpenFeignClient.initPointRule(customerId);
if (!resultPoint.success()) {
throw new RenException(resultPoint.getCode(), resultPoint.getInternalMsg());
}
//9.新客户初始化评价指标 权重
InitCustomerIndexForm indexForm = new InitCustomerIndexForm();
indexForm.setCustomerId(customerId);
Result<Boolean> resultData = dataStatisticalOpenFeignClient.initCustomerIndex(indexForm);
if (!resultData.success()) {
throw new RenException(resultData.getCode(), resultData.getInternalMsg());
}
//2021.1.25 end
}
private InitCustomerMQMsg.InitCustomerStaff constructStaffInfo4CustomerInit(String agencyId, PaUserDTO paUser) { private InitCustomerMQMsg.InitCustomerStaff constructStaffInfo4CustomerInit(String agencyId, PaUserDTO paUser) {
InitCustomerMQMsg.InitCustomerStaff staff = new InitCustomerMQMsg.InitCustomerStaff(); InitCustomerMQMsg.InitCustomerStaff staff = new InitCustomerMQMsg.InitCustomerStaff();
staff.setAgencyId(agencyId); staff.setAgencyId(agencyId);

Loading…
Cancel
Save