123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package com.care.bms.controller;
- import com.care.bms.params.VoiceCallbackParams;
- import com.care.bms.service.BmsEventOrderService;
- import com.care.common.cache.RedisKeyConstant;
- import com.care.common.cache.RedisUtil;
- import com.care.common.enums.ContactorStatusEnum;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * @Author: lilt
- * @Date: 2021/5/26
- * @Desc:
- */
- @RestController
- @Api(value = "VoiceCallbackController", tags = { "语音通知回调接口" })
- @Slf4j
- @RequestMapping("/bms")
- public class VoiceCallbackController {
- @Resource
- private RedisUtil redisUtil;
- @Autowired
- private BmsEventOrderService bmsEventOrderService;
- @PostMapping("/voice/callback")
- @ApiOperation(tags = {"语音通知回调接口"},value = "语音通知回调接口")
- public Map<String,Object> callback(@RequestBody VoiceCallbackParams voiceCallbackParams) {
- String callId = voiceCallbackParams.getCallid();
- System.out.println("callback:callId==" + callId);
- String orderId = (String) redisUtil.hget(RedisKeyConstant.VOICE_CALLBACK_INFO, callId);
- String mobile = voiceCallbackParams.getMobile();
- Integer status = null;
- String result = voiceCallbackParams.getResult();
- if("0".equals(result)) { //用户正常接听
- status = ContactorStatusEnum.YI_LIAN_XI.getValue();
- } else if("1".equals(result)){ //用户未接听
- status = ContactorStatusEnum.WEI_JIE_TONG.getValue();
- } else { //呼叫异常
- status = ContactorStatusEnum.WEI_JIE_TONG.getValue();
- }
- bmsEventOrderService.updateOrderContactStatus4Callback(Long.parseLong(orderId),mobile,status);
- Map<String,Object> rtn = new HashMap<>();
- rtn.put("result",0);
- rtn.put("errmsg","OK");
- return rtn;
- }
- }
|