This commit is contained in:
2025-03-25 15:41:52 +08:00
parent e0f8eb7b14
commit 3b40995173
24 changed files with 1143 additions and 14 deletions

View File

@@ -0,0 +1,71 @@
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* AI客服管理
*
* @icon fa fa-circle-o
*/
class Aicustomerservice extends Backend
{
/**
* Aicustomerservice模型对象
* @var \app\admin\model\Aicustomerservice
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->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();
}
}

View File

@@ -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());

View File

@@ -0,0 +1,8 @@
<?php
return [
'Id' => 'ID',
'Name' => 'AI客服名称',
'Server_url' => '服务地址',
'Apikey' => 'apikey'
];

View File

@@ -0,0 +1,40 @@
<?php
namespace app\admin\model;
use think\Model;
class Aicustomerservice extends Model
{
// 表名
protected $name = 'aicustomerservice';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}

View File

@@ -60,6 +60,6 @@ class Firmcustomer extends Model
public function firmemployee()
{
return $this->belongsTo('Firmemployee', 'firmemployee_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace app\admin\validate;
use think\Validate;
class Aicustomerservice extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}

View File

@@ -0,0 +1,27 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Server_url')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-server_url" class="form-control" name="row[server_url]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Apikey')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-apikey" class="form-control" name="row[apikey]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
</div>
</div>
</form>

View File

@@ -0,0 +1,27 @@
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Server_url')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-server_url" class="form-control" name="row[server_url]" type="text" value="{$row.server_url|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Apikey')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-apikey" class="form-control" name="row[apikey]" type="text" value="{$row.apikey|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
</div>
</div>
</form>

View File

@@ -0,0 +1,29 @@
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('aicustomerservice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('aicustomerservice/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('aicustomerservice/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('aicustomerservice/edit')}"
data-operate-del="{:$auth->check('aicustomerservice/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -76,7 +76,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Firmemployee_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firmemployee_id" data-rule="required" data-source="admin/index"
<input id="c-firmemployee_id" data-rule="required" data-source="auth/admin/index"
data-field="nickname"
class="form-control selectpage" name="row[firmemployee_id]" type="text" value="">
</div>
@@ -85,7 +85,7 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Responsible_pm')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-responsible_pm" data-rule="required"
data-source="admin/index" class="form-control selectpage"
data-source="auth/admin/index" class="form-control selectpage"
data-field="nickname"
name="row[responsible_pm]" type="text" value="">
</div>

View File

@@ -67,7 +67,7 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Firmemployee_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firmemployee_id" data-rule="required"
data-source="admin/index" class="form-control selectpage"
data-source="auth/admin/index" class="form-control selectpage"
data-field="nickname"
name="row[firmemployee_id]" type="text" value="{$row.firmemployee_id|htmlentities}">
</div>
@@ -75,7 +75,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Responsible_pm')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-responsible_pm" data-rule="required" data-source="admin/index"
<input id="c-responsible_pm" data-rule="required" data-source="auth/admin/index"
data-field="nickname"
class="form-control selectpage" name="row[responsible_pm]" type="text"
value="{$row.responsible_pm|htmlentities}">

View File

@@ -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
* authorwh
*/
function getList(){

View File

@@ -0,0 +1,39 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/25} {14:27}
*/
namespace app\api\controller;
//微信群
use think\Db;
use wanghua\general_utility_tools_php\Mmodel;
use wanghua\general_utility_tools_php\tool\Tools;
class Wxgroup extends BaseApiAuthController
{
/**
* desc获取某群的紧急联系人
* authorwh
*/
function getEmergencyContact()
{
return Mmodel::catchJson(function (){
$chatroom_id = input('chatroom_id');//52468523601@chatroom
if(empty($chatroom_id)){
return Tools::set_fail('群id不能为空');
}
$rel_group = Db::table('fa_firmcustomer')
->where('rel_group',$chatroom_id)
->value('rel_group');
return Tools::set_ok('ok',[
'emergency_contact_wxid'=>$rel_group
]);
});
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* description
* authorwh
* email
* createTime{2021/6/21} {15:02}
*/
namespace app\common\model;
use think\Db;
use think\Model;
class BaseModel extends Model
{
protected static $log_file = '';//日志文件名
/**
* desc
* authorwh
* @param $self_table
* @return \think\db\Query
*/
protected static function tab($self_table){
return Db::table($self_table);
}
}

View File

@@ -0,0 +1,421 @@
<?php
namespace app\common\model;
class TabConf
{
/**
* ai分析药品、影像、病历结果
*/
static $___fa_drugs_images_medical_task = '___fa_drugs_images_medical_task';
/**
* AI药品、影像、病历上传任务记录
*/
static $__fa_drugs_images_medical_result = '__fa_drugs_images_medical_result';
/**
* 基本信息图片上传并AI分析结果
*/
static $__fa_hbruser_drugs_images_medical_report = '__fa_hbruser_drugs_images_medical_report';
/**
* 管理员表
*/
static $fa_admin = 'fa_admin';
/**
* 管理员日志表
*/
static $fa_admin_log = 'fa_admin_log';
/**
* 地区表
*/
static $fa_area = 'fa_area';
/**
* 附件表
*/
static $fa_attachment = 'fa_attachment';
/**
* 分组表
*/
static $fa_auth_group = 'fa_auth_group';
/**
* 权限分组表
*/
static $fa_auth_group_access = 'fa_auth_group_access';
/**
* 节点表
*/
static $fa_auth_rule = 'fa_auth_rule';
/**
* 分类表
*/
static $fa_category = 'fa_category';
/**
* 在线命令表
*/
static $fa_command = 'fa_command';
/**
* 系统配置
*/
static $fa_config = 'fa_config';
/**
* 登录设备(一个医生有多个病历,一个医生同时只有一个客户端)
*/
static $fa_device = 'fa_device';
/**
* 基本信息图片上传和AI分析结果
*/
static $fa_drugs_images_medical_result = 'fa_drugs_images_medical_result';
/**
* 任务处理进度记录
*/
static $fa_drugs_images_medical_task = 'fa_drugs_images_medical_task';
/**
* 邮箱验证码表
*/
static $fa_ems = 'fa_ems';
/**
* 估量-ai处理结果
*/
static $fa_guliang_ai_deal_result = 'fa_guliang_ai_deal_result';
/**
* 估量-问答记录
*/
static $fa_guliangqarecord = 'fa_guliangqarecord';
/**
* 估量-问答配置
*/
static $fa_guliangquestion = 'fa_guliangquestion';
/**
* 估量-用户
*/
static $fa_gulianguser = 'fa_gulianguser';
/**
* 基本信息图片上传和AI分析结果
*/
static $fa_hbruser_drugs_images_medical = 'fa_hbruser_drugs_images_medical';
/**
* 基本信息图片上传并AI分析结果
*/
static $fa_hbruser_drugs_images_medical_report = 'fa_hbruser_drugs_images_medical_report';
/**
* 任务处理进度记录
*/
static $fa_hbruser_drugs_images_medical_task = 'fa_hbruser_drugs_images_medical_task';
/**
* 短信发送记录
*/
static $fa_hdr_sms_record = 'fa_hdr_sms_record';
/**
* 管理员
*/
static $fa_hdradmin = 'fa_hdradmin';
/**
* 科室
*/
static $fa_hdrdepartment = 'fa_hdrdepartment';
/**
* 医生账户信息
*/
static $fa_hdrdoctorusers = 'fa_hdrdoctorusers';
/**
* 统一随访记录
*/
static $fa_hdrfollowup = 'fa_hdrfollowup';
/**
* 随访模板
*/
static $fa_hdrfollowuptemplate = 'fa_hdrfollowuptemplate';
/**
* 患者健康洞察
*/
static $fa_hdrhealth_insight = 'fa_hdrhealth_insight';
/**
* 问诊报告存档疼痛科、听译、h5问诊统一存放一个基本信息对应一个报告
*/
static $fa_hdrmedical_report = 'fa_hdrmedical_report';
/**
* 打开对话窗口记录(同时向患者端发送当前对话患者信息)
*/
static $fa_hdropen_chat_room_record = 'fa_hdropen_chat_room_record';
/**
* 人格测试结果
*/
static $fa_hdrpersonalitytest = 'fa_hdrpersonalitytest';
/**
* 科室问卷答案
*/
static $fa_hdrquestionnaireanswer = 'fa_hdrquestionnaireanswer';
/**
* 科室问卷问题(一个问题对应多个答案)
*/
static $fa_hdrquestionnairequestion = 'fa_hdrquestionnairequestion';
/**
* 患者挂号列表(可重复挂号)
*/
static $fa_hdrregister = 'fa_hdrregister';
/**
* 用户答题记录
*/
static $fa_hdruseranswerrecord = 'fa_hdruseranswerrecord';
/**
* 统一问诊用户基本信息
*/
static $fa_hdruserbaseinfo = 'fa_hdruserbaseinfo';
/**
* 基本信息图片上传并AI分析结果
*/
static $fa_hdruserbaseinfo_upload = 'fa_hdruserbaseinfo_upload';
/**
* H5用户
*/
static $fa_hdrusersh5 = 'fa_hdrusersh5';
/**
* 智语医助-设备关联表
*/
static $fa_healdevicerelation = 'fa_healdevicerelation';
/**
* 医生新消息
*/
static $fa_message = 'fa_message';
/**
* 短信验证码表
*/
static $fa_sms = 'fa_sms';
/**
* 系统维护配置,支持模块、控制器、方法。全等匹配。
*/
static $fa_sys_maintain_config = 'fa_sys_maintain_config';
/**
* 测试表
*/
static $fa_test = 'fa_test';
/**
* 听译优医助手对话记录
*/
static $fa_tingyiueassistantchathis = 'fa_tingyiueassistantchathis';
/**
* 疼痛科聊天历史
*/
static $fa_tt_chathistory = 'fa_tt_chathistory';
/**
* 随访记录(数智人医生)
*/
static $fa_tt_followup = 'fa_tt_followup';
/**
* 疼痛科自由对话聊天历史
*/
static $fa_tt_free_chathistory = 'fa_tt_free_chathistory';
/**
* 疼痛科病历报告(听译问诊)(一个基本信息对应一个报告)
*/
static $fa_tt_medical_report = 'fa_tt_medical_report';
/**
* 疼痛科用户基本信息
*/
static $fa_tt_userbaseinfo = 'fa_tt_userbaseinfo';
/**
* 疼痛科用户
*/
static $fa_tt_users = 'fa_tt_users';
/**
* 听译-聊天历史
*/
static $fa_ty_chathistory = 'fa_ty_chathistory';
/**
* 随访记录(听译助手)
*/
static $fa_ty_followup = 'fa_ty_followup';
/**
* 听译-病历报告(听译问诊)(一个基本信息对应一个报告)
*/
static $fa_ty_medical_report = 'fa_ty_medical_report';
/**
* 听译问诊-患者病历信息
*/
static $fa_ty_userbaseinfo = 'fa_ty_userbaseinfo';
/**
* 听译问诊-患者病历信息
*/
static $fa_ty_usermedicalrecord = 'fa_ty_usermedicalrecord';
/**
* 听译-医生账号
*/
static $fa_ty_users = 'fa_ty_users';
/**
* 会员表
*/
static $fa_user = 'fa_user';
/**
* 会员组表
*/
static $fa_user_group = 'fa_user_group';
/**
* 会员余额变动表
*/
static $fa_user_money_log = 'fa_user_money_log';
/**
* 会员规则表
*/
static $fa_user_rule = 'fa_user_rule';
/**
* 会员积分变动表
*/
static $fa_user_score_log = 'fa_user_score_log';
/**
* 会员Token表
*/
static $fa_user_token = 'fa_user_token';
/**
* 用户
*/
static $fa_users = 'fa_users';
/**
* 用户操作日志
*/
static $fa_users_operate_log = 'fa_users_operate_log';
/**
* 版本表
*/
static $fa_version = 'fa_version';
/**
* 系统杂项配置
*/
static $fa_zc_sundry_config = 'fa_zc_sundry_config';
}

View File

@@ -0,0 +1,100 @@
<?php
/*
* description
* authorwh
* email
* createTime{2022/5/4} {9:12}
*/
namespace app\index\controller;
use app\apidata\Config;
use app\common\consts\LogDir;
use app\common\model\TabConf;
use app\index\model\WechatUserModel;
use think\Controller;
use think\Db;
use think\Request;
use wanghua\general_utility_tools_php\framework\base\OuterController;
use wanghua\general_utility_tools_php\tool\Tools;
class BaseAuthController extends BaseCommonController
{
public function __construct(Request $request = null)
{
parent::__construct($request);
//首页提示语
$this->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
* authorwh
* @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);
}
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* description
* authorwh
* email
* createTime{2023/1/21} {16:22}
*/
namespace app\index\controller;
use app\apidata\Config;
use app\common\model\TabConf;
use think\Controller;
use think\Db;
use think\Request;
use wanghua\general_utility_tools_php\framework\BaseController;
use wanghua\general_utility_tools_php\tool\Tools;
class BaseCommonController extends BaseController
{
function __construct(Request $request = null)
{
parent::__construct($request);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/*
* description
* authorwh
* email
* createTime{2022/5/4} {9:39}
*/
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
{
public function __construct(Request $request = null)
{
parent::__construct($request);
//校验系统维护状态 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
}
}

View File

@@ -0,0 +1,137 @@
<?php
/*
* description
* authorwh
* email
* createTime{2023/11/20} {10:28}
*/
namespace app\index\controller;
use app\api\logic\AudioRevertLogic;
use React\EventLoop\Factory;
use React\Socket\TcpConnector;
use React\Socket\SecureConnector;
use React\Socket\ConnectionInterface;
use wanghua\general_utility_tools_php\sms\AliSms;
/**
* @deprecated
*/
class Test extends BasePublicController
{
function test()
{
$config = config('sms_config');
$obj = new AliSms($config,$config['sms_sign_name'],$config['sms_template_code']);
//$obj->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 '<div style="background-color:'.$color_code.'">test</div>';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
}
}

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>接口文档</title>
</head>
<body>
<div>
<style>
.txt-lf{text-align: left}
</style>
<div style="width: 50%;margin: 0 auto;color: red;text-align: center;">
<div class="txt-lf">文档说明:</div>
<div class="txt-lf">1、如果没有明确说明提交请求均使用post</div>
<div class="txt-lf">2、此接口文档不包含websocket接口</div>
<div class="txt-lf">3、接口参数之间使用“/”符号隔开</div>
<div class="txt-lf">4、此文档接口测试功能只针对普通post、get接口不能测试文件上传或文件流</div>
<div class="txt-lf">5、功能模块按照颜色分组</div>
</div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="/static/common/js/marked.min.js"></script>
<script>
$(function() {
//加载markdown
DocObject.markdown_content();
});
let DocObject = {
markdown_content(){
$('.markdown_content').each(function(k,ele) {
$(ele).html(marked.parse($(ele).html()));
});
},
}
</script>
</html>

View File

@@ -0,0 +1,5 @@
# API 文档
## 接口列表
###### ctrl+f 搜索)(如果更改了路由,请根据路由规则定位)
##### 请求域名http://127.0.0.1:8080/
##### 请求方式POST默认

View File

@@ -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;
});

View File

@@ -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,