|
|
@ -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()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|