You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
281 lines
9.8 KiB
281 lines
9.8 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\member\controller;
|
|
use think\Db;
|
|
use think\Request;
|
|
use think\Validate;
|
|
|
|
class Common extends Base{
|
|
protected $cates=[
|
|
"1"=>"深圳市文化金融服务中心",
|
|
"2"=>"文化金融(艺术资产)交易中心",
|
|
"3"=>"国有业务",
|
|
"7"=>"区域合作中心",
|
|
"8"=>"乡村振兴(古建资产管理)计划中心",
|
|
"10"=>"沉浸式要素交易平台"
|
|
];
|
|
public function contactus(){
|
|
return $this->view->fetch();
|
|
}
|
|
public function feedback(){
|
|
|
|
if(request()->isPost()){
|
|
$rule = [
|
|
'tel'=>'require',
|
|
'email'=>'require',
|
|
'information'=>'require',
|
|
'__feed__' =>'require|token:__feed__'
|
|
];
|
|
$message = [
|
|
'tel'=>'手机号不能为空',
|
|
'email'=>'邮箱不能为空',
|
|
'information'=>'内容不能为空',
|
|
'__feed__.require'=>'令牌缺失'
|
|
];
|
|
|
|
$validate=new Validate($rule,$message);
|
|
$result=$validate->check(input());
|
|
$error='';
|
|
if(!$result)$error=$validate->getError();
|
|
|
|
$token=request()->token('__feed__');
|
|
if(!empty($error)){
|
|
return $this->error($error,'',['token'=>$token]);
|
|
}
|
|
$data =[];
|
|
$data['tel'] = input('post.tel','');
|
|
$data['email'] = input('post.email','');
|
|
$data['platform'] ="深圳文交所会员中心";
|
|
$data['information'] = input('post.information','');
|
|
$data['kind']=2;
|
|
$data['create_time'] = time();
|
|
$query=Db::name('feedback')->insert($data);
|
|
|
|
return $this->success("提交成功",'',['token'=>$token]);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
public function chatbot(){
|
|
$user=session('muser');
|
|
$kind=input('kind');
|
|
if(!$user){
|
|
return $this->redirect("login/index",['jump'=>urlencode(url('common/chatbot',['kind'=>$kind],false))]);
|
|
}
|
|
$cates=$this->cates;
|
|
$sid=uniqid("chat");
|
|
if(isset($user['SessionId'])&&$user['SessionId']){
|
|
$sid=$user['SessionId'];
|
|
}
|
|
$this->assign("sid",$sid);
|
|
$this->assign("cates",$cates);
|
|
$this->assign("kind",$kind);
|
|
return $this->view->fetch();
|
|
}
|
|
public function ajaxlog(){
|
|
$user=session('muser');
|
|
$kind=input('kind');
|
|
if(!$user){
|
|
return $this->error("查询失败");
|
|
}
|
|
$where=['uid'=>$user['member_list_id']];
|
|
if(is_null($kind)){
|
|
$where['kind']=['exp','is null'];
|
|
}else{
|
|
$where['kind']=$kind;
|
|
}
|
|
$log=db('asklog')->where($where)->order('id desc')->limit(1)->find();
|
|
$logs=[];
|
|
if($log){
|
|
$logs=unserialize($log['content']);
|
|
if(count($logs)){
|
|
foreach ($logs as $k=>$vo){
|
|
$logs[$k]['time']=date("H:i",$vo['time']);
|
|
}
|
|
}
|
|
}
|
|
return $this->success("查询成功",'',$logs);
|
|
}
|
|
/**
|
|
* 问题列表
|
|
*/
|
|
public function knowledges(){
|
|
$uid=session('mhid');
|
|
$kind=input('kind');
|
|
if(!$uid){
|
|
return $this->redirect("login/index",['jump'=>url('common/chatbot',['kind'=>$kind])]);
|
|
}
|
|
$cid=input('cid');
|
|
$list=db('news')->where(['n_cid'=>$cid,'n_kind'=>18,'n_status'=>1])->select();
|
|
|
|
return $this->success("查询成功","",$list);
|
|
}
|
|
/**
|
|
* 问题详情
|
|
*/
|
|
public function answer(){
|
|
$uid=session('mhid');
|
|
$kind=input('kind');
|
|
if(!$uid){
|
|
return $this->redirect("login/index",['jump'=>url('common/chatbot',['kind'=>$kind])]);
|
|
}
|
|
$cid=input('kid');
|
|
$list=db('news')->where(['n_id'=>$cid,'n_kind'=>18,'n_status'=>1])->find();
|
|
|
|
return $this->success("查询成功","",$list);
|
|
}
|
|
public function history(){
|
|
$uid=session('mhid');
|
|
$kind=input('kind');
|
|
if(!$uid){
|
|
return $this->redirect("login/index",['jump'=>url('common/chatbot',['kind'=>$kind])]);
|
|
}
|
|
$ques=input("ques");
|
|
$ans=isset($_POST['ans'])?$_POST['ans']:'';
|
|
$type=input("type");
|
|
$where=['uid'=>$uid];
|
|
if($kind!="")$where['kind']=$kind;
|
|
$log=db('asklog')->where($where)->order('id desc')->limit(1)->find();
|
|
$content=[];
|
|
if($log){
|
|
$content=unserialize($log['content']);
|
|
}
|
|
array_push($content,['ques'=>$ques,'ans'=>$ans,'type'=>$type,'time'=>time()]);
|
|
$content=serialize($content);
|
|
|
|
if($log){
|
|
db('asklog')->where(['uid'=>$uid])->update(['content'=>$content,'flag'=>1]);
|
|
}else{
|
|
$data=[];
|
|
$data['uid']=$uid;
|
|
$data['kind']=$kind;
|
|
$data['flag']=1;
|
|
$data['create_time']=time();
|
|
$data['update_time']=time();
|
|
$data['content']=$content;
|
|
db('asklog')->insert($data);
|
|
}
|
|
return $this->success("提交成功");
|
|
}
|
|
public function reply(){
|
|
$uid=session('mhid');
|
|
$kind=input('kind');
|
|
if(!$uid){
|
|
return $this->redirect("login/index",['jump'=>url('common/chatbot',['kind'=>$kind])]);
|
|
}
|
|
$word=input('word');
|
|
$sid=input('sid');
|
|
$cateid=input('cateid');
|
|
if(empty($word))$this->error("请输入问题");
|
|
|
|
$reply=['type'=>'Recommend','list'=>$this->cates];
|
|
if($kind==''){
|
|
$id='';
|
|
foreach ($this->cates as $k=>$row){
|
|
if(strpos($row,$word)!=false){
|
|
$id=$k;
|
|
break;
|
|
}
|
|
}
|
|
if($id){
|
|
$list=db('news')->where(['n_cid'=>$id,'n_kind'=>18,'n_status'=>1])->select();
|
|
$reply=['type'=>'Knowledge','list'=>$list];
|
|
}
|
|
$check=db('news')->where(['n_title|n_content'=>['like',['%'.$word.'%','%'.$word,$word.'%']],'n_kind'=>18,'n_status'=>1])->select();
|
|
if($check){
|
|
$reply=['type'=>'Text','list'=>$list];
|
|
}
|
|
}
|
|
return $this->success("查询成功","",$reply);
|
|
}
|
|
public function license(){
|
|
if(request()->isPost()){
|
|
$rule = [
|
|
'comname'=>'require',
|
|
'contact'=>'require',
|
|
'__license__' =>'require|token:__license__'
|
|
];
|
|
$message = [
|
|
'comname'=>'企业名称不能为空',
|
|
'contact'=>'联系方式不能为空',
|
|
'__license__.require'=>'令牌缺失'
|
|
];
|
|
|
|
$validate=new Validate($rule,$message);
|
|
$result=$validate->check(input());
|
|
$error='';
|
|
if(!$result)$error=$validate->getError();
|
|
|
|
$token=request()->token('__license__');
|
|
if(!empty($error)){
|
|
return $this->error($error,'',['token'=>$token]);
|
|
}
|
|
$kind=input('kind');
|
|
$data = array();
|
|
$data['comname'] = input('post.comname','');
|
|
$gpdate=$_POST['gpdate'];
|
|
$data['gpdate'] =implode(",", $gpdate);
|
|
$data['contact'] = input('post.contact','');
|
|
$data['create_time'] = time();
|
|
$query=Db::name('license')->insert($data);
|
|
|
|
return $this->success("提交成功",'',['token'=>$token]);
|
|
}
|
|
$month=date("m");
|
|
$months=[1=>"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];
|
|
$arrs=[];
|
|
foreach ($months as $k=>$vo){
|
|
if($month<$k)$arrs[$k]=$vo;
|
|
}
|
|
if($month==11){
|
|
$arrs[1]="一月";
|
|
$arrs[2]="二月";
|
|
}
|
|
if($month==12){
|
|
$arrs=[1=>"一月","二月","三月"];
|
|
}
|
|
$this->assign("months",$arrs);
|
|
return $this->view->fetch();
|
|
}
|
|
public function join(){
|
|
if(request()->isPost()){
|
|
$rule = [
|
|
'name'=>'require',
|
|
'contact'=>'require',
|
|
'phone'=>'require',
|
|
'__join__' =>'require|token:__join__'
|
|
];
|
|
$message = [
|
|
'name'=>'名字不能为空',
|
|
'contact'=>'联系人不能为空',
|
|
'phone'=>'联系电话不能为空',
|
|
'__join__.require'=>'令牌缺失'
|
|
];
|
|
|
|
$validate=new Validate($rule,$message);
|
|
$result=$validate->check(input());
|
|
$error='';
|
|
if(!$result)$error=$validate->getError();
|
|
|
|
$token=request()->token('__join__');
|
|
if(!empty($error)){
|
|
return $this->error($error,'',['token'=>$token]);
|
|
}
|
|
$kind=input('kind');
|
|
$data = array();
|
|
$data['name'] = input('post.name','');
|
|
$data['contact'] = input('post.contact','');
|
|
$data['phone'] = input('post.phone','');
|
|
$data['create_time'] = time();
|
|
$query=Db::name('joinus')->insert($data);
|
|
|
|
return $this->success("提交成功",'',['token'=>$token]);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
}
|
|
|