Kaynağa Gözat

1.客户回拨需要平台进行提醒和记录;

yfh 1 gün önce
ebeveyn
işleme
f13f5eaecc

+ 110 - 4
fs-company-app/src/main/java/com/fs/app/controller/VoiceApiController.java

@@ -15,11 +15,12 @@ import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
-import com.fs.company.domain.CompanyUser;
-import com.fs.company.domain.CompanyVoiceApi;
-import com.fs.company.domain.CompanyVoiceLogs;
-import com.fs.company.domain.CompanyVoiceMobile;
+import com.fs.company.domain.*;
 import com.fs.company.service.*;
+import com.fs.crm.domain.CrmCustomer;
+import com.fs.crm.domain.CrmCustomerContacts;
+import com.fs.crm.service.ICrmCustomerContactsService;
+import com.fs.crm.service.ICrmCustomerService;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
 import com.fs.voice.service.IVoiceService;
@@ -72,6 +73,28 @@ public class VoiceApiController extends AppBaseController {
     private ICompanyVoiceService companyVoiceService;
     @Autowired
     private ICompanyVoiceMobileService companyVoiceMobileService;
+
+    @Autowired
+    private ICompanyVoiceCallerService callerService;
+
+    @Autowired
+    private ICompanyService companyService;
+
+    @Autowired
+    private ICompanyUserService userService;
+
+    @Autowired
+    private ICrmCustomerService crmService;
+
+    @Autowired
+    private ICrmCustomerContactsService crmContactsService;
+
+    @Autowired
+    private ICompanyVoiceBlacklistService blacklistService;
+
+    @Autowired
+    ICompanyVoiceLogsService logsService;
+
     @Autowired
     JwtUtils jwtUtils;
     @Login
@@ -154,6 +177,31 @@ public class VoiceApiController extends AppBaseController {
                 logs.setStatus(-1);
                 companyVoiceLogsService.updateCompanyVoiceLogs(logs);
             }
+        }else{
+            JSONObject callObj=JSON.parseObject(json);
+            JSONObject notifyObj=callObj.getJSONObject("notify");
+            String type=notifyObj.getString("type");
+            String session=notifyObj.getString("session");
+            String callee=notifyObj.getString("agent");//被叫/坐席号
+            String caller=notifyObj.getString("number");//主叫
+            if(type.contentEquals("callin")){   //回拨接听
+                CompanyVoiceCaller callerEE=callerService.selectCompanyVoiceCallerByCallerNo(callee);
+                CrmCustomer customer=crmService.selectFscrmByMobile(caller);
+                Long customerId=0L;
+                if(customer!=null){
+                    customerId=customer.getCustomerId();
+                }
+                else{
+                    CrmCustomerContacts contactsMap=new CrmCustomerContacts();
+                    contactsMap.setMobile(caller);
+                    List<CrmCustomerContacts>  contactsList=crmContactsService.selectCrmCustomerContactsList(contactsMap);
+                    if(contactsList.size()>0){
+                        CrmCustomerContacts contacts=contactsList.get(0);
+                        customerId=contacts.getCustomerId();
+                    }
+                }
+                callInAction(callerEE.getCompanyId(),customerId,callerEE.getCompanyUserId(),session,caller,callerEE);
+            }
         }
         CallResult result=new CallResult();
         result.setMsg("");
@@ -161,6 +209,64 @@ public class VoiceApiController extends AppBaseController {
         return result;
     }
 
