浏览代码

修改语音通知bug

suntianwu 3 年之前
父节点
当前提交
5d57852555

+ 46 - 19
src/main/java/com/care/bms/controller/VoiceCallbackController.java

@@ -37,27 +37,54 @@ public class VoiceCallbackController {
         try {
             System.out.println("callback json == " + JsonUtil.toJson(voicepromptCallback));
             Map voiceCallbackParams = (Map) voicepromptCallback.get("voiceprompt_callback");
-            String callId = (String) voiceCallbackParams.get("callid");
-            System.out.println("callback:callId==" + callId);
-            String orderId = (String) redisUtil.hget(RedisKeyConstant.VOICE_CALLBACK_INFO, callId);
-            System.out.println("callback:orderId==" + orderId);
-            String mobile = (String) voiceCallbackParams.get("mobile");
-            System.out.println("callback:mobile==" + mobile);
-            Integer status = null;
-            String result = (String) voiceCallbackParams.get("result");
-            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();
+            if(voiceCallbackParams != null) {
+                String callId = (String) voiceCallbackParams.get("callid");
+                System.out.println("callback:callId==" + callId);
+                String orderId = (String) redisUtil.hget(RedisKeyConstant.VOICE_CALLBACK_INFO, callId);
+                System.out.println("callback:orderId==" + orderId);
+                String mobile = (String) voiceCallbackParams.get("mobile");
+                System.out.println("callback:mobile==" + mobile);
+                Integer status = null;
+                String result = (String) voiceCallbackParams.get("result");
+                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,null);
+
+                Map<String, Object> rtn = new HashMap<>();
+                rtn.put("result", 0);
+                rtn.put("errmsg", "OK");
+                return rtn;
+            } else {
+                voiceCallbackParams = (Map) voicepromptCallback.get("voice_failure_callback");
+                if(voiceCallbackParams != null){
+                    String callId = (String) voiceCallbackParams.get("callid");
+                    System.out.println("callback:failure callId==" + callId);
+                    String orderId = (String) redisUtil.hget(RedisKeyConstant.VOICE_CALLBACK_INFO, callId);
+                    System.out.println("callback:failure orderId==" + orderId);
+                    String mobile = (String) voiceCallbackParams.get("mobile");
+                    System.out.println("callback:failure mobile==" + mobile);
+                    String failureReason = (String) voiceCallbackParams.get("failure_reason");
+                    System.out.println("callback:failure failureReason==" + failureReason);
+
+                    Integer status =  ContactorStatusEnum.WEI_JIE_TONG.getValue();
+
+                    bmsEventOrderService.updateOrderContactStatus4Callback(Long.parseLong(orderId), mobile, status,failureReason);
+
+                    Map<String, Object> rtn = new HashMap<>();
+                    rtn.put("result", 0);
+                    rtn.put("errmsg", "OK");
+                    return rtn;
+                } else {
+                    return null;
+                }
+
             }
-            bmsEventOrderService.updateOrderContactStatus4Callback(Long.parseLong(orderId), mobile, status);
 
-            Map<String, Object> rtn = new HashMap<>();
-            rtn.put("result", 0);
-            rtn.put("errmsg", "OK");
-            return rtn;
         } catch (Exception e){
             e.printStackTrace();
             return null;

+ 3 - 2
src/main/java/com/care/bms/service/BmsEventOrderService.java

@@ -726,7 +726,7 @@ public class BmsEventOrderService {
      * @param status
      * @return
      */
-    public boolean updateOrderContactStatus4Callback(Long orderId,String contactPhone, Integer status) {
+    public boolean updateOrderContactStatus4Callback(Long orderId,String contactPhone, Integer status,String failureReason) {
 
         UpdateWrapper<CareEventOrderContactStatus> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda().eq(CareEventOrderContactStatus::getOrderId, orderId).eq(CareEventOrderContactStatus::getContactPhone,contactPhone)
@@ -742,7 +742,8 @@ public class BmsEventOrderService {
                 .eq(CareEventOrderHandleHis::getLogType,LogTypeEnum.VOTICE.getValue())
                 .eq(CareEventOrderHandleHis::getLogObjectId,contact.getContactId())
                 .eq(CareEventOrderHandleHis::getLogResult,"语音通知")
-                .set(CareEventOrderHandleHis::getLogResult, ContactorStatusEnum.getCodeToName(status));
+                .set(CareEventOrderHandleHis::getVoiceCallStatus, ContactorStatusEnum.getCodeToName(status))
+                .set(CareEventOrderHandleHis::getVoiceFailureReason, failureReason);
         this.careEventOrderHandleHisService.update(updateWrapper2);
 
         return this.careEventOrderContactStatusService.update(updateWrapper);

+ 7 - 0
src/main/java/com/care/common/entity/CareEventOrderHandleHis.java

@@ -74,6 +74,13 @@ public class CareEventOrderHandleHis implements Serializable {
     @TableField("LOG_RESULT")
     private String logResult;
 
+    @ApiModelProperty("语音通知状态:1未联系,2未接通,3已联系")
+    @TableField("VOICE_CALL_STATUS")
+    private String voiceCallStatus;
+
+    @ApiModelProperty("操作结果")
+    @TableField("VOICE_FAILURE_REASON")
+    private String voiceFailureReason;
 
     @ApiModelProperty("chanmb管家 contact紧联系人")
     @TableField("OP_USER_ROLE")