|
@@ -15,11 +15,12 @@ import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
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.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.CloudStorageService;
|
|
import com.fs.system.oss.OSSFactory;
|
|
import com.fs.system.oss.OSSFactory;
|
|
import com.fs.voice.service.IVoiceService;
|
|
import com.fs.voice.service.IVoiceService;
|
|
@@ -72,6 +73,28 @@ public class VoiceApiController extends AppBaseController {
|
|
private ICompanyVoiceService companyVoiceService;
|
|
private ICompanyVoiceService companyVoiceService;
|
|
@Autowired
|
|
@Autowired
|
|
private ICompanyVoiceMobileService companyVoiceMobileService;
|
|
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
|
|
@Autowired
|
|
JwtUtils jwtUtils;
|
|
JwtUtils jwtUtils;
|
|
@Login
|
|
@Login
|
|
@@ -154,6 +177,31 @@ public class VoiceApiController extends AppBaseController {
|
|
logs.setStatus(-1);
|
|
logs.setStatus(-1);
|
|
companyVoiceLogsService.updateCompanyVoiceLogs(logs);
|
|
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();
|
|
CallResult result=new CallResult();
|
|
result.setMsg("");
|
|
result.setMsg("");
|
|
@@ -161,6 +209,64 @@ public class VoiceApiController extends AppBaseController {
|
|
return result;
|
|
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
|
|
@Login
|
|
@ApiOperation("获取SIP")
|
|
@ApiOperation("获取SIP")
|
|
@GetMapping(value="/getSipAccount")
|
|
@GetMapping(value="/getSipAccount")
|