anderx 1 год назад
Родитель
Сommit
d2cce4db2e

+ 8 - 0
src/main/java/com/goafanti/common/model/User.java

@@ -518,5 +518,13 @@ public class User implements  AftUser{
     public void setSignTime(Date signTime) {
         this.signTime = signTime;
     }
+
+    public Integer getCallStatus() {
+        return callStatus;
+    }
+
+    public void setCallStatus(Integer callStatus) {
+        this.callStatus = callStatus;
+    }
 }
 

+ 4 - 1
src/main/java/com/goafanti/customer/controller/UserOutboundApiController.java

@@ -47,7 +47,10 @@ public class UserOutboundApiController  extends BaseApiController {
             return res.error(new Error("坐席号不能为空"));
         }
         if (in.getCallee()==null){
-            return res.error(new Error("客户号不能为空"));
+            return res.error(new Error("客户号码不能为空"));
+        }
+        if (in.getUid()==null){
+            return res.error(new Error("客户编号不能为空"));
         }
         return new Result<>().data(this.userOutboundService.callNumber(in));
     }

+ 20 - 1
src/main/java/com/goafanti/customer/service/impl/UserOutboundServiceImpl.java

@@ -3,6 +3,8 @@ package com.goafanti.customer.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.dao.UserArchivesMapper;
+import com.goafanti.common.dao.UserMapper;
+import com.goafanti.common.model.User;
 import com.goafanti.common.utils.HttpUtils;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
@@ -28,6 +30,8 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
 
     @Resource
     private SystemWebSocketHandler systemWebSocketHandler;
+    @Resource
+    private UserMapper userMapper;
 
     @Override
     public Object checkUser(Integer type) {
@@ -59,6 +63,14 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
 
     @Override
     public Object callNumber(InputCallNumber in) {
+        String msg =null;
+        if (StringUtils.isNotBlank(in.getUid())){
+            User u =userMapper.queryById(in.getUid());
+            if (u.getCallStatus()==1){
+                msg = "该用户正在通话中";
+                return msg;
+            }
+        }
         String url= default_url +"/openapi/"+version+"/callNumber";
         Map<String,Object> param=new HashMap<>();
         param.put("authentication",getAuthentication());
@@ -74,10 +86,16 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
 //        {"result":{"error":"0xF1000022","msg":"分机号未注册"},"data":{"seq":"20241101","response":{"seq":null,"userData":null,"result":{"error":4043309090},"data":null}}}
         JSONObject jsonObject = JSON.parseObject(s);
         JSONObject result = jsonObject.getJSONObject("result");
-        String msg = result.getString("msg");
+        msg = result.getString("msg");
         if (StringUtils.isNotBlank(msg)){
             return msg;
         }
+        if (StringUtils.isNotBlank(in.getUid())){
+            User u =new User();
+            u.setId(in.getUid());
+            u.setCallStatus(1);
+            userMapper.update(u);
+        }
         return s;
     }
 
@@ -103,6 +121,7 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
 
     @Override
     public Object callCompleted(Map<String, String[]> in) {
+        //需要关闭客户呼叫中
         systemWebSocketHandler.sendMessageToUser(TokenManager.getAdminId(), new TextMessage("callCompleted"));
         return 1;
     }