+    private  R callInAction(Long companyId, Long customerId, Long userId,String session,String caller,CompanyVoiceCaller callerEE){
+        //查询主叫号是不是坐席 查询主叫号是否已过期
+        Company company=companyService.selectCompanyById(companyId);
+        if(company.getStatus()==0){
+            return R.error("公司已停用");
+        }
+        if(company.getVoiceApiId()==null){
+            return R.error("未配置外呼接口");
+        }
+        CompanyVoiceApi api=companyVoiceApiService.selectCompanyVoiceApiById(company.getVoiceApiId());
+        if(api==null){
+            return R.error("外呼接口不存在");
+        }
+        if(api.getStatus().equals(0)){
+            return R.error("外呼接口已禁用");
+        }
+        CompanyUser user=userService.selectCompanyUserById(userId);
+        //CompanyVoiceCaller voiceCaller=callerService.selectCompanyVoiceCallerByUserId(companyId,userId);
+        CompanyVoice companyVoice=companyVoiceService.selectCompanyVoiceByCompanyId(user.getCompanyId());
+        if(callerEE==null){
+            return R.error("未绑定坐席");
+        }
+        if(companyVoice.getTimes()<=0){
+            return R.error("剩余时长不足,请购买套餐");
+        }
+
+//      CompanyVoiceMobile voiceMobile=mobileService.selectEmptyCompanyVoiceMobile(companyId,api.getApiId());
+//      if(voiceMobile==null){
+//           return R.error("没有空闲号码");
+//      }
+
+        //黑名单处理
+        if(blacklistService.selectCompanyVoiceBlacklistByMobile(caller)>0){
+            return R.error("主叫号码已被设置为黑名单");
+        }
+        //写入SESSION
+        CompanyVoiceLogs logs=new CompanyVoiceLogs();
+        logs.setCompanyId(companyId);
+        logs.setVoiceTitle(caller+"回拨:"+user.getNickName());
+        logs.setStartTime(new Date());
+        logs.setVoiceType(1);
+        logs.setCalleePhone(callerEE.getMobile());
+        logs.setCallerPhone(caller);
+        logs.setDisplayCalleeNumber(callerEE.getMobile());
+        logs.setDisplayCallerNumber(caller);
+        logs.setRemark(caller +"回拨呼叫"+user.getNickName());
+        logs.setCompanyUserId(userId);
+        logs.setCustomerId(customerId);
+        logs.setApiId(api.getApiId());
+        logs.setSessionId(session);
+        logs.setCallerNo(caller);
+        logsService.insertCompanyVoiceLogs(logs);
+//        voiceMobile.setStatus(0);
+//        mobileService.updateCompanyVoiceMobile(voiceMobile);
+        return R.ok();
+
+    }
+
     @Login
     @ApiOperation("获取SIP")
     @GetMapping(value="/getSipAccount")

+ 5 - 0
fs-company/src/main/java/com/fs/company/controller/CompanyUserController.java

@@ -355,5 +355,10 @@ public class CompanyUserController extends BaseController {
             return AjaxResult.error("操作失败");
         }
     }
+    @PutMapping("/updateVolume")
+    public AjaxResult updateVolume(@RequestBody CompanyUser user) {
+        user.setUpdateBy(SecurityUtils.getUsername());
+        return toAjax(companyUserService.updateVolume(user));
+    }
 
 }

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

@@ -13,11 +13,13 @@ import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.crm.domain.CrmCustomerContacts;
 import com.fs.crm.param.CrmCompanyLineCustomerImportParam;
 import com.fs.core.security.LoginUser;
 import com.fs.core.web.service.TokenService;
 import com.fs.crm.domain.CrmCustomer;
 import com.fs.crm.param.*;
+import com.fs.crm.service.ICrmCustomerContactsService;
 import com.fs.crm.service.ICrmCustomerService;
 import com.fs.crm.service.ICrmCustomerUserService;
 import com.fs.crm.vo.*;
@@ -52,7 +54,8 @@ public class CrmCustomerController extends BaseController
     private TokenService tokenService;
     @Autowired
     ICrmCustomerUserService crmCustomerUserService;
-
+    @Autowired
+    private ICrmCustomerContactsService crmContactsService;
     @ApiOperation("获取线索客户")
     @PreAuthorize("@ss.hasPermi('crm:customer:lineList')")
     @GetMapping("/getLineCustomerList")
@@ -448,5 +451,22 @@ public class CrmCustomerController extends BaseController
         List<CrmCustomer> list = crmCustomerService.selectCrmCustomerListBySearch(param);
         return R.ok().put("data",list);
     }
-
+    @PreAuthorize("@ss.hasPermi('crm:customer:query2')")
+    @GetMapping(value = "/getInfoByMobile/{mobile}")
+    public R getInfoByMobile(@PathVariable("mobile") String mobile)
+    {
+        CrmCustomer customer=crmCustomerService.selectFscrmByMobile(mobile);
+        Long customerId=0L;
+        if(customer==null){
+            CrmCustomerContacts contactsMap=new CrmCustomerContacts();
+            contactsMap.setMobile(mobile);
+            List<CrmCustomerContacts>  contactsList=crmContactsService.selectCrmCustomerContactsList(contactsMap);
+            if(contactsList.size()>0){
+                CrmCustomerContacts contacts=contactsList.get(0);
+                customerId=contacts.getCustomerId();
+                customer=crmCustomerService.selectCrmCustomerById(customerId);
+            }
+        }
+        return R.ok().put("data",customer);
+    }
 }

+ 11 - 0
fs-service-system/src/main/java/com/fs/company/domain/CompanyUser.java

