Browse Source

新增线索客户导入

anderx 1 year ago
parent
commit
8b49985ad5

+ 5 - 0
src/main/java/com/goafanti/customer/controller/UserClueApiController.java

@@ -75,11 +75,16 @@ public class UserClueApiController extends BaseApiController{
 
 	/**
 	 * 线索客户转移
+	 * @param in type 0=转交, 1退回线索客户,2=移除线索客户,3=领取线索客户
 	 * @return
 	 */
 	@PostMapping("/transfer")
 	public Result transfer( InputUserClueTransferBo in) {
 		Result res = new Result();
+		if (in.getType()==0&&in.getTransferId()==null){
+			res.getError().add(buildError("转移编号不能为空"));
+			return res;
+		}
 		return res.data(userClueService.updateTransfer(in));
 	}
 

+ 13 - 6
src/main/java/com/goafanti/customer/service/impl/UserClueServiceImpl.java

@@ -127,9 +127,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         cob.setMobile(in.getContactMobile());
         cob.setMajor(AFTConstants.YES);
         organizationContactBookMapper.insert(cob);
-        addUserTransferLog(user,22);
-
-
+        addUserTransferLog(user,22,null);
         return 1;
     }
 
@@ -146,7 +144,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
                 add(inUserClueBo);
             }catch (Exception e){
                 size++;
-                msg.append("客户[").append(outUserClueExcel.getNickname()).append("]新增失败,").append(e.getMessage()).append("。 ");
+                msg.append("客户[").append(outUserClueExcel.getNickname()).append("]已存在系统中,导入失改。 ");
             }
         }
         if (size==0)msg.append("客户新增成功");
@@ -164,6 +162,10 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
 
     private void userTransfer(String uid,InputUserClueTransferBo in) {
         User user = userMapper.queryById(uid);
+        if (!user.getAid().equals(TokenManager.getAdminId())){
+            throw new BusinessException("只能操作所属客户");
+        }
+        String aid=in.getTransferId();
         int type = 0;
         if (in.getType()==0){
             user.setAid(in.getTransferId());
@@ -173,6 +175,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
             user.setClueProcess(2);
             user.setAid(user.getClueAid());
             type=24;
+            aid=user.getClueAid();
         }else if (in.getType()==2){
             user.setClueProcess(3);
             userMapper.update(user);
@@ -183,7 +186,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
             type=26;
         }
         userMapper.update(user);
-        addUserTransferLog(user,type);
+        addUserTransferLog(user,type,aid);
     }
 
     /**
@@ -191,14 +194,18 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
      * @param user 客户信息
      * @param type  22=导入线索客户,23=转交线索客户,24=退回线索客户,25=移除线索客户,26=领取线索客户
      */
-    private void addUserTransferLog(User user,Integer type) {
+    private void addUserTransferLog(User user,Integer type,String transferId) {
         UserTransferLog u = new UserTransferLog();
         u.setUid(user.getId());
         u.setAid(TokenManager.getAdminId());
+        if (type==23||type==24){
+            u.setTakeAid(transferId);
+        }
         u.setType(type);
         userTransferLogMapper.insertSelective(u);
     }
 
+
     private void checkUserName(InputUserClueBo in) throws BusinessException{
         if (!userMapper.checkUser("", in.getUserName(), "", 1, null, null).isEmpty())
             throw new BusinessException("客户已经存在");