修改点呼回调逻辑

master
wujingtao 3 years ago
parent afd74cade1
commit f3b73ddde8

@ -120,12 +120,12 @@ public class TelephoneCallController {
@PostMapping("/roll/cdrUrl")
@ApiOperation("点呼系统回调话单")
public CommonResponse<String> rollCallBack(@RequestBody String json) {
log.info("点呼回调:{}", json);
try {
RollCallBackDTO rollCallBackDTO = JSONUtil.toBean(json, RollCallBackDTO.class);
if (ObjectUtil.isEmpty(rollCallBackDTO) || StrUtil.isEmpty(rollCallBackDTO.getSessionid())) {
return CommonResponse.createByErrorMessage("参数为空");
}
log.info("点呼回调:{}", rollCallBackDTO);
telephoneCallService.rollCallBack(rollCallBackDTO);
} catch (Exception e) {
log.error("点呼回调话单错误 参数 {}", json);

@ -1,7 +1,6 @@
package com.baiye.modules.telemarkting.dao;
import com.baiye.modules.telemarkting.entity.AllCallInfo;
import com.baiye.modules.telemarkting.entity.CallClueInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@ -25,8 +24,6 @@ public interface AllCallInfoRepository extends JpaRepository<AllCallInfo, Long>,
*/
AllCallInfo findBySessionId(String sessionId);
AllCallInfo findByRequestId(String requestId);
/**
*
*

@ -27,4 +27,5 @@ public class RollCallBackDTO {
private String extval1;
private String extval2;
private String extval3;
private String otherLeg;
}

@ -186,6 +186,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
//获取分机号
ExtensionNumber extensionNumber = extensionNumberRepository.selectByMemberId(telephoneCallReqDTO.getMemberId());
if (extensionNumber == null) {
log.error("未配置分机号");
return CommonResponse.createByErrorMessage("未配置分机号");
}
telephoneCallReqDTO.setTelA(String.valueOf(extensionNumber.getNumber()));
@ -193,6 +194,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
//获取线索号
Clue body = sourceClueClient.queryDetails(Long.parseLong(telephoneCallReqDTO.getUserData())).getBody();
if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) {
log.error("未获取到号码");
return CommonResponse.createByErrorMessage("未获取到号码");
}
telephoneCallReqDTO.setTelB(body.getNid());
@ -201,6 +203,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
if (StrUtil.isNotBlank(reqId)) {
if (StrUtil.isNotBlank(reqId)) {
AllCallInfo allCallInfo = new AllCallInfo();
allCallInfo.setSessionId(requestId);
allCallInfo.setRequestId(requestId);
allCallInfo.setClueId(Long.parseLong(telephoneCallReqDTO.getUserData()));
allCallInfo.setMemberId(telephoneCallReqDTO.getMemberId());
@ -226,17 +229,23 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Override
@Transactional(rollbackFor = Exception.class)
public void rollCallBack(RollCallBackDTO rollCallBackDTO) {
String reqId = rollCallBackDTO.getReqid();
AllCallInfo allCallInfo = allCallInfoRepository.findByRequestId(reqId);
if (ObjectUtil.isNotEmpty(allCallInfo)) {
if (StrUtil.isBlank(rollCallBackDTO.getDuration())) {
//表示接通
callClueRepository.updateByStatus(DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueId());
String sessionId = rollCallBackDTO.getSessionid();
String otherLeg = rollCallBackDTO.getOtherLeg();
allCallInfo.setStatus(DefaultNumberConstants.TWO_NUMBER);
allCallInfo.setDuration(Integer.valueOf(rollCallBackDTO.getDuration()));
AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(sessionId);
if (ObjectUtil.isNotEmpty(allCallInfo)) {
//相同说明是分机号的回调
if (sessionId.equals(otherLeg)) {
allCallInfo.setRecordFlag(DefaultNumberConstants.ONE_NUMBER);
allCallInfo.setRecordFileDownloadUrl(rollCallBackDTO.getRecord_file_url());
} else {
//拨打线索号的回调
if (StrUtil.isNotBlank(rollCallBackDTO.getCallee_answer_time())) {
//表示接通
callClueRepository.updateByStatus(DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueId());
allCallInfo.setStatus(DefaultNumberConstants.TWO_NUMBER);
allCallInfo.setDuration(Integer.valueOf(rollCallBackDTO.getDuration()));
}
}
allCallInfoRepository.save(allCallInfo);
}

Loading…
Cancel
Save