触客宝部分功能提交
This commit is contained in:
@@ -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'); // 登录
|
||||
});
|
||||
|
||||
|
||||
|
||||
29
Server/application/chukebao/controller/BaseController.php
Normal file
29
Server/application/chukebao/controller/BaseController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\chukebao\controller;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* 基础控制器
|
||||
*/
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param string $column
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getUserInfo(?string $column = null)
|
||||
{
|
||||
$user = $this->request->userInfo;
|
||||
|
||||
if (!$user) {
|
||||
throw new \Exception('未授权访问,缺少有效的身份凭证', 401);
|
||||
}
|
||||
|
||||
return $column ? $user[$column] : $user;
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\chukebao\controller;
|
||||
|
||||
use library\ResponseHelper;
|
||||
use think\Db;
|
||||
|
||||
class WechatChatroomController extends BaseController
|
||||
{
|
||||
|
||||
public function getList(){
|
||||
$page = $this->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\chukebao\controller;
|
||||
|
||||
use library\ResponseHelper;
|
||||
use think\Db;
|
||||
|
||||
class WechatFriendController extends BaseController
|
||||
{
|
||||
|
||||
public function getList(){
|
||||
$page = $this->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);
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user