私域抄盘手 - 修改微信号相关路由规则 及 统一微信号信息查询规则

This commit is contained in:
柳清爽
2025-05-14 14:17:36 +08:00
parent 2d60f23806
commit 798b0d7854
10 changed files with 152 additions and 182 deletions

View File

@@ -25,7 +25,7 @@ Route::group('v1/', function () {
Route::get('', 'app\cunkebao\controller\wechat\GetWechatsOnDevicesV1Controller@index');
Route::get(':id/summary', 'app\cunkebao\controller\wechat\GetWechatOnDeviceSummarizeV1Controller@index');
Route::get(':id/friends', 'app\cunkebao\controller\wechat\GetWechatOnDeviceFriendsV1Controller@index');
Route::get(':id/friend/:aId', 'app\cunkebao\controller\wechat\GetWechatOnDeviceFriendProfileV1Controller@index');
Route::get(':wechatId', 'app\cunkebao\controller\wechat\GetWechatProfileV1Controller@index');
Route::get('count', 'app\cunkebao\controller\DeviceWechat@count');
Route::get('device-count', 'app\cunkebao\controller\DeviceWechat@deviceCount'); // 获取有登录微信的设备数量

View File

@@ -41,8 +41,8 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController
$query = WechatFriendShipModel::alias('f')
->field(
[
'w.id', 'w.nickname', 'w.avatar',
'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId',
'w.id', 'w.nickname', 'w.avatar', 'w.wechatId',
'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatAccount',
'f.memo', 'f.tags'
]
)
@@ -60,25 +60,6 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController
return $query->paginate($this->request->param('limit/d', 10), false, ['page' => $this->request->param('page/d', 1)]);
}
/**
* 获取原始的64位的微信id
*
* @return string
* @throws \Exception
*/
protected function getStringWechatIdByNumberId(): string
{
$account = WechatAccountModel::find(
$this->request->param('id/d')
);
if (is_null($account)) {
throw new \Exception('微信账号不存在', 404);
}
return $account->wechatId;
}
/**
* 构建查询条件
*
@@ -92,7 +73,7 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController
$where[] = ['exp', "f.memo LIKE '%{$keyword}%' OR f.tags LIKE '%{$keyword}%'"];
}
$where['f.ownerWechatId'] = $this->getStringWechatIdByNumberId();
$where['f.ownerWechatId'] = $this->request->param('id/s') ?: 'x_x';
return array_merge($where, $params);
}

View File

@@ -233,25 +233,6 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
];
}
/**
* 获取原始的64位的微信id
*
* @return string
* @throws \Exception
*/
protected function getStringWechatIdByNumberId(): string
{
$account = WechatAccountModel::find(
$this->request->param('id/d')
);
if (is_null($account)) {
throw new \Exception('微信账号不存在', 404);
}
return $account->wechatId;
}
/**
* 获取微信号详情
*
@@ -260,7 +241,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
public function index()
{
try {
$wechatId = $this->getStringWechatIdByNumberId();
$wechatId = $this->request->param('id/s');
// 以下内容依次加工数据
$accountAge = $this->getRegisterDate($wechatId);

View File

@@ -10,7 +10,7 @@ use library\ResponseHelper;
/**
* 设备微信控制器
*/
class GetWechatOnDeviceFriendProfileV1Controller extends BaseController
class GetWechatProfileV1Controller extends BaseController
{
/**
* 获取最近互动时间
@@ -63,11 +63,11 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController
/**
* 获取微信账号
*
* @param int $id
* @param string $wechatId
* @return array
* @throws \Exception
*/
protected function getWechatAccountProfileById(int $id): array
protected function getWechatAccountProfileByWechatId(string $wechatId): array
{
$account = WechatAccountModel::alias('w')
->field(
@@ -78,7 +78,8 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController
]
)
->join('wechat_friendship f', 'w.wechatId=f.wechatId')
->find($id);
->where('w.wechatId', $wechatId)
->find();
if (is_null($account)) {
throw new \Exception('未获取到微信账号数据', 404);
@@ -95,8 +96,8 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController
public function index()
{
try {
$results = $this->getWechatAccountProfileById(
$this->request->param('aId/d')
$results = $this->getWechatAccountProfileByWechatId(
$this->request->param('wechatId/s')
);
return ResponseHelper::success(

View File

@@ -198,8 +198,8 @@ class GetWechatsOnDevicesV1Controller extends BaseController
$query = WechatAccountModel::alias('w')
->field(
[
'w.id', 'w.nickname', 'w.avatar',
'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId',
'w.id', 'w.nickname', 'w.avatar', 'w.wechatId',
'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatAccount',
'l.deviceId'
]
)