This commit is contained in:
wong
2025-08-15 18:30:03 +08:00
parent 25ae2458f0
commit 639d7d3cb6
3 changed files with 89 additions and 2 deletions

View File

@@ -837,4 +837,54 @@ class WebSocketController extends BaseController
return json_encode(['code' => 500, 'msg' => '邀请好友入群异常:' . $e->getMessage()]);
}
}
/**
* 添加群好友
* @param $data
* @return false|string
*/
public function CmdChatroomOperate($data = [])
{
try {
// 参数验证
if (empty($data)) {
return json_encode(['code' => 400, 'msg' => '参数缺失']);
}
// 验证必要参数
if (empty($data['wechatId'])) {
return json_encode(['code' => 400, 'msg' => 'wechatId不能为空']);
}
if (empty($data['sendWord'])) {
return json_encode(['code' => 400, 'msg' => '添加的招呼语不能为空']);
}
if (empty($data['wechatAccountId'])) {
return json_encode(['code' => 400, 'msg' => '微信账号ID不能为空']);
}
if (empty($data['wechatChatroomId'])) {
return json_encode(['code' => 400, 'msg' => '群ID不能为空']);
}
// 构建请求参数
$params = [
"chatroomOperateType" => 1,
"cmdType" => "CmdChatroomOperate",
"extra" => [
'wechatId' => $data['wechatId'],
'sendWord' => $data['sendWord']
],
"seq" => time(),
"wechatAccountId" => $data['wechatAccountId'],
"wechatChatroomId" => $data['wechatChatroomId'],
];
$message = $this->sendMessage($params);
return json_encode(['code' => 200, 'msg' => '添加好友请求发送成功', 'data' => $message]);
} catch (\Exception $e) {
// 返回错误响应
return json_encode(['code' => 500, 'msg' => '添加群好友异常:' . $e->getMessage()]);
}
}
}

View File

@@ -130,13 +130,14 @@ Route::group('v1/', function () {
});
//数据统计相关
//数据统计相关
Route::group('dashboard',function (){
Route::get('', 'app\cunkebao\controller\StatsController@baseInfoStats');
Route::get('plan-stats', 'app\cunkebao\controller\StatsController@planStats');
Route::get('sevenDay-stats', 'app\cunkebao\controller\StatsController@customerAcquisitionStats7Days');
Route::get('today-stats', 'app\cunkebao\controller\StatsController@todayStats');
Route::get('friendRequestTaskStats', 'app\cunkebao\controller\StatsController@getFriendRequestTaskStats');
Route::get('userInfoStats', 'app\cunkebao\controller\StatsController@userInfoStats');
});

View File

@@ -197,7 +197,13 @@ class StatsController extends Controller
}
/**
* 场景获客数据统计
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFriendRequestTaskStats()
{
$companyId = $this->request->userInfo['companyId'];
@@ -347,5 +353,35 @@ class StatsController extends Controller
}
public function userInfoStats()
{
$companyId = $this->request->userInfo['companyId'];
$userId = $this->request->userInfo['id'];
$isAdmin = $this->request->userInfo['isAdmin'];
$device = Db::name('device')->where(['companyId' => $companyId,'deleteTime' => 0]);
$wechat = Db::name('wechat_customer')->where(['companyId' => $companyId]);
$contentLibrary = Db::name('content_library')->where(['companyId' => $companyId,'isDel' => 0]);
$user = Db::name('wechat_friendship')->where(['companyId' => $companyId,'deleteTime' => 0]);
if(empty($isAdmin)){
$contentLibrary = $contentLibrary->where(['userId' => $userId]);
}
$deviceNum = $device->count();
$wechatNum = $wechat->count();
$contentLibraryNum = $contentLibrary->count();
$userNum = $user->count();
$data = [
'deviceNum' => $deviceNum,
'wechatNum' => $wechatNum,
'contentLibraryNum' => $contentLibraryNum,
'userNum' => $userNum,
];
return successJson($data, '获取成功');
}
}