From 1e1b65684ddd6b16c71d967f4838a1614242251e Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Thu, 25 Sep 2025 17:52:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A6=E5=AE=A2=E5=AE=9D=20=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=AE=A1=E7=90=86=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/chukebao/config/route.php | 44 ++ .../chukebao/controller/ContentController.php | 631 ++++++++++++++++++ .../controller/FollowUpController.php | 3 +- .../chukebao/controller/MessageController.php | 4 +- .../controller/QuestionsController.php | 3 +- .../chukebao/controller/ToDoController.php | 4 +- .../controller/TokensRecordController.php | 4 +- .../controller/WechatChatroomController.php | 3 +- .../controller/WechatFriendController.php | 5 +- .../controller/WechatGroupController.php | 30 + .../application/chukebao/model/Keywords.php | 17 + .../application/chukebao/model/Material.php | 17 + .../chukebao/model/SensitiveWord.php | 17 + 13 files changed, 772 insertions(+), 10 deletions(-) create mode 100644 Server/application/chukebao/controller/ContentController.php create mode 100644 Server/application/chukebao/controller/WechatGroupController.php create mode 100644 Server/application/chukebao/model/Keywords.php create mode 100644 Server/application/chukebao/model/Material.php create mode 100644 Server/application/chukebao/model/SensitiveWord.php diff --git a/Server/application/chukebao/config/route.php b/Server/application/chukebao/config/route.php index 090ddec1..6a78198f 100644 --- a/Server/application/chukebao/config/route.php +++ b/Server/application/chukebao/config/route.php @@ -31,6 +31,12 @@ Route::group('v1/', function () { Route::get('details', 'app\chukebao\controller\MessageController@details'); // 消息详情 }); + //微信分组 + Route::get('wechatGroup/list', 'app\chukebao\controller\WechatGroupController@getList'); // 微信分组 + + + + //AI相关 Route::group('ai/', function () { //问答 @@ -84,6 +90,44 @@ Route::group('v1/', function () { Route::get('list', 'app\chukebao\controller\TokensRecordController@getList'); }); + + + //内容管理 + Route::group('content/', function () { + //素材管理 + Route::group('material/', function () { + Route::get('list', 'app\chukebao\controller\ContentController@getMaterial'); + Route::post('add', 'app\chukebao\controller\ContentController@createMaterial'); + Route::get('details', 'app\chukebao\controller\ContentController@detailsMaterial'); + Route::get('del', 'app\chukebao\controller\ContentController@delMaterial'); + Route::post('update', 'app\chukebao\controller\ContentController@updateMaterial'); + }); + + //违禁词管理 + Route::group('sensitiveWord/', function () { + Route::get('list', 'app\chukebao\controller\ContentController@getSensitiveWord'); + Route::post('add', 'app\chukebao\controller\ContentController@createSensitiveWord'); + Route::get('details', 'app\chukebao\controller\ContentController@detailsSensitiveWord'); + Route::get('del', 'app\chukebao\controller\ContentController@delSensitiveWord'); + Route::post('update', 'app\chukebao\controller\ContentController@updateSensitiveWord'); + Route::get('setStatus', 'app\chukebao\controller\ContentController@setSensitiveWordStatus'); + }); + + + //关键词管理 + Route::group('keywords/', function () { + Route::get('list', 'app\chukebao\controller\ContentController@getKeywords'); + Route::post('add', 'app\chukebao\controller\ContentController@createKeywords'); + Route::get('details', 'app\chukebao\controller\ContentController@detailsKeywords'); + Route::get('del', 'app\chukebao\controller\ContentController@delKeywords'); + Route::post('update', 'app\chukebao\controller\ContentController@updateKeywords'); + Route::get('setStatus', 'app\chukebao\controller\ContentController@setKeywordStatus'); + }); + }); + + + + }); diff --git a/Server/application/chukebao/controller/ContentController.php b/Server/application/chukebao/controller/ContentController.php new file mode 100644 index 00000000..e496bfa5 --- /dev/null +++ b/Server/application/chukebao/controller/ContentController.php @@ -0,0 +1,631 @@ +request->param('page', 1); + $limit = $this->request->param('limit', 10); + $keyword = $this->request->param('keyword', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + $query = Material::where(['userId' => $userId,'companyId' => $companyId,'isDel' => 0]) + ->order('id desc'); + if (!empty($keyword)){ + $query->where('title', 'like', '%'.$keyword.'%'); + } + $list = $query->page($page, $limit)->select()->toArray(); + $total = $query->count(); + + foreach ($list as $k => &$v){ + $user = Db::name('users')->where(['id' => $v['userId']])->field('username,account')->find(); + if (!empty($user)){ + $v['userName'] = !empty($user['username']) ? $user['username'] : $user['account']; + }else{ + $v['userName'] = ''; + } + } + unset($v); + return ResponseHelper::success(['list'=>$list,'total'=>$total]); + } + + + /** + * 素材添加 + * @return \think\response\Json + * @throws \Exception + */ + public function createMaterial(){ + $title = $this->request->param('title', ''); + $content = $this->request->param('content', []); + $cover = $this->request->param('cover', ''); + $status = $this->request->param('status', 0); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($title) || empty($content) || empty($cover)){ + return ResponseHelper::error('参数缺失'); + } + $newContent = []; + foreach ($content as $k => $v){ + if (in_array($v,['text','image','video','audio','file','link'])){ + $newContent[] = $v; + } + } + + Db::startTrans(); + try { + $query = new Material(); + $query->title = $title; + $query->content = !empty($newContent) ? json_encode($newContent,256) : json_encode([],256); + $query->cover = $cover; + $query->status = $status; + $query->userId = $userId; + $query->companyId = $companyId; + $query->createTime = time(); + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','创建成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('创建失败:'.$e->getMessage()); + } + } + + /** + * 素材详情 + * @return \think\response\Json + */ + public function detailsMaterial() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = Material::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + $data['content'] = json_decode($data['content'],true); + unset($data['createTime'],$data['updateTime'],$data['isDel'],$data['delTime']); + return ResponseHelper::success($data,'获取成功'); + } + + /** + * 删除素材 + * @return \think\response\Json + */ + public function delMaterial() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = Material::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $data->isDel = 1; + $data->delTime = time(); + $data->save(); + Db::commit(); + return ResponseHelper::success('','删除成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('删除失败:'.$e->getMessage()); + } + } + + + /** + * 修改素材 + * @return \think\response\Json + * @throws \Exception + */ + public function updateMaterial(){ + $id = $this->request->param('id', ''); + $title = $this->request->param('title', ''); + $content = $this->request->param('content', []); + $cover = $this->request->param('cover', ''); + $status = $this->request->param('status', 0); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($id) || empty($title) || empty($content) || empty($cover)){ + return ResponseHelper::error('参数缺失'); + } + $newContent = []; + foreach ($content as $k => $v){ + if (in_array($v,['text','image','video','audio','file','link'])){ + $newContent[] = $v; + } + } + $query = Material::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($query)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $query->title = $title; + $query->content = !empty($newContent) ? json_encode($newContent,256) : json_encode([],256); + $query->cover = $cover; + $query->status = $status; + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','修改成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('修改失败:'.$e->getMessage()); + } + } + //===================================================== 素材管理 ===================================================== + + + + + + //==================================================== 违禁词管理 ==================================================== + + /** + * 违禁词列表 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public function getSensitiveWord(){ + $page = $this->request->param('page', 1); + $limit = $this->request->param('limit', 10); + $keyword = $this->request->param('keyword', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + $query = SensitiveWord::where(['userId' => $userId,'companyId' => $companyId,'isDel' => 0]) + ->order('id desc'); + if (!empty($keyword)){ + $query->where('title', 'like', '%'.$keyword.'%'); + } + $total = $query->count(); + $list = $query->page($page, $limit)->select()->toArray(); + + + foreach ($list as $k => &$v){ + $user = Db::name('users')->where(['id' => $v['userId']])->field('username,account')->find(); + if (!empty($user)){ + $v['userName'] = !empty($user['username']) ? $user['username'] : $user['account']; + }else{ + $v['userName'] = ''; + } + } + unset($v); + return ResponseHelper::success(['list'=>$list,'total'=>$total]); + } + + + /** + * 违禁词添加 + * @return \think\response\Json + * @throws \Exception + */ + public function createSensitiveWord(){ + $title = $this->request->param('title', ''); + $keywords = $this->request->param('keywords', ''); + $content = $this->request->param('content', ''); + $status = $this->request->param('status', 0); + $operation = $this->request->param('operation', 0); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($title) || empty($keywords)){ + return ResponseHelper::error('参数缺失'); + } + + $keywords = explode(',',$keywords); + + Db::startTrans(); + try { + $query = new SensitiveWord(); + $query->title = $title; + $query->keywords = $keywords; + $query->content = $content; + $query->status = $status; + $query->operation = $operation; + $query->userId = $userId; + $query->companyId = $companyId; + $query->createTime = time(); + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','创建成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('创建失败:'.$e->getMessage()); + } + } + + + + /** + * 违禁词详情 + * @return \think\response\Json + */ + public function detailsSensitiveWord() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = SensitiveWord::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + $data['keywords'] = json_decode($data['keywords'],true); + $data['keywords'] = implode(',',$data['keywords']); + unset($data['createTime'],$data['updateTime'],$data['isDel'],$data['delTime']); + return ResponseHelper::success($data,'获取成功'); + } + + /** + * 违禁词删除 + * @return \think\response\Json + */ + public function delSensitiveWord() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = SensitiveWord::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $data->isDel = 1; + $data->delTime = time(); + $data->save(); + Db::commit(); + return ResponseHelper::success('','删除成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('删除失败:'.$e->getMessage()); + } + } + + + /** + * 更新违禁词 + * @return \think\response\Json + * @throws \Exception + */ + public function updateSensitiveWord(){ + $id = $this->request->param('id', ''); + $title = $this->request->param('title', ''); + $keywords = $this->request->param('keywords', ''); + $content = $this->request->param('content', ''); + $status = $this->request->param('status', 0); + $operation = $this->request->param('operation', 0); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($id) || empty($title) || empty($keywords)){ + return ResponseHelper::error('参数缺失'); + } + + $keywords = explode(',',$keywords); + + $query = SensitiveWord::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($query)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $query->title = $title; + $query->keywords = $keywords; + $query->content = $content; + $query->status = $status; + $query->operation = $operation; + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','修改成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('修改失败:'.$e->getMessage()); + } + } + + /** + * 修改违禁词状态 + * @return \think\response\Json + * @throws \Exception + */ + public function setSensitiveWordStatus(){ + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + + $query = SensitiveWord::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($query)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $query->status = !empty($query['status']) ? 0 : 1;; + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','修改成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('修改失败:'.$e->getMessage()); + } + } + + + //==================================================== 违禁词管理 ==================================================== + + + + + + //=================================================== 关键词词管理 ==================================================== + + /** + * 关键词列表 + * @return \think\response\Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public function getKeywords(){ + $page = $this->request->param('page', 1); + $limit = $this->request->param('limit', 10); + $keyword = $this->request->param('keyword', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + $query = Keywords::where(['userId' => $userId,'companyId' => $companyId,'isDel' => 0]) + ->order('id desc'); + if (!empty($keyword)){ + $query->where('title', 'like', '%'.$keyword.'%'); + } + $total = $query->count(); + $list = $query->page($page, $limit)->select()->toArray(); + + + foreach ($list as $k => &$v){ + $user = Db::name('users')->where(['id' => $v['userId']])->field('username,account')->find(); + if (!empty($user)){ + $v['userName'] = !empty($user['username']) ? $user['username'] : $user['account']; + }else{ + $v['userName'] = ''; + } + } + unset($v); + return ResponseHelper::success(['list'=>$list,'total'=>$total]); + } + + + /** + * 关键词添加 + * @return \think\response\Json + * @throws \Exception + */ + public function createKeywords(){ + $title = $this->request->param('title', ''); + $type = $this->request->param('type', 0); + $keywords = $this->request->param('keywords', ''); + $replyType = $this->request->param('replyType', 0); + $content = $this->request->param('content',''); + $materialId = $this->request->param('materialId',''); + $status = $this->request->param('status', 0); + $sort = $this->request->param('sort', 50); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($title) || empty($keywords) || (empty($materialId) && empty($content))){ + return ResponseHelper::error('参数缺失'); + } + + $keywords = explode(',',$keywords); + + Db::startTrans(); + try { + $query = new Keywords(); + $query->title = $title; + $query->type = $type; + $query->keywords = !empty($keywords) ? json_encode($keywords,256) : json_encode([]); + $query->replyType = $replyType; + $query->content = !empty($content) ? json_encode($content,256) : json_encode([]);; + $query->materialId = $materialId; + $query->status = $status; + $query->sort = $sort; + $query->userId = $userId; + $query->companyId = $companyId; + $query->createTime = time(); + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','创建成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('创建失败:'.$e->getMessage()); + } + } + + + + /** + * 关键词详情 + * @return \think\response\Json + */ + public function detailsKeywords() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = Keywords::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + $data['content'] = json_decode($data['content'],true); + $data['keywords'] = json_decode($data['keywords'],true); + $data['keywords'] = implode(',',$data['keywords']); + unset($data['createTime'],$data['updateTime'],$data['isDel'],$data['delTime']); + return ResponseHelper::success($data,'获取成功'); + } + + /** + * 关键词删除 + * @return \think\response\Json + */ + public function delKeywords() + { + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + $data = Keywords::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($data)){ + return ResponseHelper::error('该关键词已被删除或者不存在'); + } + Db::startTrans(); + try { + $data->isDel = 1; + $data->delTime = time(); + $data->save(); + Db::commit(); + return ResponseHelper::success('','删除成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('删除失败:'.$e->getMessage()); + } + } + + + /** + * 更新关键词 + * @return \think\response\Json + * @throws \Exception + */ + public function updateKeywords(){ + $id = $this->request->param('id', ''); + $title = $this->request->param('title', ''); + $type = $this->request->param('type', 0); + $keywords = $this->request->param('keywords', ''); + $replyType = $this->request->param('replyType', 0); + $content = $this->request->param('content',''); + $materialId = $this->request->param('materialId',''); + $status = $this->request->param('status', 0); + $sort = $this->request->param('sort', 50); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($title) || empty($keywords) || (empty($materialId) && empty($content))){ + return ResponseHelper::error('参数缺失'); + } + + $keywords = explode(',',$keywords); + + $query = Keywords::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($query)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $query->title = $title; + $query->type = $type; + $query->keywords = !empty($keywords) ? json_encode($keywords,256) : json_encode([]); + $query->replyType = $replyType; + $query->content = !empty($content) ? json_encode($content,256) : json_encode([]);; + $query->materialId = $materialId; + $query->status = $status; + $query->sort = $sort; + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','修改成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('修改失败:'.$e->getMessage()); + } + } + + /** + * 修改关键词状态 + * @return \think\response\Json + * @throws \Exception + */ + public function setKeywordStatus(){ + $id = $this->request->param('id', ''); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + if (empty($id)){ + return ResponseHelper::error('参数缺失'); + } + + $query = Keywords::where(['id'=>$id,'isDel' => 0,'userId' => $userId,'companyId' => $companyId])->find(); + if (empty($query)){ + return ResponseHelper::error('该素材已被删除或者不存在'); + } + Db::startTrans(); + try { + $query->status = !empty($query['status']) ? 0 : 1; + $query->updateTime = time(); + $query->save(); + Db::commit(); + return ResponseHelper::success(' ','修改成功'); + } catch (\Exception $e) { + Db::rollback(); + return ResponseHelper::error('修改失败:'.$e->getMessage()); + } + } + + + + //=================================================== 关键词词管理 ==================================================== + + + + + + +} \ No newline at end of file diff --git a/Server/application/chukebao/controller/FollowUpController.php b/Server/application/chukebao/controller/FollowUpController.php index dbefba17..d875ef39 100644 --- a/Server/application/chukebao/controller/FollowUpController.php +++ b/Server/application/chukebao/controller/FollowUpController.php @@ -41,8 +41,9 @@ class FollowUpController extends BaseController $query = FollowUp::where($where); - $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); $total = $query->count(); + $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); + foreach ($list as &$item) { $nickname = Db::table('s2_wechat_friend')->where(['id' => $item['friendId']])->value('nickname'); diff --git a/Server/application/chukebao/controller/MessageController.php b/Server/application/chukebao/controller/MessageController.php index beffd1ed..6d7de2a6 100644 --- a/Server/application/chukebao/controller/MessageController.php +++ b/Server/application/chukebao/controller/MessageController.php @@ -133,9 +133,9 @@ class MessageController extends BaseController $where[] = ['wechatTime','between',[$from,$to]]; } - - $list = Db::table('s2_wechat_message')->where($where)->page($page,$limit)->order('id DESC')->select(); $total = Db::table('s2_wechat_message')->where($where)->count(); + $list = Db::table('s2_wechat_message')->where($where)->page($page,$limit)->order('id DESC')->select(); + foreach ($list as $k=>&$v){ diff --git a/Server/application/chukebao/controller/QuestionsController.php b/Server/application/chukebao/controller/QuestionsController.php index 9ee8799e..21096bb5 100644 --- a/Server/application/chukebao/controller/QuestionsController.php +++ b/Server/application/chukebao/controller/QuestionsController.php @@ -30,8 +30,9 @@ class QuestionsController extends BaseController if (!empty($keyword)){ $query->where('questions|answers', 'like', '%'.$keyword.'%'); } - $list = $query->page($page, $limit)->select()->toArray(); $total = $query->count(); + $list = $query->page($page, $limit)->select()->toArray(); + foreach ($list as $k => &$v){ $user = Db::name('users')->where(['id' => $v['userId']])->field('username,account')->find(); diff --git a/Server/application/chukebao/controller/ToDoController.php b/Server/application/chukebao/controller/ToDoController.php index c71ab30b..8519ea4d 100644 --- a/Server/application/chukebao/controller/ToDoController.php +++ b/Server/application/chukebao/controller/ToDoController.php @@ -40,9 +40,9 @@ class ToDoController extends BaseController } $query = ToDo::where($where); - - $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); $total = $query->count(); + $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); + foreach ($list as &$item) { $nickname = Db::table('s2_wechat_friend')->where(['id' => $item['friendId']])->value('nickname'); diff --git a/Server/application/chukebao/controller/TokensRecordController.php b/Server/application/chukebao/controller/TokensRecordController.php index deb8882d..8e0519ce 100644 --- a/Server/application/chukebao/controller/TokensRecordController.php +++ b/Server/application/chukebao/controller/TokensRecordController.php @@ -33,9 +33,9 @@ class TokensRecordController extends BaseController $query = TokensRecord::where($where); - - $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); $total = $query->count(); + $list = $query->where($where)->page($page,$limit)->order('id desc')->select(); + foreach ($list as &$item) { if (in_array($item['type'],[1])){ diff --git a/Server/application/chukebao/controller/WechatChatroomController.php b/Server/application/chukebao/controller/WechatChatroomController.php index 8753da88..01d07756 100644 --- a/Server/application/chukebao/controller/WechatChatroomController.php +++ b/Server/application/chukebao/controller/WechatChatroomController.php @@ -20,8 +20,9 @@ class WechatChatroomController extends BaseController $query = Db::table('s2_wechat_chatroom') ->where(['accountId' => $accountId,'isDeleted' => 0]) ->order('id desc'); - $list = $query->page($page, $limit)->select(); $total = $query->count(); + $list = $query->page($page, $limit)->select(); + // 提取所有聊天室ID,用于批量查询 diff --git a/Server/application/chukebao/controller/WechatFriendController.php b/Server/application/chukebao/controller/WechatFriendController.php index f73a6ab8..500fd5ec 100644 --- a/Server/application/chukebao/controller/WechatFriendController.php +++ b/Server/application/chukebao/controller/WechatFriendController.php @@ -18,8 +18,9 @@ class WechatFriendController extends BaseController $query = Db::table('s2_wechat_friend') ->where(['accountId' => $accountId,'isDeleted' => 0]) ->order('id desc'); - $list = $query->page($page, $limit)->select(); $total = $query->count(); + $list = $query->page($page, $limit)->select(); + // 提取所有好友ID @@ -73,6 +74,8 @@ class WechatFriendController extends BaseController // 处理每个好友的数据 foreach ($list as $k => &$v) { + $v['labels'] = json_decode($v['labels'], true); + $v['siteLabels'] = json_decode($v['siteLabels'], true); $v['createTime'] = !empty($v['createTime']) ? date('Y-m-d H:i:s', $v['createTime']) : ''; $v['updateTime'] = !empty($v['updateTime']) ? date('Y-m-d H:i:s', $v['updateTime']) : ''; $v['passTime'] = !empty($v['passTime']) ? date('Y-m-d H:i:s', $v['passTime']) : ''; diff --git a/Server/application/chukebao/controller/WechatGroupController.php b/Server/application/chukebao/controller/WechatGroupController.php new file mode 100644 index 00000000..5e0241d9 --- /dev/null +++ b/Server/application/chukebao/controller/WechatGroupController.php @@ -0,0 +1,30 @@ +getUserInfo('s2_accountId'); + $userId = $this->getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + + $query = Db::table('s2_wechat_group')->where(['accountId' => $accountId])->whereIn('groupType',[1,2])->order('sortIndex desc,id desc'); + $list = $query->select(); + $total = $query->count(); + + + // 处理每个好友的数据 + foreach ($list as $k => &$v) { + $v['createTime'] = !empty($v['createTime']) ? date('Y-m-d H:i:s', $v['createTime']) : ''; + } + unset($v); + + return ResponseHelper::success(['list'=>$list,'total'=>$total]); + } +} \ No newline at end of file diff --git a/Server/application/chukebao/model/Keywords.php b/Server/application/chukebao/model/Keywords.php new file mode 100644 index 00000000..ea70d882 --- /dev/null +++ b/Server/application/chukebao/model/Keywords.php @@ -0,0 +1,17 @@ +