app通话回调
This commit is contained in:
@@ -79,7 +79,10 @@ public enum ErrorCodeEnum {
|
|||||||
INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在!", null),
|
INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在!", null),
|
||||||
ROOM_STATUS_ERROR(10211156, "当前面试房间状态不允许进行该操作!", null),
|
ROOM_STATUS_ERROR(10211156, "当前面试房间状态不允许进行该操作!", null),
|
||||||
MOBILE_APP_NOT_ONLINE_ERROR(10211157, "拨出手机APP不在线!", null),
|
MOBILE_APP_NOT_ONLINE_ERROR(10211157, "拨出手机APP不在线!", null),
|
||||||
CALL_UP_ERROR(10211158, "拨出电话异常!", null),
|
CALL_RECORD_NOT_EXIST_ERROR(10211158, "通话记录不存在!", null),
|
||||||
|
|
||||||
|
CREATE_CALL_REQUEST_ERROR(10211158, "创建电话请求失败!", null),
|
||||||
|
CALL_UP_ERROR(10211159, "拨出电话异常!", null),
|
||||||
CONTENT_DUPLICATED(10211200, "动态标题重复!", null),
|
CONTENT_DUPLICATED(10211200, "动态标题重复!", null),
|
||||||
SIGN_FAIL(600000, "验签失败", null),
|
SIGN_FAIL(600000, "验签失败", null),
|
||||||
GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误!", null),
|
GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误!", null),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cool.store.mapper;
|
package com.cool.store.mapper;
|
||||||
|
|
||||||
import com.cool.store.entity.CallRecordDO;
|
import com.cool.store.entity.CallRecordDO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangchenbiao
|
* @author zhangchenbiao
|
||||||
@@ -21,4 +22,8 @@ public interface CallRecordMapper {
|
|||||||
* dateTime:2023-08-11 01:03
|
* dateTime:2023-08-11 01:03
|
||||||
*/
|
*/
|
||||||
int updateByPrimaryKeySelective(CallRecordDO record);
|
int updateByPrimaryKeySelective(CallRecordDO record);
|
||||||
|
|
||||||
|
int updateByTransNoSelective(CallRecordDO record);
|
||||||
|
|
||||||
|
CallRecordDO selectByTransNo(String transNo);
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
incoming_user_id, call_start_time, call_end_time, record_url, call_status, fail_reason,
|
incoming_user_id, call_start_time, call_end_time, record_url, call_status, fail_reason,
|
||||||
creater, create_time, updater, update_time, remark
|
creater, create_time, updater, update_time, remark
|
||||||
</sql>
|
</sql>
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
|
||||||
insert into call_record
|
insert into call_record
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="partnerLineId != null">
|
<if test="partnerLineId != null">
|
||||||
@@ -182,4 +182,61 @@
|
|||||||
</set>
|
</set>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateByTransNoSelective">
|
||||||
|
update call_record
|
||||||
|
<set>
|
||||||
|
<if test="partnerLineId != null">
|
||||||
|
partner_line_id = #{partnerLineId},
|
||||||
|
</if>
|
||||||
|
<if test="outgoingMobile != null">
|
||||||
|
outgoing_mobile = #{outgoingMobile},
|
||||||
|
</if>
|
||||||
|
<if test="outgoingUserId != null">
|
||||||
|
outgoing_user_id = #{outgoingUserId},
|
||||||
|
</if>
|
||||||
|
<if test="incomingMobile != null">
|
||||||
|
incoming_mobile = #{incomingMobile},
|
||||||
|
</if>
|
||||||
|
<if test="incomingUserId != null">
|
||||||
|
incoming_user_id = #{incomingUserId},
|
||||||
|
</if>
|
||||||
|
<if test="callStartTime != null">
|
||||||
|
call_start_time = #{callStartTime},
|
||||||
|
</if>
|
||||||
|
<if test="callEndTime != null">
|
||||||
|
call_end_time = #{callEndTime},
|
||||||
|
</if>
|
||||||
|
<if test="recordUrl != null">
|
||||||
|
record_url = #{recordUrl},
|
||||||
|
</if>
|
||||||
|
<if test="callStatus != null">
|
||||||
|
call_status = #{callStatus},
|
||||||
|
</if>
|
||||||
|
<if test="failReason != null">
|
||||||
|
fail_reason = #{failReason},
|
||||||
|
</if>
|
||||||
|
<if test="creater != null">
|
||||||
|
creater = #{creater},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time = #{createTime},
|
||||||
|
</if>
|
||||||
|
<if test="updater != null">
|
||||||
|
updater = #{updater},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null">
|
||||||
|
remark = #{remark},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where trans_no = #{transNo}
|
||||||
|
</update>
|
||||||
|
<select id="selectByTransNo" resultType="com.cool.store.entity.CallRecordDO">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from call_record
|
||||||
|
where trans_no = #{transNo}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.cool.store.request;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: young.yu
|
||||||
|
* @Date: 2023-08-11 15:46
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(description = "呼叫信息")
|
||||||
|
public class CallFinishBackReq {
|
||||||
|
@ApiModelProperty(value = "请求编号", required = true)
|
||||||
|
private String transNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "呼叫状态: 1-呼叫接听, 2-呼叫未接听, 3-呼叫失败", required = true)
|
||||||
|
private Integer callStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "呼叫失败的情况下必传,说明呼叫失败的原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "呼叫接听情况下必传,通话开始时间,格式:yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String callStartTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "呼叫接听情况下必传,通话结束时间,格式:yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String callEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.cool.store.request;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(description = "呼叫记录信息")
|
||||||
|
public class CallRecordBackReq {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "请求编号", required = true)
|
||||||
|
private String transNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "录音上传地址", required = true)
|
||||||
|
private String recordUrl;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.cool.store.service;
|
package com.cool.store.service;
|
||||||
|
|
||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
|
import com.cool.store.request.CallFinishBackReq;
|
||||||
|
import com.cool.store.request.CallRecordBackReq;
|
||||||
import com.cool.store.request.CallUpReq;
|
import com.cool.store.request.CallUpReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,4 +12,6 @@ import com.cool.store.request.CallUpReq;
|
|||||||
*/
|
*/
|
||||||
public interface CallService {
|
public interface CallService {
|
||||||
void callUp(CallUpReq request) throws ApiException;
|
void callUp(CallUpReq request) throws ApiException;
|
||||||
|
void callFinishBack(CallFinishBackReq request) throws ApiException;
|
||||||
|
void callRecordBack(CallRecordBackReq request) throws ApiException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.cool.store.service.impl;
|
package com.cool.store.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.lang.UUID;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.cool.store.dto.call.CallUpDTO;
|
import com.cool.store.dto.call.CallUpDTO;
|
||||||
@@ -9,8 +10,13 @@ import com.cool.store.enums.ErrorCodeEnum;
|
|||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.handler.WebSocketServer;
|
import com.cool.store.handler.WebSocketServer;
|
||||||
import com.cool.store.mapper.CallRecordMapper;
|
import com.cool.store.mapper.CallRecordMapper;
|
||||||
|
import com.cool.store.mapper.HyOutboundMobileMapper;
|
||||||
|
import com.cool.store.request.CallFinishBackReq;
|
||||||
|
import com.cool.store.request.CallRecordBackReq;
|
||||||
import com.cool.store.request.CallUpReq;
|
import com.cool.store.request.CallUpReq;
|
||||||
import com.cool.store.service.CallService;
|
import com.cool.store.service.CallService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -21,43 +27,83 @@ import java.util.Date;
|
|||||||
* @Date: 2023-08-10 18:58
|
* @Date: 2023-08-10 18:58
|
||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CallServiceImpl implements CallService {
|
public class CallServiceImpl implements CallService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CallRecordMapper callRecordMapper;
|
private CallRecordMapper callRecordMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HyOutboundMobileMapper hyOutboundMobileMapper;
|
||||||
@Override
|
@Override
|
||||||
public void callUp(CallUpReq request) throws ApiException {
|
public void callUp(CallUpReq request) throws ApiException {
|
||||||
//校验拨出手机号APP是否在线
|
try {
|
||||||
boolean isOnline = WebSocketServer.isOnline(request.getOutgoingMobile());
|
//校验拨出手机号APP是否在线
|
||||||
if(!isOnline){
|
boolean isOnline = WebSocketServer.isOnline(request.getOutgoingMobile());
|
||||||
throw new ApiException(ErrorCodeEnum.MOBILE_APP_NOT_ONLINE_ERROR);
|
if (!isOnline) {
|
||||||
}
|
throw new ApiException(ErrorCodeEnum.MOBILE_APP_NOT_ONLINE_ERROR);
|
||||||
CallRecordDO callRecordDO = new CallRecordDO();
|
}
|
||||||
callRecordDO.setOutgoingMobile(request.getOutgoingMobile());
|
CallRecordDO callRecordDO = new CallRecordDO();
|
||||||
callRecordDO.setIncomingMobile(request.getIncomingMobile());
|
callRecordDO.setOutgoingMobile(request.getOutgoingMobile());
|
||||||
callRecordDO.setOutgoingUserId(request.getOutgoingUserId());
|
callRecordDO.setIncomingMobile(request.getIncomingMobile());
|
||||||
callRecordDO.setIncomingUserId(request.getIncomingUserId());
|
callRecordDO.setOutgoingUserId(request.getOutgoingUserId());
|
||||||
callRecordDO.setPartnerLineId(Long.valueOf(request.getLineId()));
|
callRecordDO.setIncomingUserId(request.getIncomingUserId());
|
||||||
|
callRecordDO.setPartnerLineId(Long.valueOf(request.getLineId()));
|
||||||
|
|
||||||
//请求id
|
//请求id
|
||||||
String transNo = UUID.fastUUID().toString();
|
String transNo = UUID.fastUUID().toString().replace("-", "");
|
||||||
callRecordDO.setTransNo(transNo);
|
callRecordDO.setTransNo(transNo);
|
||||||
callRecordDO.setCreater(request.getOutgoingUserId());
|
callRecordDO.setCreater(request.getOutgoingUserId());
|
||||||
callRecordDO.setCreateTime(new Date());
|
callRecordDO.setCreateTime(new Date());
|
||||||
callRecordDO.setCallStatus(CallStatusEnum.PENDING_CALL.getCode());
|
callRecordDO.setCallStatus(CallStatusEnum.PENDING_CALL.getCode());
|
||||||
|
|
||||||
//发起app通话请求
|
//发起app通话请求
|
||||||
CallUpDTO callUpDTO = new CallUpDTO();
|
CallUpDTO callUpDTO = new CallUpDTO();
|
||||||
callUpDTO.setTransNo(transNo);
|
callUpDTO.setTransNo(transNo);
|
||||||
callUpDTO.setOutgoingMobile(request.getOutgoingMobile());
|
callUpDTO.setOutgoingMobile(request.getOutgoingMobile());
|
||||||
callUpDTO.setIncomingMobile(request.getIncomingMobile());
|
callUpDTO.setIncomingMobile(request.getIncomingMobile());
|
||||||
boolean sendFlag = WebSocketServer.sendInfo(JSON.toJSONString(callUpDTO),callRecordDO.getOutgoingMobile());
|
boolean sendFlag = WebSocketServer.sendInfo(JSON.toJSONString(callUpDTO), callRecordDO.getOutgoingMobile());
|
||||||
if(!sendFlag){
|
if (!sendFlag) {
|
||||||
|
throw new ApiException(ErrorCodeEnum.CREATE_CALL_REQUEST_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存通话记录
|
||||||
|
callRecordMapper.insertSelective(callRecordDO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("callUp error, request:{}", JSON.toJSONString(request), e);
|
||||||
throw new ApiException(ErrorCodeEnum.CALL_UP_ERROR);
|
throw new ApiException(ErrorCodeEnum.CALL_UP_ERROR);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//保存通话记录
|
@Override
|
||||||
callRecordMapper.insertSelective(callRecordDO);
|
public void callFinishBack(CallFinishBackReq request) throws ApiException {
|
||||||
|
CallRecordDO callRecordDO = callRecordMapper.selectByTransNo(request.getTransNo());
|
||||||
|
//校验通话记录是否存在
|
||||||
|
if(callRecordDO == null){
|
||||||
|
throw new ApiException(ErrorCodeEnum.CALL_RECORD_NOT_EXIST_ERROR);
|
||||||
|
}
|
||||||
|
callRecordDO.setCallStatus(request.getCallStatus());
|
||||||
|
callRecordDO.setFailReason(request.getFailReason());
|
||||||
|
callRecordDO.setUpdater("system-app");
|
||||||
|
callRecordDO.setUpdateTime(new Date());
|
||||||
|
if(StringUtils.isNotEmpty(request.getCallStartTime())&&StringUtils.isNotEmpty(request.getCallEndTime())){
|
||||||
|
callRecordDO.setCallStartTime(DateUtil.parse(request.getCallStartTime()));
|
||||||
|
callRecordDO.setCallEndTime(DateUtil.parse(request.getCallEndTime()));
|
||||||
|
}
|
||||||
|
callRecordMapper.updateByTransNoSelective(callRecordDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callRecordBack(CallRecordBackReq request) throws ApiException {
|
||||||
|
CallRecordDO callRecordDO = callRecordMapper.selectByTransNo(request.getTransNo());
|
||||||
|
//校验通话记录是否存在
|
||||||
|
if(callRecordDO == null){
|
||||||
|
throw new ApiException(ErrorCodeEnum.CALL_RECORD_NOT_EXIST_ERROR);
|
||||||
|
}
|
||||||
|
callRecordDO.setRecordUrl(request.getRecordUrl());
|
||||||
|
callRecordDO.setUpdater("system-app");
|
||||||
|
callRecordDO.setUpdateTime(new Date());
|
||||||
|
callRecordMapper.updateByTransNoSelective(callRecordDO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ public class TokenValidateFilter implements Filter {
|
|||||||
//TODO 800回调地址暂时不做验证
|
//TODO 800回调地址暂时不做验证
|
||||||
"/partner/pc/flow/qualificationReview/callback",
|
"/partner/pc/flow/qualificationReview/callback",
|
||||||
"/**/ecSync/ecToApplet/**",
|
"/**/ecSync/ecToApplet/**",
|
||||||
"/partner/pc/websocket/**");
|
"/partner/pc/websocket/**",
|
||||||
|
"/partner/pc/call/**");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.cool.store.controller;
|
package com.cool.store.controller;
|
||||||
|
|
||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
|
import com.cool.store.request.CallFinishBackReq;
|
||||||
|
import com.cool.store.request.CallRecordBackReq;
|
||||||
import com.cool.store.request.CallUpReq;
|
import com.cool.store.request.CallUpReq;
|
||||||
import com.cool.store.request.GetTipsInfoReq;
|
import com.cool.store.request.GetTipsInfoReq;
|
||||||
import com.cool.store.response.ResponseResult;
|
import com.cool.store.response.ResponseResult;
|
||||||
@@ -34,4 +36,18 @@ public class CallController {
|
|||||||
callService.callUp(request);
|
callService.callUp(request);
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/finish/callback")
|
||||||
|
@ApiOperation("通话结束回调")
|
||||||
|
public ResponseResult callFinishBack(@RequestBody CallFinishBackReq request) throws ApiException {
|
||||||
|
callService.callFinishBack(request);
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/record/callback")
|
||||||
|
@ApiOperation("录音上传回调")
|
||||||
|
public ResponseResult callRecordBack(@RequestBody CallRecordBackReq request) throws ApiException {
|
||||||
|
callService.callRecordBack(request);
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user