diff --git a/admin/application/admin/controller/Aicustomerservice.php b/admin/application/admin/controller/Aicustomerservice.php new file mode 100644 index 0000000..b16c07c --- /dev/null +++ b/admin/application/admin/controller/Aicustomerservice.php @@ -0,0 +1,71 @@ +model = new \app\admin\model\Aicustomerservice; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = false; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + $row->visible(['id','name']); + + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/admin/application/admin/controller/Firmcustomer.php b/admin/application/admin/controller/Firmcustomer.php index fddedc3..7f2d6d9 100644 --- a/admin/application/admin/controller/Firmcustomer.php +++ b/admin/application/admin/controller/Firmcustomer.php @@ -58,20 +58,21 @@ class Firmcustomer extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model - ->with(['firmstoreprojectstwo','firmcustomerorigin','firmemployee']) + ->with(['firmstoreprojectstwo','firmcustomerorigin']) ->where($where) ->order($sort, $order) ->paginate($limit); foreach ($list as $row) { - $row->visible(['id','customer_name','age','phone','rel_wx','rel_group','firmtags_ids','headimage','remark','responsible_pm','return_visit_content','status','create_time']); + $row->visible(['id','customer_name','age','phone','rel_wx','rel_group','firmtags_ids','headimage','remark','responsible_pm','return_visit_content','status','create_time','admin_id']); $row->visible(['firmstoreprojectstwo']); $row->getRelation('firmstoreprojectstwo')->visible(['name']); $row->visible(['firmcustomerorigin']); $row->getRelation('firmcustomerorigin')->visible(['name']); - $row->visible(['firmemployee']); - $row->getRelation('firmemployee')->visible(['name']); - $row->responsible_pm = Db::table('fa_firmemployee')->where('id',$row->responsible_pm)->value('name'); + //$row->visible(['admin']); + //$row->getRelation('admin')->visible(['nickname']); + $row->admin_id = Db::table('fa_admin')->where('id',$row->admin_id)->value('nickname'); + $row->responsible_pm = Db::table('fa_admin')->where('id',$row->responsible_pm)->value('nickname'); } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/admin/application/admin/lang/zh-cn/aicustomerservice.php b/admin/application/admin/lang/zh-cn/aicustomerservice.php new file mode 100644 index 0000000..ad5e1f1 --- /dev/null +++ b/admin/application/admin/lang/zh-cn/aicustomerservice.php @@ -0,0 +1,8 @@ + 'ID', + 'Name' => 'AI客服名称', + 'Server_url' => '服务地址', + 'Apikey' => 'apikey' +]; diff --git a/admin/application/admin/model/Aicustomerservice.php b/admin/application/admin/model/Aicustomerservice.php new file mode 100644 index 0000000..99c4a35 --- /dev/null +++ b/admin/application/admin/model/Aicustomerservice.php @@ -0,0 +1,40 @@ +belongsTo('Firmemployee', 'firmemployee_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); } } diff --git a/admin/application/admin/validate/Aicustomerservice.php b/admin/application/admin/validate/Aicustomerservice.php new file mode 100644 index 0000000..c31e992 --- /dev/null +++ b/admin/application/admin/validate/Aicustomerservice.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/admin/application/admin/view/aicustomerservice/add.html b/admin/application/admin/view/aicustomerservice/add.html new file mode 100644 index 0000000..ffb854a --- /dev/null +++ b/admin/application/admin/view/aicustomerservice/add.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/admin/application/admin/view/aicustomerservice/edit.html b/admin/application/admin/view/aicustomerservice/edit.html new file mode 100644 index 0000000..31f4a2f --- /dev/null +++ b/admin/application/admin/view/aicustomerservice/edit.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/admin/application/admin/view/aicustomerservice/index.html b/admin/application/admin/view/aicustomerservice/index.html new file mode 100644 index 0000000..df1d6f3 --- /dev/null +++ b/admin/application/admin/view/aicustomerservice/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+
+
+ +
+ +
+
+
diff --git a/admin/application/admin/view/firmcustomer/add.html b/admin/application/admin/view/firmcustomer/add.html index 115ef60..1ba39d4 100644 --- a/admin/application/admin/view/firmcustomer/add.html +++ b/admin/application/admin/view/firmcustomer/add.html @@ -76,7 +76,7 @@
-
@@ -85,7 +85,7 @@
diff --git a/admin/application/admin/view/firmcustomer/edit.html b/admin/application/admin/view/firmcustomer/edit.html index 18e9992..e1ecbc5 100644 --- a/admin/application/admin/view/firmcustomer/edit.html +++ b/admin/application/admin/view/firmcustomer/edit.html @@ -67,7 +67,7 @@
@@ -75,7 +75,7 @@
- diff --git a/admin/application/api/controller/Firmemployee.php b/admin/application/api/controller/Worker.php similarity index 91% rename from admin/application/api/controller/Firmemployee.php rename to admin/application/api/controller/Worker.php index 61e3169..15f869a 100644 --- a/admin/application/api/controller/Firmemployee.php +++ b/admin/application/api/controller/Worker.php @@ -14,13 +14,12 @@ use think\Db; use wanghua\general_utility_tools_php\Mmodel; use wanghua\general_utility_tools_php\tool\Tools; -class Firmemployee extends BaseApiAuthController +class Worker extends BaseApiAuthController { /** * desc:获取工作人员列表 * - * /api/firmemployee/getList * author:wh */ function getList(){ diff --git a/admin/application/api/controller/Wxgroup.php b/admin/application/api/controller/Wxgroup.php new file mode 100644 index 0000000..2bee7ee --- /dev/null +++ b/admin/application/api/controller/Wxgroup.php @@ -0,0 +1,39 @@ +where('rel_group',$chatroom_id) + ->value('rel_group'); + + return Tools::set_ok('ok',[ + 'emergency_contact_wxid'=>$rel_group + ]); + }); + } +} \ No newline at end of file diff --git a/admin/application/common/model/BaseModel.php b/admin/application/common/model/BaseModel.php new file mode 100644 index 0000000..7261c79 --- /dev/null +++ b/admin/application/common/model/BaseModel.php @@ -0,0 +1,31 @@ +assign('index_msg',cache('index_msg_alert_cache_time')); + + //线上环境加载微信授权 + if(config('sys_env') == 'PROD'){ + $wx_user_info = session('wx_user_info'); + if(empty($wx_user_info['openid'])) { + //重定向之前,保存当前url, 在获取授权信息之后,回跳到授权之前的网页地址 + session('redirect_before_url_session',request()->url(true)); + //没有则重定向去授权 + return $this->redirect(url('Wexinauth/usrAuth','',301,true)); + } + + $this->saveWechatUser($wx_user_info); + } + + + //校验系统维护状态 start + $chm = $this->checkMaintain(); + if($chm['is_maintain']){ + if($chm['openid']){ + //解析openid + if(!in_array(index_user_openid(), explode(',',$chm['openid']))){ + //白名单之外维护中 + //Tools::log_to_write_txt([ + // '维护测试'=>$chm['openid'], + // 'my'=>index_user_openid() + //]); + return $this->error($chm['msg']); + } + }else{ + //不存在,直接维护中 + return $this->error($chm['msg'].'!'); + } + } + //校验系统维护状态 end + + + } + + + + + /** + * desc: + * author:wh + * @param $wx_user_info + */ + private function saveWechatUser($wx_user_info){ + try { + $wechat_user = WechatUserModel::getWxUserByOpenid($wx_user_info['openid']); + if(empty($wechat_user)){ + return WechatUserModel::insertInfo($wx_user_info); + } + //扩展,按周期更新,而不是不更新 + if(empty($wechat_user['update_time']) || time()-strtotime($wechat_user['update_time'])>5*3600){ + + return WechatUserModel::updateUser($wx_user_info); + } + + + }catch (\Exception $e){ + Tools::log_to_write_txt([ + 'error'=>'存储异常.'.$e->getMessage(), + 'wx_user_info'=>$wx_user_info, + 'error_info'=>$e->getTraceAsString() + ],LogDir::WECHAT_USER_INFO_LOG); + } + } +} \ No newline at end of file diff --git a/admin/application/index/controller/BaseCommonController.php b/admin/application/index/controller/BaseCommonController.php new file mode 100644 index 0000000..e28c4a2 --- /dev/null +++ b/admin/application/index/controller/BaseCommonController.php @@ -0,0 +1,29 @@ +checkMaintain(); + if($chm['is_maintain']){ + if($chm['openid']){ + //解析openid + if(!in_array(index_user_openid(), explode(',',$chm['openid']))){ + //白名单之外维护中 + //Tools::log_to_write_txt([ + // '维护测试'=>$chm['openid'], + // 'my'=>index_user_openid() + //]); + return $this->error($chm['msg']); + } + }else{ + //不存在,直接维护中 + return $this->error($chm['msg'].'!'); + } + } + //校验系统维护状态 end + + } +} \ No newline at end of file diff --git a/admin/application/index/controller/Test.php b/admin/application/index/controller/Test.php new file mode 100644 index 0000000..4b43c2b --- /dev/null +++ b/admin/application/index/controller/Test.php @@ -0,0 +1,137 @@ +addTemplate(); + //die; + $res = $obj->send('18290416033',json_encode(['code'=>1223])); + dump($res); + die; + + $api_cache_arr['aaa'][] = ['api_name'=>111,'doc_txt'=>222]; + $api_cache_arr['bb'][] = ['api_name'=>777,'doc_txt'=>777]; + $api_cache_arr['aaa'][] = ['api_name'=>666,'doc_txt'=>666]; + $api_cache_arr['ccc'][] = ['api_name'=>111,'doc_txt'=>222]; + $api_cache_arr['aaa'][] = ['api_name'=>555,'doc_txt'=>555]; + $api_cache_arr['ccc'][] = ['api_name'=>333,'doc_txt'=>333]; + + dump($api_cache_arr);die; + // 使用示例 + $color = $this->stringToColor("example string"); + //echo $color; // 输出颜色码 + + die; + $color_code = substr(md5('asdfasdf'),0,6); + echo '
test
';die; + +// 使用示例 + $color = $this->stringToColor("example string"); + echo $color; // 输出颜色码 + die; + // 配置您的讯飞应用信息 + $appId = 'd482af59'; + $apiKey = '0d20dab630904ad8676d9075375a1914'; + + // 创建事件循环 + $loop = Factory::create(); + + // 创建TcpConnector,它实现了ConnectorInterface + $tcpConnector = new TcpConnector($loop); + + // 使用TcpConnector创建SecureConnector + $secureConnector = new SecureConnector($tcpConnector, $loop); + + // 实时语音转写API地址 + //ws://8.130.29.83:2700 + //$url = 'ws://8.130.29.83:2700'; + $url = 'wss://rtasr.xfyun.cn/v1/ws'; + + // 计算签名 + $ts = time(); + $baseString = $appId . $ts; + $md5BaseString = md5($baseString); + $signa = base64_encode(hash_hmac('sha1', $md5BaseString, $apiKey, true)); + dump($signa); + + $params = [ + 'appid' => $appId, + 'ts' => $ts, + 'signa' => $signa, + 'lang' => 'zh-cn', // 中文普通话 + ]; + dump($params); + $str = ''; + $i = 0; + foreach ($params as $key => $value){ + if($i==count($params)-1){ + $str .= $key . '=' . $value ; + }else{ + + $str .= $key . '=' . $value . '&'; + } + $i++; + } + $encodedParams = urlencode($str); // 对查询参数进行URL编码 + // 构建WebSocket请求URL + $requestUrl = $url . '?' . $encodedParams; + dump($requestUrl); + // 使用SecureConnector连接到WebSocket服务器 + $secureConnector->connect($requestUrl)->then(function (ConnectionInterface $conn) { + echo "Connected to the WebSocket server\n"; + // ... 其他逻辑 ... + }, function ($error) { + // 连接失败处理 + echo "Connection error: " . $error->getMessage() . "\n"; + }); + + // 运行事件循环 + $loop->run(); + } + function callback($resource, $buffer, $length) { + global $audioQueue; + array_push($audioQueue, $buffer); + } + function testwss(){ + return view(); + } + function testwss2(){ + return view(); + } + + function buildApiDoc() + { + parent::buildApiDoc(); + } + + public function buildTablesConf() + { + parent::buildTablesConf(); // TODO: Change the autogenerated stub + } + public function clearCache() + { + parent::clearCache(); // TODO: Change the autogenerated stub + } +} \ No newline at end of file diff --git a/admin/public/api_docs/api_list.html b/admin/public/api_docs/api_list.html new file mode 100644 index 0000000..0184635 --- /dev/null +++ b/admin/public/api_docs/api_list.html @@ -0,0 +1,41 @@ + + + + + 接口文档 + + +
+ +
+
文档说明:
+
1、如果没有明确说明,提交请求均使用post
+
2、此接口文档不包含websocket接口
+
3、接口参数之间使用“/”符号隔开
+
4、此文档接口测试功能只针对普通post、get接口,不能测试文件上传或文件流
+
5、功能模块按照颜色分组
+
+
+ + + + + \ No newline at end of file diff --git a/admin/public/api_docs/api_list.md b/admin/public/api_docs/api_list.md new file mode 100644 index 0000000..fa43b7c --- /dev/null +++ b/admin/public/api_docs/api_list.md @@ -0,0 +1,5 @@ +# API 文档 +## 接口列表 +###### (ctrl+f 搜索)(如果更改了路由,请根据路由规则定位) +##### 请求域名:http://127.0.0.1:8080/ +##### 请求方式:POST(默认) diff --git a/admin/public/assets/js/backend/aicustomerservice.js b/admin/public/assets/js/backend/aicustomerservice.js new file mode 100644 index 0000000..24d567c --- /dev/null +++ b/admin/public/assets/js/backend/aicustomerservice.js @@ -0,0 +1,51 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'aicustomerservice/index' + location.search, + add_url: 'aicustomerservice/add', + edit_url: 'aicustomerservice/edit', + del_url: 'aicustomerservice/del', + multi_url: 'aicustomerservice/multi', + import_url: 'aicustomerservice/import', + table: 'aicustomerservice', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); diff --git a/admin/public/assets/js/backend/firmcustomer.js b/admin/public/assets/js/backend/firmcustomer.js index 8a83071..9f8e7fd 100644 --- a/admin/public/assets/js/backend/firmcustomer.js +++ b/admin/public/assets/js/backend/firmcustomer.js @@ -40,7 +40,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'status', title: __('Status'), searchList: {"yes":__('Status yes'),"no":__('Status no')}, formatter: Table.api.formatter.status}, {field: 'firmstoreprojectstwo.name', title: __('Firmstoreprojectstwo.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'firmcustomerorigin.name', title: __('Firmcustomerorigin.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'firmemployee.name', title: __('Firmemployee.name'), operate: 'LIKE'}, + {field: 'admin_id', title: __('责任人'), operate: 'LIKE'}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, diff --git a/front/application/index/controller/BasePublicController.php b/front/application/index/controller/BasePublicController.php index bdcae20..ca668fe 100644 --- a/front/application/index/controller/BasePublicController.php +++ b/front/application/index/controller/BasePublicController.php @@ -10,7 +10,6 @@ namespace app\index\controller; use think\Request; -use wanghua\general_utility_tools_php\framework\base\PublicController; use wanghua\general_utility_tools_php\tool\Tools; class BasePublicController extends BaseCommonController