|
|
@@ -15,9 +15,9 @@ import com.goafanti.customer.service.UserClueService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
@Service
|
|
|
public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements UserClueService {
|
|
|
@@ -94,8 +94,6 @@ 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);
|
|
|
@@ -133,25 +131,69 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String pushImportUserClue(List<OutUserClueExcel> list) {
|
|
|
+ public Map<String, Object> pushImportUserClue(List<OutUserClueExcel> list) {
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
int size=0;
|
|
|
- for (OutUserClueExcel outUserClueExcel : list) {
|
|
|
+ for (OutUserClueExcel e : list) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ checkMobile(e.getContactMobile());
|
|
|
+ checkContacts(e.getContacts());
|
|
|
+ //判定客户名称
|
|
|
+ checkUserName(e.getNickname());
|
|
|
+ }catch (BusinessException ex){
|
|
|
+ size++;
|
|
|
+ msg.append("<br/>客户[").append(e.getNickname()).append("]导入失败,原因:").append(ex.getMessage()).append(" ");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
InputUserClueBo inUserClueBo = new InputUserClueBo();
|
|
|
- inUserClueBo.setUserName(outUserClueExcel.getNickname());
|
|
|
- inUserClueBo.setContactMobile(outUserClueExcel.getContactMobile());
|
|
|
- inUserClueBo.setContacts(outUserClueExcel.getContacts());
|
|
|
+ inUserClueBo.setUserName(e.getNickname());
|
|
|
+ inUserClueBo.setContactMobile(e.getContactMobile());
|
|
|
+ inUserClueBo.setContacts(e.getContacts());
|
|
|
try {
|
|
|
add(inUserClueBo);
|
|
|
- }catch (Exception e){
|
|
|
+ }catch (Exception ex){
|
|
|
size++;
|
|
|
- msg.append("客户[").append(outUserClueExcel.getNickname()).append("]已存在系统中,导入失改。 ");
|
|
|
+ msg.append("<br/>客户[").append(e.getNickname()).append("]新增异常。 ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
+ map.put("errorCount",size);
|
|
|
+ if (size==0){
|
|
|
+ msg.append("客户导入成功.");
|
|
|
+ }
|
|
|
+ map.put("msg",msg);
|
|
|
+ System.out.println(msg);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkContacts(String contacts) throws BusinessException {
|
|
|
+ String nameReg="[\\u4e00-\\u9fa5]+.*";
|
|
|
+ Pattern pattern =Pattern.compile(nameReg);
|
|
|
+ Matcher matcher = pattern.matcher(contacts);
|
|
|
+ if (!matcher.matches()){
|
|
|
+ throw new BusinessException("联系人名称名称格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkMobile(String contactMobile) throws BusinessException{
|
|
|
+ String mobileReg="[1-9]\\d{10}";
|
|
|
+ String mobileReg2="^0\\d{2,3}-?\\d{7,8}$";
|
|
|
+ Pattern pattern =Pattern.compile(mobileReg);
|
|
|
+ Matcher matcher = pattern.matcher(contactMobile);
|
|
|
+ if (!matcher.matches()){
|
|
|
+ Pattern pattern2 =Pattern.compile(mobileReg2);
|
|
|
+ Matcher matcher2 = pattern2.matcher(contactMobile);
|
|
|
+ if (!matcher2.matches()){
|
|
|
+ throw new BusinessException("手机号格式不正确");
|
|
|
}
|
|
|
}
|
|
|
- if (size==0)msg.append("客户新增成功");
|
|
|
- return msg.toString();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Object updateTransfer(InputUserClueTransferBo in) {
|
|
|
String[] split = in.getUid().split(",");
|
|
|
@@ -222,14 +264,14 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void checkUserName(InputUserClueBo in) throws BusinessException{
|
|
|
- if (!userMapper.checkUser("", in.getUserName(), "", 1, null, null).isEmpty())
|
|
|
+ private void checkUserName(String name) throws BusinessException{
|
|
|
+ if (!userMapper.checkUser("", name, "", 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 (name.contains("(")){
|
|
|
+ name2=name.replace("(","(").replace(")",")");
|
|
|
+ }else if (name.contains("(")){
|
|
|
+ name2=name.replace("(","(").replace(")",")");
|
|
|
}
|
|
|
if (name2!=null){
|
|
|
if (!userMapper.checkUser("", name2, "", 1, null, null).isEmpty())
|