Преглед на файлове

1、绑定好友强关系

yys преди 2 седмици
родител
ревизия
fa1dfe4c5f

+ 21 - 0
fs-service/src/main/java/com/fs/company/param/FsUserBindSalesParam.java

@@ -0,0 +1,21 @@
+package com.fs.company.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 会员绑定销售并添加IM好友参数
+ */
+@Data
+public class FsUserBindSalesParam implements Serializable {
+
+    /** 会员ID */
+    @NotNull(message = "userId不能为空")
+    private Long userId;
+
+    /** 销售ID */
+    @NotNull(message = "companyUserId不能为空")
+    private Long companyUserId;
+}

+ 8 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java

@@ -265,5 +265,13 @@ public interface ICompanyUserService {
      */
     List<com.fs.hisStore.domain.FsUserScrm> selectBoundFsUsersByCompanyUserId(Long companyUserId);
 
+    /**
+     * 绑定会员与销售关系,并添加IM好友
+     *
+     * @param userId        会员ID
+     * @param companyUserId 销售ID
+     */
+    void bindFsUserAndImportFriend(Long userId, Long companyUserId);
+
     int unBind(String userId);
 }

+ 45 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -14,10 +14,13 @@ import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.exception.file.OssException;
+import com.fs.common.enums.ImTypeEnum;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.PatternUtils;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.im.config.ImTypeConfig;
+import com.fs.im.service.OpenIMService;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.*;
 import com.fs.company.param.CompanyUserAreaParam;
@@ -107,6 +110,12 @@ public class CompanyUserServiceImpl implements ICompanyUserService
     @Autowired
     private FsUserMapper fsUserMapper;
 
+    @Autowired
+    private CompanyCompanyFsuserMapper companyCompanyFsuserMapper;
+
+    @Autowired
+    private OpenIMService openIMService;
+
     @Autowired
     private IFsUserCompanyUserService userCompanyUserService;
 
@@ -1097,6 +1106,42 @@ public class CompanyUserServiceImpl implements ICompanyUserService
         return companyUserMapper.selectBoundFsUsersByCompanyUserId(companyUserId);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void bindFsUserAndImportFriend(Long userId, Long companyUserId) {
+        com.fs.his.domain.FsUser fsUser = fsUserMapper.selectFsUserByUserId(userId);
+        if (fsUser == null || (fsUser.getIsDel() != null && fsUser.getIsDel() == 1)) {
+            throw new CustomException("会员不存在");
+        }
+
+        CompanyUser companyUser = selectCompanyUserById(companyUserId);
+        if (companyUser == null || "1".equals(companyUser.getDelFlag())) {
+            throw new CustomException("销售不存在");
+        }
+        if (!"0".equals(companyUser.getStatus())) {
+            throw new CustomException("销售已禁用");
+        }
+
+        batchUpdateBindCompanyUserId(Collections.singletonList(userId), companyUserId);
+
+        CompanyCompanyFsuser existBind = companyCompanyFsuserMapper.getInfoByUserId(String.valueOf(userId));
+        if (existBind == null) {
+            CompanyCompanyFsuser bind = new CompanyCompanyFsuser();
+            bind.setUserId(userId);
+            bind.setCompanyId(companyUser.getCompanyId());
+            bind.setCompanyUserId(companyUserId);
+            bind.setStatus(1);
+            bind.setBindType(0);
+            bind.setCreateTime(DateUtils.getNowDate());
+            companyCompanyFsuserMapper.insertCompanyCompanyUser(bind);
+        } else if (!companyUserId.equals(existBind.getCompanyUserId())) {
+            existBind.setCompanyUserId(companyUserId);
+            existBind.setCompanyId(companyUser.getCompanyId());
+            existBind.setUpdateTime(DateUtils.getNowDate());
+            companyCompanyFsuserMapper.updateCompanyCompanyUser(existBind);
+        }
+    }
+
     @Override
     public int unBind(String userId) {
         return companyUserMapper.unBind(userId);

+ 15 - 2
fs-user-app/src/main/java/com/fs/app/controller/AppLoginController.java

@@ -21,6 +21,8 @@ import com.fs.his.domain.FsUserNewTask;
 import com.fs.his.mapper.FsUserMapper;
 import com.fs.his.service.IFsUserNewTaskService;
 import com.fs.his.service.IFsUserService;
+import com.fs.company.param.FsUserBindSalesParam;
+import com.fs.company.service.ICompanyUserService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsUserRegisterParam;
 import com.fs.im.service.OpenIMService;
@@ -71,6 +73,9 @@ public class AppLoginController extends AppBaseController{
     @Autowired
     private OpenIMService openIMService;
 
+    @Autowired
+    private ICompanyUserService companyUserService;
+
     @ApiOperation("注册app用户")
     @PostMapping("/register")
     @RepeatSubmit
@@ -978,11 +983,19 @@ public class AppLoginController extends AppBaseController{
     }
 
     /**
-     * 获取好友申请列表
+     * 绑定会员销售关系
      *
-     * @param userRequestParam
+     * @param param
      * @return
      */
+    @Login
+    @ApiOperation("绑定会员销售关系")
+    @PostMapping("/bindFsUser")
+    public R bindFsUserAndImportFriend(@Validated @RequestBody FsUserBindSalesParam param) {
+        companyUserService.bindFsUserAndImportFriend(param.getUserId(), param.getCompanyUserId());
+        return R.ok("绑定成功");
+    }
+
     @PostMapping("/getFriendList")
     public R getFriendList(@RequestBody UserRequestParam userRequestParam)
     {