From 410a43e6a18462ccfb353c72fd534bd0719e3c09 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Sat, 13 Sep 2025 17:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A6=E5=AE=A2=E5=AE=9D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=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 | 11 +++++-- .../chukebao/controller/BaseController.php | 29 +++++++++++++++++++ .../chukebao/controller/LoginController.php | 13 +++++---- .../controller/WechatChatroomController.php | 21 ++++++++++++++ .../controller/WechatFriendController.php | 21 ++++++++++++++ ...PotentialListWithInCompanyV1Controller.php | 9 +++--- 6 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 Server/application/chukebao/controller/BaseController.php create mode 100644 Server/application/chukebao/controller/WechatChatroomController.php create mode 100644 Server/application/chukebao/controller/WechatFriendController.php diff --git a/Server/application/chukebao/config/route.php b/Server/application/chukebao/config/route.php index 6ae947a0..8e57834c 100644 --- a/Server/application/chukebao/config/route.php +++ b/Server/application/chukebao/config/route.php @@ -9,7 +9,14 @@ use think\facade\Route; Route::group('v1/', function () { Route::group('kefu/', function () { - + //好友相关 + Route::group('wechatFriend/', function () { + Route::get('list', 'app\chukebao\controller\WechatFriendController@getList'); // 获取好友列表 + }); + //好友相关 + Route::group('wechatChatroom/', function () { + Route::get('list', 'app\chukebao\controller\WechatChatroomController@getList'); // 获取好友列表 + }); }); @@ -18,7 +25,7 @@ Route::group('v1/', function () { // 客服登录 Route::group('v1/kefu', function () { - Route::post('login', 'app\chukebao\controller\LoginController@index'); // 获取好友列表 + Route::post('login', 'app\chukebao\controller\LoginController@index'); // 登录 }); diff --git a/Server/application/chukebao/controller/BaseController.php b/Server/application/chukebao/controller/BaseController.php new file mode 100644 index 00000000..2c877509 --- /dev/null +++ b/Server/application/chukebao/controller/BaseController.php @@ -0,0 +1,29 @@ +request->userInfo; + + if (!$user) { + throw new \Exception('未授权访问,缺少有效的身份凭证', 401); + } + + return $column ? $user[$column] : $user; + } +} \ No newline at end of file diff --git a/Server/application/chukebao/controller/LoginController.php b/Server/application/chukebao/controller/LoginController.php index d34c55e3..519b744a 100644 --- a/Server/application/chukebao/controller/LoginController.php +++ b/Server/application/chukebao/controller/LoginController.php @@ -2,18 +2,16 @@ namespace app\chukebao\controller; -use app\common\controller\BaseController; use app\common\util\JwtUtil; use Exception; use library\ResponseHelper; -use app\api\controller\UserController; use think\Db; - +use think\Controller; /** * 认证控制器 * 处理用户登录和身份验证 */ -class LoginController extends BaseController +class LoginController extends Controller { @@ -58,17 +56,17 @@ class LoginController extends BaseController 'password' => !empty($user['passwordLocal']) ? localDecrypt($user['passwordLocal']) : $password ]; + try { // 调用登录接口获取token $headerData = ['client:kefu-client']; if (!empty($verifySessionId) && !empty($verifyCode)){ $headerData[] = 'verifysessionid:'.$verifySessionId; - $headerData[] = 'verifycode:'.$verifyCode; + $headerData[] = 'verifycode:'.$verifyCode; } $header = setHeader($headerData, '', 'plain'); $result = requestCurl('https://s2.siyuguanli.com:9991/token', $params, 'POST', $header); $result = handleApiResponse($result); - if (isset($result['access_token']) && !empty($result['access_token'])) { $userData['kefuData']['token'] = $result; $headerData = ['client:kefu-client']; @@ -76,6 +74,9 @@ class LoginController extends BaseController $result2 = requestCurl('https://s2.siyuguanli.com:9991/api/account/self', [], 'GET', $header, 'json'); $self = handleApiResponse($result2); $userData['kefuData']['self'] = $self; + + Db::name('users')->where('id', $user['id'])->update(['passwordLocal' => localEncrypt($password),'updateTime' => time()]); + }else{ return ResponseHelper::error($result['error_description']); } diff --git a/Server/application/chukebao/controller/WechatChatroomController.php b/Server/application/chukebao/controller/WechatChatroomController.php new file mode 100644 index 00000000..cf03fd41 --- /dev/null +++ b/Server/application/chukebao/controller/WechatChatroomController.php @@ -0,0 +1,21 @@ +request->param('page', 1); + $limit = $this->request->param('limit', 10); + $accountId = $this->getUserInfo('s2_accountId'); + if (empty($accountId)){ + return ResponseHelper::error('请先登录'); + } + $list = Db::table('s2_wechat_chatroom')->where('accountId',$accountId)->order('id desc')->page($page, $limit)->select(); + return ResponseHelper::success($list); + } +} \ No newline at end of file diff --git a/Server/application/chukebao/controller/WechatFriendController.php b/Server/application/chukebao/controller/WechatFriendController.php new file mode 100644 index 00000000..aa9f0248 --- /dev/null +++ b/Server/application/chukebao/controller/WechatFriendController.php @@ -0,0 +1,21 @@ +request->param('page', 1); + $limit = $this->request->param('limit', 10); + $accountId = $this->getUserInfo('s2_accountId'); + if (empty($accountId)){ + return ResponseHelper::error('请先登录'); + } + $list = Db::table('s2_wechat_friend')->where('accountId',$accountId)->order('id desc')->page($page, $limit)->select(); + return ResponseHelper::success($list); + } +} \ No newline at end of file diff --git a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php index 85b0944f..a6252698 100644 --- a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php +++ b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php @@ -155,11 +155,11 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController public function getUser() { - $userId = $this->request->param('userId', ''); + $wechatId = $this->request->param('wechatId', ''); $companyId = $this->getUserInfo('companyId'); - if (empty($userId)) { - return json_encode(['code' => 500, 'msg' => '用户id不能为空']); + if (empty($wechatId)) { + return json_encode(['code' => 500, 'msg' => '微信id不能为空']); } $total = [ @@ -175,12 +175,11 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController 'wa.nickname', 'wa.avatar', 'wa.gender', 'wa.phone', 'wa.alias']) ->join('wechat_account wa', 'p.identifier=wa.wechatId', 'left') ->order('p.id DESC') - ->where(['p.id' => $userId]) + ->where(['p.identifier' => $wechatId]) ->group('p.identifier') ->find(); $data['lastMsgTime'] = ''; - //来源 $source = Db::name('traffic_source')->alias('ts') ->field(['wa.nickname', 'wa.avatar', 'wa.gender', 'wa.phone', 'wa.wechatId', 'wa.alias',