|
|
@@ -4,12 +4,16 @@ import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.*;
|
|
|
import com.goafanti.common.enums.IdentityProcess;
|
|
|
import com.goafanti.common.enums.UserLevel;
|
|
|
+import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.*;
|
|
|
import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
-import com.goafanti.customer.bo.*;
|
|
|
+import com.goafanti.customer.bo.InputUserClueBo;
|
|
|
+import com.goafanti.customer.bo.InputUserClueList;
|
|
|
+import com.goafanti.customer.bo.OutUserClueExcel;
|
|
|
+import com.goafanti.customer.bo.OutUserClueList;
|
|
|
import com.goafanti.customer.service.CustomerService;
|
|
|
import com.goafanti.customer.service.UserClueService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -52,7 +56,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object add(InputUserClueBo in) {
|
|
|
+ public Object add(InputUserClueBo in) throws BusinessException{
|
|
|
User user = new User();
|
|
|
Date now = new Date();
|
|
|
String aid= TokenManager.getAdminId();
|
|
|
@@ -86,25 +90,24 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
user.setClueTime(now);
|
|
|
passwordUtil.encryptPassword(user);
|
|
|
String aname = adminMapper.queryById(TokenManager.getAdminId()).getName();
|
|
|
-
|
|
|
- //判定客户名称
|
|
|
- checkUserName(in);
|
|
|
- UserMid um=new UserMid();
|
|
|
- um.setAid(user.getAid());
|
|
|
- um.setUid(uid);
|
|
|
- userMidMapper.insertSelective(um);
|
|
|
- // 创建企业认证信息
|
|
|
- OrganizationIdentity oi = new OrganizationIdentity();
|
|
|
- oi.setUnitName(in.getUserName());
|
|
|
- oi.setId(identifyId);
|
|
|
- oi.setUid(uid);
|
|
|
- oi.setContacts(in.getContacts());
|
|
|
- oi.setContactMobile(in.getContactMobile());
|
|
|
- oi.setHighTechZone(AFTConstants.NO);
|
|
|
- oi.setInternational(AFTConstants.NO);
|
|
|
- oi.setListed(AFTConstants.NO);
|
|
|
- oi.setAuditStatus(IdentityProcess.SUCCESS.getCode()); // 实名企业
|
|
|
- organizationIdentityMapper.insert(oi);
|
|
|
+ //判定客户名称
|
|
|
+ checkUserName(in);
|
|
|
+ UserMid um=new UserMid();
|
|
|
+ um.setAid(user.getAid());
|
|
|
+ um.setUid(uid);
|
|
|
+ userMidMapper.insertSelective(um);
|
|
|
+ // 创建企业认证信息
|
|
|
+ OrganizationIdentity oi = new OrganizationIdentity();
|
|
|
+ oi.setUnitName(in.getUserName());
|
|
|
+ oi.setId(identifyId);
|
|
|
+ oi.setUid(uid);
|
|
|
+ oi.setContacts(in.getContacts());
|
|
|
+ oi.setContactMobile(in.getContactMobile());
|
|
|
+ oi.setHighTechZone(AFTConstants.NO);
|
|
|
+ oi.setInternational(AFTConstants.NO);
|
|
|
+ oi.setListed(AFTConstants.NO);
|
|
|
+ oi.setAuditStatus(IdentityProcess.SUCCESS.getCode()); // 实名企业
|
|
|
+ organizationIdentityMapper.insert(oi);
|
|
|
userMapper.insertSelective(user);
|
|
|
UserNames un=new UserNames();
|
|
|
un.setUid(uid);
|
|
|
@@ -128,8 +131,9 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object importUserClue(List<OutUserClueExcel> list) {
|
|
|
+ public String pushImportUserClue(List<OutUserClueExcel> list) {
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
+ int size=0;
|
|
|
for (OutUserClueExcel outUserClueExcel : list) {
|
|
|
InputUserClueBo inUserClueBo = new InputUserClueBo();
|
|
|
inUserClueBo.setUserName(outUserClueExcel.getNickname());
|
|
|
@@ -138,10 +142,11 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
try {
|
|
|
add(inUserClueBo);
|
|
|
}catch (Exception e){
|
|
|
- msg.append("客户").append(outUserClueExcel.getNickname()).append("新增失败");
|
|
|
+ size++;
|
|
|
+ msg.append("客户[").append(outUserClueExcel.getNickname()).append("]新增失败,").append(e.getMessage()).append("。 ");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+ if (size==0)msg.append("客户新增成功");
|
|
|
return msg.toString();
|
|
|
}
|
|
|
|
|
|
@@ -154,10 +159,18 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
userTransferLogMapper.insertSelective(u);
|
|
|
}
|
|
|
|
|
|
- private void checkUserName(InputUserClueBo in) {
|
|
|
- InputAddCustomer in1=new InputAddCustomer();
|
|
|
- in1.setName(in.getUserName());
|
|
|
- in1.setType(1);
|
|
|
- customerService.checkUserName(in1);
|
|
|
+ private void checkUserName(InputUserClueBo in) throws BusinessException{
|
|
|
+ if (!userMapper.checkUser("", in.getUserName(), "", 1, null, null).isEmpty())
|
|
|
+ throw new BusinessException("客户已经存在");
|
|
|
+ String name2=null;
|
|
|
+ if (in.getUserName().contains("(")){
|
|
|
+ name2=in.getUserName().replace("(","(").replace(")",")");
|
|
|
+ }else if (in.getUserName().contains("(")){
|
|
|
+ name2=in.getUserName().replace("(","(").replace(")",")");
|
|
|
+ }
|
|
|
+ if (name2!=null){
|
|
|
+ if (!userMapper.checkUser("", name2, "", 1, null, null).isEmpty())
|
|
|
+ throw new BusinessException("客户已经存在");
|
|
|
+ }
|
|
|
}
|
|
|
}
|