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.

138 lines
3.5 KiB

<?php
namespace app\base\controller\wechat\admin;
use app\BaseController;
use app\base\model\wechat\WechatNews;
use app\base\model\wechat\WechatReply;
class Reply extends BaseController
{
/**
* 获取微信自动回复
* @date 2020-09-16
*/
public function lists()
{
$param = input('post.');
$wechat_reply_model = new WechatReply();
$where = [
['uid', '=', UID]
];
if(!empty($param['keyword'])){
$where[] = ['name', 'like', '%' . $param['keyword'] . '%'];
}
$wechat_reply_list = $wechat_reply_model->getDataList($where, $param['page'],'*', 'id desc', $param['limit']);
$rdata = [
'list' => $wechat_reply_list
];
return sendSuccessMessage($rdata);
}
/**
* 微信自动回复编辑
* @param string $id 数据ID
* @date 2020-09-24
*/
public function dataAdd()
{
$param = input('post.');
$wechat_reply_model = new WechatReply();
$data = [
'id'=>$param['id'],
'uid'=>UID,
'trigger_type'=>$param['trigger_type'],
'name'=>$param['trigger_type'] == 1 ? $param['name'] : '',
'matching_type'=>$param['trigger_type'] == 1 ? $param['matching_type'] : 1,
'type'=>$param['type'],
];
if($param['type'] == 'text'){
$data['content'] = [
'text' => $param['text_content']
];
}else if($param['type'] == 'image'){
$data['content'] = [
'image_url' => $param['image_url']
];
}else if($param['type'] == 'voice'){
$data['content'] = [
'voice_url' => $param['voice_url']
];
}else if($param['type'] == 'video'){
$data['content'] = [
'title' => $param['video_title'],
'description' => $param['video_description'],
'video_url' => $param['video_url']
];
}else if($param['type'] == 'music'){
$data['content'] = [
'title' => $param['music_title'],
'description' => $param['music_description'],
'music_url' => $param['music_url'],
'hq_music_url'=>$param['music_url'],
'thumb_url'=>$param['thumb_url']
];
}else if($param['type'] == 'news'){
$data['content'] = [
'news_id' => $param['news_id']
];
}
$res = $wechat_reply_model->dataUpdate($data);
if(!$res){
return sendErrorMessage(4001,'操作失败');
}
return sendSuccessMessage([],'操作成功');
}
/**
* 删除微信自动回复
* @param string $id 数据ID
* @date 2020-09-16
*/
public function dataDel()
{
$id = input('param.id');
$wechat_reply_model = new WechatReply();
$res = $wechat_reply_model->dataDel($id);
if (!$res) {
return sendErrorMessage(4001, '删除失败');
}
return sendSuccessMessage([], '删除成功');
}
/**
* 获取图文消息列表
* @param string $id 数据ID
* @date 2020-09-24
*/
public function newsList()
{
$wechat_news_model = new WechatNews();
$news_list = $wechat_news_model->getAllData([
['uid', '=', UID]
]);
$rdata = [
'list' => $news_list
];
return sendSuccessMessage($rdata);
}
}