@@ -132,6 +132,10 @@ public class CompanyUser extends BaseEntity
 
     private Integer qwStatus;
 
+    /** 音量 */
+    private double volume;
+
+
     /** 用户上级id */
     private Long parentId;
 
@@ -144,6 +148,13 @@ public class CompanyUser extends BaseEntity
     /** 是否需要单独注册会员,1-是,0-否(用于个微销售分享看课) */
     private Integer isNeedRegisterMember;
 
+    public double getVolume() {
+        return volume;
+    }
+
+    public void setVolume(double volume) {
+        this.volume = volume;
+    }
     public Integer getIsAudit() {
         return isAudit;
     }

+ 4 - 0
fs-service-system/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -291,4 +291,8 @@ public interface CompanyUserMapper
     List<CompanyUser> selectAllCompanyUserByCompanyIdAndDeptId(@Param("companyId") Long companyId, @Param("deptId") Long deptId);
 
     List<String> selectCompanyUserNameByIds(@Param("companyUserIDs")List<Long> companyUserID);
+
+
+    @Update(" update company_user set volume=#{maps.volume} where user_id=#{maps.userId} ")
+    public int updateVolume(@Param("maps") CompanyUser user);
 }

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

@@ -204,4 +204,5 @@ public interface ICompanyUserService {
      */
     Boolean setIsRegisterMember(boolean status,  List<Long> userIds);
 
+    int updateVolume(CompanyUser user);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/company/service/ICompanyVoiceCallerService.java

@@ -73,4 +73,6 @@ public interface ICompanyVoiceCallerService
     List<CompanyVoiceCaller> selectCompanyVoiceCallerByEnable(Long callerLine);
 
     Integer selectCompanyVoiceCallerCountsByCompanyId(Long companyId);
+
+    CompanyVoiceCaller selectCompanyVoiceCallerByCallerNo(String callee);
 }

+ 4 - 1
fs-service-system/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -538,5 +538,8 @@ public class CompanyUserServiceImpl implements ICompanyUserService
     public List<CompanyUser> getCompanyUserListByCompanyIdAndDeptId(Long companyId, Long deptId) {
         return companyUserMapper.selectAllCompanyUserByCompanyIdAndDeptId(companyId, deptId);
     }
-
+    @Override
+    public int updateVolume(CompanyUser user){
+        return companyUserMapper.updateVolume(user);
+    }
 }

+ 6 - 0
fs-service-system/src/main/java/com/fs/company/service/impl/CompanyVoiceCallerServiceImpl.java

@@ -190,4 +190,10 @@ public class CompanyVoiceCallerServiceImpl implements ICompanyVoiceCallerService
     public Integer selectCompanyVoiceCallerCountsByCompanyId(Long companyId) {
         return companyVoiceCallerMapper.selectCompanyVoiceCallerCountsByCompanyId(companyId);
     }
+
+    @Override
+    public CompanyVoiceCaller selectCompanyVoiceCallerByCallerNo(String callerNo) {
+        return companyVoiceCallerMapper.selectCompanyVoiceCallerByCallerNo(callerNo);
+    }
+
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -620,4 +620,7 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer>
      * @return
      */
     List<Long> selectCustomerIdByCompanyUserId(@Param("companyUserId") Long companyUserId);
+
+    @Select("select *  from crm_customer where mobile=#{mobile} limit 1")
+    CrmCustomer selectFscrmByMobile(String mobile);
 }

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

@@ -141,4 +141,6 @@ public interface ICrmCustomerService
     public List<CrmCustomerListVO> selectCrmCustomer1();
 
     List<CrmMyCustomerListQueryVO> selectCrmMyAssistListQuery(CrmMyCustomerListQueryParam param);
+
+    CrmCustomer selectFscrmByMobile(String mobile);
 }

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

@@ -962,4 +962,9 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
 
         return vos;
     }
+
+    @Override
+    public CrmCustomer selectFscrmByMobile(String mobile){
+        return crmCustomerMapper.selectFscrmByMobile(mobile);
+    }
 }

+ 1 - 0
fs-service-system/src/main/resources/mapper/crm/CrmCustomerMapper.xml

@@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="visitTime"    column="visit_time"    />
         <result property="trafficSource"   column="traffic_source"    />
         <result property="importType"    column="import_type"    />
+        <result property="volume"    column="volume"    />
         <result property="thirdAccount"    column="third_account"    />
         <result property="clueId"    column="clue_id"    />
     </resultMap>