Browse Source

new intef

vali 6 years ago
parent
commit
a97455dd81
1 changed files with 232 additions and 34 deletions
  1. 232 34
      application/service/controller/Ext.php

+ 232 - 34
application/service/controller/Ext.php

@@ -4,12 +4,16 @@ namespace app\service\controller;
 
 use think\cache\driver\Redis;
 use think\Request;
+use think\Db;
 
 use app\admin\model\Advertisement;
 use app\admin\model\Users;
-use app\service\model\Accounts;
 use app\admin\model\Admins;
 use app\admin\model\ServiceLog;
+use app\admin\model\ChatLog;
+
+use app\service\model\Alarm;
+use app\service\model\Accounts;
 
 /**
  * 客服系统 Event 接口
@@ -95,95 +99,289 @@ class Ext extends Common
         }
     }
 
-
-    //
-    public function xx3()
+    //添加工单
+    public function addService()
     {
-
+        $datas = [
+            'user_id' => input('post.user_id', 0),
+            'client_id' => input('post.client_id', ''),
+            'user_name' => input('post.user_name', ''),
+            'user_avatar' => input('post.user_avatar', ''),
+            'user_ip' => input('post.user_ip', ''),
+            'kf_id' => input('post.kf_id', 0),
+            'start_time' => input('post.start_time', ''),
+            'group_id' => input('post.group_id', ''),
+            'website' => input('post.website', ''),
+            'system' => input('post.system', ''),
+            'browse' => input('post.browse', ''),
+            'intime' => input('post.intime', ''),
+            'status' => input('post.status', ''),
+            'evaluate_id' => input('post.evaluate_id', ''),
+            'servicelog_close_type' => input('post.servicelog_close_type', ''),
+        ];
+
+        $id = Db::name('service_log')->insertGetId($datas);
+
+        if ($id) {
+            return json(['code' => 1, 'data' => ['service_id' => $id], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'fails!']);
+        }
     }
 
 
-    //
-    public function xx4()
+    //更新工单信息
+    public function updateServerlog()
     {
+        $id = intval(input('post.id', 0));
+        if (empty($id)) {
+            return json(['code' => 0, 'data' => [], 'msg' => '参数错误!']);;
+        }
+        $model = ServiceLog::get($id);
+        if (!$model) {
+            return json(['code' => 0, 'data' => [], 'msg' => '无此数据']);
+        }
+        $datas = [
+            'status' => input('post.status', 1),
+            'evaluate_id' => input('post.evaluate_id', 1),
+            'evaluate_content' => input('post.evaluate_content', 1),
+            'servicelog_close_type' => input('post.servicelog_close_type', 0),
+        ];
+
+        $ret = $model->save($datas, ['servicelog_id' => $id]);
+        if ($ret) {
+            return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'faile']);
+        }
 
     }
 
 
-    //
-    public function xx5()
+    //统计某个工单会话条数
+    public function getSRcount()
     {
-
+        $id = input('post.id', 0);
+        $model = new ChatLog();
+        $count = $model->selectChatLog(['servicelog_id' => $id]);
+        return json(['code' => 1, 'data' => ['count' => $count], 'msg' => 'success']);
     }
 
+    //初始化一条报警记录数据
+    public function addSArecord()
+    {
+        $id = intval(input('post.id', 0));
+        $model = new Alarm();
+        $model->servicelog_id = $id;
+        $ret = $model->save();
+        if ($ret) {
+            return json(['code' => 1, 'data' => ['alarm_id' => $model->alarm_id], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'failse']);
+        }
+    }
 
-    //
-    public function xx6()
+    //获取某个工单的报敬记录数据
+    public function getSAbyid()
     {
+        $sid = intval(input('post.sid', 0));
+        $aid = intval(input('post.aid', 0));
+        $id = $sid ? $sid : $aid;
+        $fild = $sid ? 'servicelog_id' : 'alarm_id';
+        $where = ["$fild" => $id];
+
+        $model = new Alarm();
+        $record = $model->where($where)->find();
+
+        if ($record) {
+            return json(['code' => 1, 'data' => ['count' => $record], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'faile']);
+        }
 
     }
 
 
-    //
-    public function xx7()
+    //更新报警数据
+    public function updateSArecord()
     {
+        $id = intval(input('post.sid', 0));
+        if (empty($id)) {
+            return json(['code' => 0, 'data' => [], 'msg' => '参数错误!']);;
+        }
+        $model = Alarm::get(['servicelog_id' => $id]);
+        if (!$model) {
+            return json(['code' => 0, 'data' => [], 'msg' => '无此数据']);
+        }
 
+        $datas = [
+            'alarm_userSensitive' => input('post.alarm_userSensitive', 0),
+            'alarm_serverSensitive' => input('post.alarm_serverSensitive', 0),
+            'alarm_corresponding' => input('post.alarm_corresponding', 0),
+            'alarm_cvtOvertime' => input('post.alarm_cvtOvertime', 0),
+            'alarm_respond' => input('post.alarm_respond', 0),
+            'alarm_lineTime' => input('post.alarm_lineTime', 0),
+            'alarm_count' => input('post.alarm_count', 0),
+        ];
+
+        $ret = $model->save($datas, ['servicelog_id' => $id]);
+        if ($ret) {
+            return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'faile']);
+        }
     }
 
 
-    //
-    public function xx8()
+    //查询统计中间表记录
+    public function countmidtabquery()
     {
+        $dtype = input('post.dtype', '');
+        $mdate = input('post.mdate', date("Y-m-d"));
+
+        $ret = DB::name('countmidtable')->where(['dtype' => $dtype, 'mdate' => $mdate])->find();
+        if ($ret) {
+            return json(['code' => 1, 'data' => $ret, 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'faile']);
+        }
 
     }
 
 
-    //
-    public function xx9()
+    //更新或新增统计中间统计表
+    public function countmidtabupdate()
     {
+        $id = input('post.id', 0);
+        $dtype = input('post.dtype', '');
+        $mdate = input('post.mdate', date("Y-m-d"));
 
-    }
+        $dcontent = input('post.dcontent', '');
+        $datatype = input('post.datatype', '');
 
+        $flag = intval(input('post.flag', 0));
 
-    //
-    public function xxa()
-    {
+        if ($flag == 1) {
+            $ret = Db::table('ws_countmidtable')->update(['datatype' => $datatype, 'dcontent' => $dcontent, 'id' => $id]);
+        } else {
+            $ret = Db::table('ws_countmidtable')->insert(['dtype' => $dtype, 'mdate' => $mdate, 'dcontent' => $dcontent, 'datatype' => $datatype]);
+        }
+
+        if ($ret) {
+            return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+        }
 
     }
 
 
-    //
-    public function xxb()
+    //获取系统配置
+    public function getsysconfig()
     {
-
+        $all = Db::name("systemconfig")->select();
+        return json(['code' => 1, 'data' => $all, 'msg' => 'success']);
     }
 
 
-    //
-    public function xxc()
+    //获取所有分组信息
+    public function getgroups()
     {
-
+        $all = Db::name("groups")->select();
+        return json(['code' => 1, 'data' => $all, 'msg' => 'success']);
     }
 
 
-    //
-    public function xxd()
+    //获取所有自动回答信息
+    public function wsreplay()
     {
+        $type = intval(input('post.type', 1));
+        $all = Db::name("reply")->where('type', $type)->select();
+        return json(['code' => 1, 'data' => $all, 'msg' => 'success']);
+    }
+
 
+    //获取所有用户分组标签
+    public function accountlab()
+    {
+        $all = Db::name("accountslabel")->select();
+        return json(['code' => 1, 'data' => $all, 'msg' => 'success']);
     }
 
 
-    //
-    public function xxe()
+    //更新客服在线状态
+    public function upKfStatus()
     {
+        $flag = intval(input('post.flag', -1));
+        $kfuid = trim(input('post.uid', ''));
+
+        if ($flag == 0) {
+            $ret = Db::name('kfonline')->where('uid', $kfuid)->delete();
+            if ($ret) {
+                return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+            } else {
+                return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+            }
+        }
+
+        if ($flag == 1) {
+            $status = intval(input('post.status'));
+            $ip = trim(input('post.ip', ''));
+            $ret = Db::name('kfonline')->insert(['uid' => $kfuid, 'status' => $status, 'ip' => $ip, 'uptime' => date('Y-m-d H:i:s')]);
+            if ($ret) {
+                return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+            } else {
+                return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+            }
+        }
+
+        if ($flag == 2) {
+            $status = intval(input('post.status'));
+            $ret = Db::name('kfonline')->where('uid', $kfuid)->update(['status' => $status]);
+            if ($ret) {
+                return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+            } else {
+                return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+            }
+        }
 
     }
 
+    public function batchupserverlog()
+    {
+        $kfid = input('post.kfid', '');
+
+        $t = strtotime("-7 day");
+        $now = time();
+
+        if ($kfid) {
+            $ret = Db::execute("update ws_service_log set status=2,end_time=$now where  start_time>=$t and  kf_id=$kfid and  status!=2");
+        } else {
+            $ret = Db::execute("update ws_service_log set status=2,end_time=$now where  start_time>=$t and  status!=2");
+        }
+
+        if ($ret) {
+            return json(['code' => 1, 'data' => [], 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+        }
+    }
 
-    //
-    public function xxf()
+    public function torobot()
     {
+        $groups_id = intval(input('post.groups_id'));
+        $robot_name = trim(input('post.robot_name'));
+        $robotgroups_id = intval(input('post.robotgroups_id'));
+
+        $ret = Db::name('robot')->field('robot_content')->where(['robot_status' => 1, 'groups_id' => $groups_id, 'robot_name' => $robot_name, 'robotgroups_id' => $robotgroups_id])->select();
+
+        if ($ret) {
+            return json(['code' => 1, 'data' => $ret, 'msg' => 'success']);
+        } else {
+            return json(['code' => 0, 'data' => [], 'msg' => 'fail']);
+        }
 
     }
 
+
 }