|
|
|
@ -14,18 +14,18 @@ import com.daqing.framework.domain.crms.CustomerEntity; |
|
|
|
|
import com.daqing.framework.domain.crms.PersonalCustomerEntity; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CrmsConstant; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerTO; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerVOCompany; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerVOPersonal; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerCompanyVO; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerPersonalVO; |
|
|
|
|
import com.daqing.framework.domain.crms.request.CustomerRequest; |
|
|
|
|
import com.daqing.framework.domain.hrms.EmployeeEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.ext.EmployeeTO; |
|
|
|
|
import com.daqing.framework.model.response.ResponseResult; |
|
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
|
import com.daqing.framework.utils.SnowflakeIdUtils; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
@ -107,13 +107,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) { |
|
|
|
|
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id); |
|
|
|
|
//封装个人类型客户信息
|
|
|
|
|
CustomerVOPersonal customerVOPersonal = this.setPersonal(customer, name, personalCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerVOPersonal>().SUCCESS(customerVOPersonal); |
|
|
|
|
CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO); |
|
|
|
|
} else { |
|
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id); |
|
|
|
|
//封装企业类型客户信息
|
|
|
|
|
CustomerVOCompany customerVOCompany = this.setCompany(customer, name, companyCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerVOCompany>().SUCCESS(customerVOCompany); |
|
|
|
|
CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -136,6 +136,57 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 插入个人类型客户信息 |
|
|
|
|
* @param customerEntity 客户基本信息 |
|
|
|
|
* @param personalCustomerEntity 个人类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Transactional |
|
|
|
|
@Override |
|
|
|
|
public boolean saveCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) { |
|
|
|
|
customerEntity.setId(SnowflakeIdUtils.getRandomid()); |
|
|
|
|
//TODO 设置客户编号
|
|
|
|
|
customerEntity.setCode(((int)(Math.random()*100+1))+""); |
|
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
|
personalCustomerEntity.setId(SnowflakeIdUtils.getRandomid()); |
|
|
|
|
personalCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
|
return customerDao.saveCustomer(customerEntity) && personalCustomerDao.savePersonalCustomer(personalCustomerEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 插入企业类型客户信息 |
|
|
|
|
* @param customerEntity 客户基本信息 |
|
|
|
|
* @param companyCustomerEntity 企业类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Transactional |
|
|
|
|
@Override |
|
|
|
|
public boolean saveCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity) { |
|
|
|
|
customerEntity.setId(SnowflakeIdUtils.getRandomid()); |
|
|
|
|
//TODO 设置客户编号
|
|
|
|
|
customerEntity.setCode(((int)(Math.random()*100+1))+""); |
|
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
|
companyCustomerEntity.setId(SnowflakeIdUtils.getRandomid()); |
|
|
|
|
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
|
return customerDao.saveCustomer(customerEntity) && companyCustomerDao.saveCompanyCustomer(companyCustomerEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新个人类型客户信息 |
|
|
|
|
* @param customerEntity 客户基本信息 |
|
|
|
|
* @param personalCustomerEntity 企业类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public boolean updateCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) { |
|
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
|
personalCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
|
return customerDao.updateCustomer(customerEntity) && personalCustomerDao.updatePersonalCustomer(personalCustomerEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 选择某段时间内客户信息的时间参数校验 |
|
|
|
|
* |
|
|
|
@ -243,31 +294,31 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
* @param personal 个人类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private CustomerVOPersonal setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { |
|
|
|
|
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { |
|
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
|
CustomerVOPersonal customerVOPersonal = new CustomerVOPersonal(); |
|
|
|
|
customerVOPersonal.setCode(customer.getCode()); |
|
|
|
|
customerVOPersonal.setType(customer.getType()); |
|
|
|
|
customerVOPersonal.setManager(name); |
|
|
|
|
customerVOPersonal.setName(customer.getName()); |
|
|
|
|
customerVOPersonal.setAddress(customer.getAddr()); |
|
|
|
|
customerVOPersonal.setPhone(customer.getPhone()); |
|
|
|
|
customerVOPersonal.setIdCard(personal.getIdCard()); |
|
|
|
|
customerVOPersonal.setAge(personal.getAge()); |
|
|
|
|
customerVOPersonal.setGender(personal.getGender()); |
|
|
|
|
customerVOPersonal.setMaritalStatus(personal.getMaritalStatus()); |
|
|
|
|
customerVOPersonal.setEducation(personal.getEducation()); |
|
|
|
|
customerVOPersonal.setEmployer(personal.getEmployer()); |
|
|
|
|
customerVOPersonal.setPosition(personal.getPosition()); |
|
|
|
|
customerVOPersonal.setWorkingYears(personal.getWorkingYears()); |
|
|
|
|
customerVOPersonal.setSocialSecurityNum(personal.getSocialSecurityNum()); |
|
|
|
|
customerVOPersonal.setLivingSituation(personal.getLivingSituation()); |
|
|
|
|
customerVOPersonal.setResidenceAddr(personal.getResidenceAddr()); |
|
|
|
|
customerVOPersonal.setBusinessSource(personal.getBusinessSource()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkman(personal.getEmergencyLinkman()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone()); |
|
|
|
|
return customerVOPersonal; |
|
|
|
|
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO(); |
|
|
|
|
customerPersonalVO.setCode(customer.getCode()); |
|
|
|
|
customerPersonalVO.setType(customer.getType()); |
|
|
|
|
customerPersonalVO.setManager(name); |
|
|
|
|
customerPersonalVO.setName(customer.getName()); |
|
|
|
|
customerPersonalVO.setAddress(customer.getAddr()); |
|
|
|
|
customerPersonalVO.setPhone(customer.getPhone()); |
|
|
|
|
customerPersonalVO.setIdCard(personal.getIdCard()); |
|
|
|
|
customerPersonalVO.setAge(personal.getAge()); |
|
|
|
|
customerPersonalVO.setGender(personal.getGender()); |
|
|
|
|
customerPersonalVO.setMaritalStatus(personal.getMaritalStatus()); |
|
|
|
|
customerPersonalVO.setEducation(personal.getEducation()); |
|
|
|
|
customerPersonalVO.setEmployer(personal.getEmployer()); |
|
|
|
|
customerPersonalVO.setPosition(personal.getPosition()); |
|
|
|
|
customerPersonalVO.setWorkingYears(personal.getWorkingYears()); |
|
|
|
|
customerPersonalVO.setSocialSecurityNum(personal.getSocialSecurityNum()); |
|
|
|
|
customerPersonalVO.setLivingSituation(personal.getLivingSituation()); |
|
|
|
|
customerPersonalVO.setResidenceAddr(personal.getResidenceAddr()); |
|
|
|
|
customerPersonalVO.setBusinessSource(personal.getBusinessSource()); |
|
|
|
|
customerPersonalVO.setEmergencyLinkman(personal.getEmergencyLinkman()); |
|
|
|
|
customerPersonalVO.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship()); |
|
|
|
|
customerPersonalVO.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone()); |
|
|
|
|
return customerPersonalVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -278,23 +329,23 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
* @param company 企业类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private CustomerVOCompany setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { |
|
|
|
|
CustomerVOCompany customerVOCompany = new CustomerVOCompany(); |
|
|
|
|
customerVOCompany.setCode(customer.getCode()); |
|
|
|
|
customerVOCompany.setType(customer.getType()); |
|
|
|
|
customerVOCompany.setManager(name); |
|
|
|
|
customerVOCompany.setName(customer.getName()); |
|
|
|
|
customerVOCompany.setAddress(customer.getAddr()); |
|
|
|
|
customerVOCompany.setPhone(customer.getPhone()); |
|
|
|
|
customerVOCompany.setRegisteredCapital(company.getRegisteredCapital()); |
|
|
|
|
customerVOCompany.setIndustry(company.getIndustry()); |
|
|
|
|
customerVOCompany.setYears(company.getYears()); |
|
|
|
|
customerVOCompany.setRegion(company.getRegion()); |
|
|
|
|
customerVOCompany.setShareholder(company.getShareholder()); |
|
|
|
|
customerVOCompany.setAffiliatedCompany(company.getAffiliatedCompany()); |
|
|
|
|
customerVOCompany.setEmployeeNumber(company.getEmpNum()); |
|
|
|
|
customerVOCompany.setLinkman(company.getLinkman()); |
|
|
|
|
customerVOCompany.setBusinessSource(company.getBusinessSource()); |
|
|
|
|
return customerVOCompany; |
|
|
|
|
private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { |
|
|
|
|
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO(); |
|
|
|
|
customerCompanyVO.setCode(customer.getCode()); |
|
|
|
|
customerCompanyVO.setType(customer.getType()); |
|
|
|
|
customerCompanyVO.setManager(name); |
|
|
|
|
customerCompanyVO.setName(customer.getName()); |
|
|
|
|
customerCompanyVO.setAddress(customer.getAddr()); |
|
|
|
|
customerCompanyVO.setPhone(customer.getPhone()); |
|
|
|
|
customerCompanyVO.setRegisteredCapital(company.getRegisteredCapital()); |
|
|
|
|
customerCompanyVO.setIndustry(company.getIndustry()); |
|
|
|
|
customerCompanyVO.setYears(company.getYears()); |
|
|
|
|
customerCompanyVO.setRegion(company.getRegion()); |
|
|
|
|
customerCompanyVO.setShareholder(company.getShareholder()); |
|
|
|
|
customerCompanyVO.setAffiliatedCompany(company.getAffiliatedCompany()); |
|
|
|
|
customerCompanyVO.setEmployeeNumber(company.getEmpNum()); |
|
|
|
|
customerCompanyVO.setLinkman(company.getLinkman()); |
|
|
|
|
customerCompanyVO.setBusinessSource(company.getBusinessSource()); |
|
|
|
|
return customerCompanyVO; |
|
|
|
|
} |
|
|
|
|
} |