diff --git a/README.md b/README.md
index 3c5c57b..334e144 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,16 @@
## 更新日志
+### v2.1
+
+- 增加网页全网搜功能
+- 对接微信对话功能
+- 更新优化Seo
+- 后台增加批量删除功能
+- 优化表格导入功能
+
+注:如何更新见文件夹updateLog/24.11.4
+
### v2
- UI改版:不再使用uniapp
diff --git a/app/admin/controller/Source.php b/app/admin/controller/Source.php
index 52c2713..08fcb24 100644
--- a/app/admin/controller/Source.php
+++ b/app/admin/controller/Source.php
@@ -153,14 +153,18 @@ class Source extends QfShop
if (!$this->pk_value) {
return jerr($this->pk . "必须填写", 400);
}
-
- //根据主键获取一行数据
- $item = $this->getRowByPk();
- if (empty($item)) {
- return jerr("数据查询失败", 404);
- }
- $this->model->where($this->pk, $this->pk_value)->delete();
+ if (isInteger($this->pk_value)){
+ //根据主键获取一行数据
+ $item = $this->getRowByPk();
+ if (empty($item)) {
+ return jerr("数据查询失败", 404);
+ }
+ $this->model->where($this->pk, $this->pk_value)->delete();
+ }else{
+ $list = explode(',', $this->pk_value);
+ $this->model->where($this->pk, 'in', $list)->delete();
+ }
return jok('删除成功');
}
@@ -192,7 +196,7 @@ class Source extends QfShop
if ($error) {
return $error;
}
- // try {
+ try {
$file = request()->file('file');
try {
validate(['file' => 'filesize:' . config("qfshop.upload_max_file") . '|fileExt:' . config("qfshop.upload_file_type")])
@@ -205,11 +209,12 @@ class Source extends QfShop
$extension = pathinfo($file_name, PATHINFO_EXTENSION);
if ($extension == 'csv') {
+ return jerr('转成xlsx格式吧');
$PHPReader = new \PHPExcel_Reader_CSV();
$encoding = $this->detectFileEncoding($file_name);
- if (!$encoding || strtoupper($encoding) == 'UTF-8') {
- $encoding = 'GBK'; // 尝试将其强制转为GBK
- }
+ // if (!$encoding || strtoupper($encoding) == 'UTF-8') {
+ // $encoding = 'GBK'; // 尝试将其强制转为GBK
+ // }
$PHPReader->setInputEncoding($encoding);
$PHPReader->setDelimiter(',');
} elseif ($extension == 'xlsx') {
@@ -284,9 +289,9 @@ class Source extends QfShop
} catch (ValidateException $e) {
return jerr($e->getMessage());
}
- // } catch (\Exception $error) {
- // return jerr('上传文件失败,请检查你的文件!');
- // }
+ } catch (\Exception $error) {
+ return jerr('上传文件失败,请检查你的文件!');
+ }
}
diff --git a/app/admin/controller/SourceCategory.php b/app/admin/controller/SourceCategory.php
index b36449a..852484a 100644
--- a/app/admin/controller/SourceCategory.php
+++ b/app/admin/controller/SourceCategory.php
@@ -22,11 +22,11 @@ class SourceCategory extends QfShop
];
$this->insertFields = [
//允许添加的字段列表
- "name","sort","status","image"
+ "name","sort","status","image","is_update"
];
$this->updateFields = [
//允许更新的字段列表
- "name","sort","status","image"
+ "name","sort","status","image","is_update"
];
$this->insertRequire = [
//添加时必须填写的字段
@@ -196,6 +196,19 @@ class SourceCategory extends QfShop
if (!$source_category_id) {
return jerr("ID参数必须填写", 400);
}
+
+
+ $d = [
+ "status" => 1,
+ "update_time" => time(),
+ ];
+ if(input("type") == 1){
+ $d = [
+ "is_update" => 0,
+ "update_time" => time(),
+ ];
+ }
+
if (isInteger($source_category_id)) {
//根据主键获取一行数据
$item = $this->model->where("source_category_id", $source_category_id)->field($this->selectDetail)->find();
@@ -204,17 +217,11 @@ class SourceCategory extends QfShop
}
//单个操作
$map = ["source_category_id" => $source_category_id];
- $this->model->where($map)->update([
- "status" => 1,
- "update_time" => time(),
- ]);
+ $this->model->where($map)->update($d);
} else {
//批量操作
$list = explode(',', $source_category_id);
- $this->model->where("source_category_id", 'in', $list)->update([
- "status" => 1,
- "update_time" => time(),
- ]);
+ $this->model->where("source_category_id", 'in', $list)->update($d);
}
return jok("禁用成功");
}
@@ -236,6 +243,18 @@ class SourceCategory extends QfShop
if (!$source_category_id) {
return jerr("ID参数必须填写", 400);
}
+
+ $d = [
+ "status" => 0,
+ "update_time" => time(),
+ ];
+ if(input("type") == 1){
+ $d = [
+ "is_update" => 1,
+ "update_time" => time(),
+ ];
+ }
+
if (isInteger($source_category_id)) {
//根据主键获取一行数据
$item = $this->model->where("source_category_id", $source_category_id)->field($this->selectDetail)->find();
@@ -244,17 +263,11 @@ class SourceCategory extends QfShop
}
//单个操作
$map = ["source_category_id" => $source_category_id];
- $this->model->where($map)->update([
- "status" => 0,
- "update_time" => time(),
- ]);
+ $this->model->where($map)->update($d);
} else {
//批量操作
$list = explode(',', $source_category_id);
- $this->model->where("source_category_id", 'in', $list)->update([
- "status" => 0,
- "update_time" => time(),
- ]);
+ $this->model->where("source_category_id", 'in', $list)->update($d);
}
return jok("启用成功");
}
diff --git a/app/api/controller/Chatbot.php b/app/api/controller/Chatbot.php
new file mode 100644
index 0000000..b1f4bfb
--- /dev/null
+++ b/app/api/controller/Chatbot.php
@@ -0,0 +1,382 @@
+key = base64_decode($this->encodingAESKey . "=");
+ }
+
+ public function index()
+ {
+ $encrypted = input('encrypted');
+
+ //解决全局搜时会多次接收相同消息导致多次请求的bug,原因未知
+ if(!empty($encrypted)){
+ if(Cache::get($encrypted) == 1){
+ return;
+ }
+ Cache::set($encrypted, 1, 600);
+ }
+
+ $msg = $this->decryptMessage($encrypted);
+
+
+ $msgtype = $msg['content']['msgtype']??'';
+ $message = $msg['content']['msg']??'';
+ if ($msgtype !== 'text' || empty($message)) {
+ if(Cache::get($msg['userid']) != 1){
+ $messages = "欢迎来到 ".$this->wName."!🍿🎬 这里是影迷的梦幻天堂,准备好享受每一部影视的精彩时刻吧!\n\n";
+ $messages .= "🔍 使用指南 🔍\n\n";
+ $messages .= "1. 搜剧命令\n";
+ $messages .= "回复 “搜剧+剧名”,免费获取最全的影视资源。\n";
+ $messages .= "示例:搜剧我被美女包围了\n\n";
+ $messages .= "2. 全网搜\n";
+ $messages .= "回复 “全网搜+关键词”,快速找到全网资源!\n";
+ $messages .= "示例:全网搜学剪辑\n\n";
+ $messages .= "赶快准备好你的爆米花,和我们一起开启下一场视觉盛宴吧!🎥";
+
+ $this->sendMessage($msg, $messages);
+ }
+ Cache::set($msg['userid'], 1, 604800);
+ }
+ // 检查用户消息内容中开头第一个字是否包含“搜”关键字
+ if (strncmp($message, '搜', 1) === 0 || strncmp($message, '全网搜', 1) === 0) {
+
+ if(strncmp($message, '全网搜', 1) === 0){
+ $list = [];
+ // 去除“全网搜”关键字,提取用户输入的剧名
+ $newString = preg_replace('/^全网搜/u', '', $message);
+ }else{
+ // 去除“搜剧”关键字,提取用户输入的剧名
+ $newString = preg_replace('/^搜剧|^搜/u', '', $message);
+
+ // 实例化资源模型,并搜索匹配的剧名
+ $map['page_size'] = 5;
+ $map['title'] = $newString;
+ $SourceModel = new SourceModel();
+ $result = $SourceModel->getList($map);
+ $list = $result['items']??[];
+ }
+
+
+
+ if(empty($list)){
+ //系统没有资源去全网搜
+ $this->sendMessage($msg, "正在深入搜索,请稍等...");
+
+ $list = $this->Qsearch($newString);
+ }
+
+ $content = "🔍 ".$newString."丨搜索结果";
+ $is_times = 0;
+ if (!empty($list)) {
+ foreach ($list as $item) {
+ $content = $content . "\n";
+ if(!empty($item['is_time']) && $item['is_time'] == 1){
+ $content = $content . "\n🌐️ " . $item['title'] . "\n" . $item['url'] . "";
+ $is_times++;
+ }else{
+ $content = $content . "\n" . $item['title'] . "\n" . $item['url'] . "";
+ }
+ }
+ $content = $content . "\n";
+ if($is_times>0){
+ $content = $content . "\n🌐️ 资源来源网络,30分钟后删除";
+ }else if(!empty($newString)){
+ $content = $content . "\n 不是短剧?请尝试:全网搜".$newString."";
+ }
+ $content = $content . "\n ------------------------------------------------";
+ $content = $content . "\n 欢迎观看!如果喜欢可以喊你的朋友一起来哦";
+ } else {
+ // 如果没有找到匹配的剧名,提示用户减少关键词尝试搜索
+ $content = $content . "\n";
+ $content = $content . "\n 未找到,可换个关键词尝试哦~";
+ $content = $content . "\n ⚠️宁少写,不多写、错写~";
+ }
+
+ $this->sendMessage($msg, $content);
+ }
+
+
+
+ }
+
+ private function Qsearch($newString)
+ {
+ $list = [];
+ $urlData = array(
+ 'title' => $newString,
+ );
+ $res = curlHelper(Request::domain()."/api/other/all_search", "POST", $urlData)['body'];
+ $res = json_decode($res, true);
+
+ if($res['code'] === 200){
+ $list = $res['data']??[];
+ }
+
+ return $list;
+ }
+
+ // 解密消息
+ private function decryptMessage($encrypted)
+ {
+ $result = $this->decrypt($encrypted,$this->appId);
+ if ($result[0] !== 0) {
+ return [];
+ }
+ return json_decode(json_encode(simplexml_load_string($result[1])), true);
+ }
+
+ // 发送消息
+ private function sendMessage($msg, $message)
+ {
+ $data = $this->createXmlMessage($msg, $message);
+ $result = $this->encrypt($data,$this->appId);
+
+ if ($result[0] !== 0) {
+ return;
+ }
+
+ $this->sendPostRequest("https://chatbot.weixin.qq.com/openapi/sendmsg/".$this->token, [
+ 'encrypt' => $result[1],
+ ]);
+ }
+
+ // 创建 XML 消息
+ private function createXmlMessage($msg, $message)
+ {
+ return '
+ {$key+1} + {$vo.title} +
+ + {/volist} +