yfh 13 horas atrás
pai
commit
cca6dfa155

+ 4 - 4
fs-company/src/main/java/com/fs/crm/controller/CrmCustomerController.java

@@ -20,6 +20,7 @@ import com.fs.core.web.service.TokenService;
 import com.fs.crm.domain.CrmCustomer;
 import com.fs.crm.param.*;
 import com.fs.crm.service.ICrmCustomerAssistService;
+import com.fs.crm.service.ICrmCustomerContactsService;
 import com.fs.crm.service.ICrmCustomerService;
 import com.fs.crm.service.ICrmCustomerUserService;
 import com.fs.crm.service.impl.CrmCustomerAssistServiceImpl;
@@ -56,8 +57,7 @@ public class CrmCustomerController extends BaseController
     @Autowired
     ICrmCustomerUserService crmCustomerUserService;
     @Autowired
-    private ICrmCustomerAssistService crmCustomerAssistService;
-
+    private ICrmCustomerContactsService crmContactsService;
     @ApiOperation("获取线索客户")
     @PreAuthorize("@ss.hasPermi('crm:customer:lineList')")
     @GetMapping("/getLineCustomerList")
@@ -250,7 +250,7 @@ public class CrmCustomerController extends BaseController
         }
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
-        return crmCustomerAssistService.assistToUser(loginUser.getUsername(),loginUser.getUser().getUserId(),param);
+        return crmCustomerService.assistToUser(loginUser.getUsername(),loginUser.getUser().getUserId(),param);
     }
 
 
@@ -470,7 +470,7 @@ public class CrmCustomerController extends BaseController
         if(customer==null){
             CrmCustomerContacts contactsMap=new CrmCustomerContacts();
             contactsMap.setMobile(mobile);
-            List<CrmCustomerContacts>  contactsList=crmCustomerAssistService.selectCrmCustomerContactsList(contactsMap);
+            List<CrmCustomerContacts>  contactsList=crmContactsService.selectCrmCustomerContactsList(contactsMap);
             if(contactsList.size()>0){
                 CrmCustomerContacts contacts=contactsList.get(0);
                 customerId=contacts.getCustomerId();

+ 1 - 0
fs-service-system/src/main/java/com/fs/crm/service/ICrmCustomerService.java

@@ -42,6 +42,7 @@ public interface ICrmCustomerService
      */
     public List<CrmCustomer> selectCrmCustomerList(CrmCustomer crmCustomer);
 
+    R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param);
     /**
      * 新增客户
      *

+ 52 - 0
fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java

@@ -931,4 +931,56 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
     public CrmCustomer selectFscrmByMobile(String mobile){
         return crmCustomerMapper.selectFscrmByMobile(mobile);
     }
+
+    @Override
+    @Transactional
+    public R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param) {
+        Integer index=0;
+        for(CrmCustomerAssignUserDTO userDTO:param.getUsers()){
+            CompanyUser companyUser=companyUserMapper.selectCompanyUserById(userDTO.getCompanyUserId());
+            for(int i=0;i<userDTO.getCount();i++){
+                CrmCustomer customer=crmCustomerMapper.selectCrmCustomerById(param.getCustomerIds().get(index));
+                //不能选择客户拥有者本人
+                CrmCustomerUser crmCustomerUser = crmCustomerUserMapper.selectCrmCustomerUserById(customer.getCustomerUserId());
+                if (Objects.equals(crmCustomerUser.getCompanyUserId(), userDTO.getCompanyUserId())){
+                    return R.error("不能选择自己来协作!");
+                }
+                //查询协作客户
+                CrmCustomerAssist customerAssist=new CrmCustomerAssist();
+                customerAssist.setCustomerId(customer.getCustomerId());
+                customerAssist.setCompanyUserId(userDTO.getCompanyUserId());
+                List<CrmCustomerAssist> tempList = assistMapper.selectCrmCustomerAssistList(customerAssist);
+                if(tempList!=null && !tempList.isEmpty()){
+                    return R.error("销售:" + companyUser.getNickName() +"(" + userDTO.getCompanyUserId() + ")已拥有改该协作客户:" + customer.getCustomerName());
+                }
+                customerAssist.setCompanyId(param.getCompanyId());
+                customerAssist.setCompanyUserName(companyUser.getNickName());
+                customerAssist.setCreateTime(new Date());
+                assistMapper.insertCrmCustomerAssist(customerAssist);
+                //写日志
+                CrmCustomerLogs logs=new CrmCustomerLogs();
+                logs.setCustomerId(customer.getCustomerId());
+                logs.setCreateTime(new Date());
+                logs.setLogsType(CustomerLogEnum.ASSIST_USER.getValue());
+                logs.setTitle(CustomerLogEnum.ASSIST_USER.getDesc());
+                logs.setRemark(opeUserName+"为客户"+customer.getCustomerName()+"添加协作人:" + companyUser.getNickName());
+                logs.setCompanyUserId(userDTO.getCompanyUserId());
+                logsMapper.insertCrmCustomerLogs(logs);
+
+                if(StringUtils.isNotEmpty(companyUser.getJpushId())){
+                    Map<String, String> extrasMap=new HashMap<>();
+                    extrasMap.put("customerId",customer.getCustomerId().toString());
+                    extrasMap.put("type","1");
+                    try {
+                        jpushService.sendRegisterIdPush("客户消息","您收到 一个客户协作邀请",extrasMap,companyUser.getJpushId());
+                    } catch (APIConnectionException e) {
+                    } catch (APIRequestException e) {
+                    }
+                }
+                index++;
+            }
+        }
+        return R.ok();
+    }
+
 }