|
|
@@ -23,12 +23,18 @@ import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.CustomerLogMapper;
|
|
|
import com.goafanti.common.dao.CustomerMapper;
|
|
|
+import com.goafanti.common.dao.CustomerOrganizationInfoMapper;
|
|
|
+import com.goafanti.common.dao.CustomerUserInfoMapper;
|
|
|
+import com.goafanti.common.dao.FollowUpRecordMapper;
|
|
|
import com.goafanti.common.enums.CustomerFollowFiled;
|
|
|
import com.goafanti.common.enums.CustomerIntentionFiled;
|
|
|
import com.goafanti.common.enums.CustomerStatusFiled;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.Customer;
|
|
|
import com.goafanti.common.model.CustomerLog;
|
|
|
+import com.goafanti.common.model.CustomerOrganizationInfo;
|
|
|
+import com.goafanti.common.model.CustomerUserInfo;
|
|
|
+import com.goafanti.common.model.FollowUpRecord;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
@Service
|
|
|
public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implements CustomerService {
|
|
|
@@ -38,11 +44,22 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
|
|
|
private AdminMapper adminMapper;
|
|
|
@Autowired
|
|
|
private CustomerLogMapper customerLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private CustomerUserInfoMapper customerUserInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private CustomerOrganizationInfoMapper customerOrganizationInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private FollowUpRecordMapper followUpRecordMapper;
|
|
|
@Override
|
|
|
- public int addCustomer(Customer cus) {
|
|
|
- Date data =new Date();
|
|
|
+ public int addCustomer(Customer cus,CustomerUserInfo cui,CustomerOrganizationInfo coi,FollowUpRecord fur) {
|
|
|
+ //插入 customerUserInfo
|
|
|
+ customerUserInfoMapper.insert(cui);
|
|
|
+ //插入 customerOrganizationInfo
|
|
|
+ customerOrganizationInfoMapper.insert(coi);
|
|
|
+ //插入跟进表
|
|
|
+ followUpRecordMapper.insert(fur);
|
|
|
String paid = findLadderIds(TokenManager.getAdminId());//查询上级管理员ID集合
|
|
|
- cus.setCreateTime(data);
|
|
|
+ if(StringUtils.isNotBlank(paid)) paid = paid.substring(0, paid.length()-1);
|
|
|
cus.setAid(TokenManager.getAdminId());
|
|
|
cus.setPaid(paid);
|
|
|
int res = customerMapper.insert(cus);
|
|
|
@@ -72,7 +89,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
|
|
|
String newPaid = "";
|
|
|
for(Customer c:customers){
|
|
|
newPaid = findLadderIds(c.getAid());
|
|
|
- if(!newPaid.equals("")) newPaid = newPaid.substring(0, newPaid.length()-1);
|
|
|
+ if(StringUtils.isNotBlank(newPaid)) newPaid = newPaid.substring(0, newPaid.length()-1);
|
|
|
c.setPaid(newPaid);
|
|
|
customerMapper.updateByPrimaryKeySelective(c);
|
|
|
}
|
|
|
@@ -232,31 +249,34 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveCustomerLog(CustomerIn cus,String operatorType,String cid){
|
|
|
+ public void saveCustomerLog(CustomerIn cus,String operatorType){
|
|
|
/* 记录日志 */
|
|
|
+ String cid =cus.getId();
|
|
|
CustomerLog log = new CustomerLog();
|
|
|
log.setId(UUID.randomUUID().toString());
|
|
|
log.setCid(cid);
|
|
|
log.setOperatorTime(new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS).format(new Date()));
|
|
|
log.setOperatorName(TokenManager.getAdminToken().getName());
|
|
|
Customer c = customerMapper.selectByPrimaryKey(cid) ;
|
|
|
+ String beforeAdminName = adminMapper.selectByPrimaryKey(c.getAid()).getName();
|
|
|
if(operatorType.equals(AFTConstants.CUSTOMER_CREATE)){//创建用户
|
|
|
log.setAfterFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getFollowSituation())).getDesc()); //跟进状态
|
|
|
log.setAfterCustomerIntention(getCompanyIntention(cus.getCompanyIntention())); //跟进意向
|
|
|
log.setAfterCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getCustomerStatus())).getDesc()); //客户状态
|
|
|
log.setAfterAdminName(TokenManager.getAdminToken().getName());
|
|
|
log.setOperatorType(AFTConstants.CUSTOMER_CREATE);
|
|
|
- }else if(operatorType.equals(AFTConstants.CUSTOMER_MODIFY)){ //修改用户
|
|
|
- log.setBeforeAdminName(cus.getBeforeAdminName());//修改前操作人
|
|
|
+ }else if(operatorType.equals(AFTConstants.CUSTOMER_MODIFY)){ //修改客户
|
|
|
+ log.setBeforeAdminName(beforeAdminName);//修改前操作人
|
|
|
log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
|
|
|
log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
|
|
|
log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
|
|
|
+ log.setAfterAdminName(TokenManager.getAdminToken().getName());
|
|
|
log.setAfterFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getFollowSituation())).getDesc()); //修改后跟进状态
|
|
|
log.setAfterCustomerIntention(getCompanyIntention(cus.getCompanyIntention())); //修改后跟进意向
|
|
|
log.setAfterCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getCustomerStatus())).getDesc()); //修改后客户状态
|
|
|
log.setOperatorType(AFTConstants.CUSTOMER_MODIFY);
|
|
|
- }else if(operatorType.equals(AFTConstants.CUSTOMER_DELETE)){ //删除用户
|
|
|
- log.setBeforeAdminName(cus.getBeforeAdminName());
|
|
|
+ }else if(operatorType.equals(AFTConstants.CUSTOMER_DELETE)){ //删除客户
|
|
|
+ log.setBeforeAdminName(beforeAdminName); //删除前跟进人
|
|
|
log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //跟进意向
|
|
|
log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //跟进状态
|
|
|
log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//跟进进度
|
|
|
@@ -264,25 +284,25 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
|
|
|
}else if(operatorType.equals(AFTConstants.CUSTOMER_TRANSFER)){ //转交客户
|
|
|
log.setBeforeAdminName(cus.getBeforeAdminName());//转交前的人
|
|
|
log.setAfterAdminName(cus.getAdminName());//转交后的人
|
|
|
- log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //修改前跟进意向
|
|
|
- log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //修改前跟进状态
|
|
|
- log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//修改前跟进进度
|
|
|
+ log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
|
|
|
+ log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
|
|
|
+ log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
|
|
|
log.setOperatorType(AFTConstants.CUSTOMER_TRANSFER);
|
|
|
- }else if(operatorType.equals(AFTConstants.CUSTOMER_RECEIVE)){ //领取
|
|
|
- log.setBeforeAdminName(cus.getBeforeAdminName());//领取前的人
|
|
|
+ }else if(operatorType.equals(AFTConstants.CUSTOMER_RECEIVE)){ //领取客户
|
|
|
+ log.setBeforeAdminName(beforeAdminName);//领取前的人
|
|
|
log.setAfterAdminName(TokenManager.getAdminToken().getName());//领取后跟进人
|
|
|
- log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //领取前跟进意向
|
|
|
- log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //领取前跟进状态
|
|
|
- log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//领取前跟进进度
|
|
|
+ log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //领取前跟进意向
|
|
|
+ log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //领取前跟进状态
|
|
|
+ log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//领取前跟进进度
|
|
|
log.setOperatorType(AFTConstants.CUSTOMER_RECEIVE);
|
|
|
}else if(operatorType.equals(AFTConstants.CUSTOMER_TO_PUBLIC)){ //转为公共客户
|
|
|
- log.setBeforeAdminName(cus.getBeforeAdminName());//转为公共客户前跟进人
|
|
|
- log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //修改前跟进意向
|
|
|
- log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //修改前跟进状态
|
|
|
- log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//修改前跟进进度
|
|
|
+ log.setBeforeAdminName(beforeAdminName);//转为公共客户前跟进人
|
|
|
+ log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //转换前跟进意向
|
|
|
+ log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //转换前跟进状态
|
|
|
+ log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//转换前跟进进度
|
|
|
log.setOperatorType(AFTConstants.CUSTOMER_TO_PUBLIC);
|
|
|
}else if(operatorType.equals(AFTConstants.CUSTOMER_FOLLOW)){ //跟进客户
|
|
|
- log.setBeforeAdminName(TokenManager.getAdminToken().getName());//跟进前操作人
|
|
|
+ log.setBeforeAdminName(beforeAdminName);//跟进前操作人
|
|
|
log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
|
|
|
log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
|
|
|
log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
|
|
|
@@ -314,7 +334,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateCustomer(Customer c) {
|
|
|
+ //修改主表
|
|
|
return customerMapper.updateByPrimaryKeySelective(c);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|