修复微信管理数据展示问题

This commit is contained in:
wong
2025-09-28 16:02:03 +08:00
parent 372847f398
commit 7b3df95152
2 changed files with 15 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ use app\common\model\WechatCustomer as WechatCustomerModel;
use app\common\model\WechatFriendShip as WechatFriendShipModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
use think\Db;
/**
* 微信控制器
@@ -63,7 +64,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController
*/
protected function getWechatAddFriendStatus(string $wechatId): int
{
return 1;
return Db::name('device_wechat_login')->where(['wechatId' => $wechatId])->order('id DESC')->value('alive');
}
/**
@@ -164,7 +165,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController
return DeviceWechatLoginModel::where(
[
'companyId' => $this->getUserInfo('companyId'),
'alive' => DeviceWechatLoginModel::ALIVE_WECHAT_ACTIVE,
// 'alive' => DeviceWechatLoginModel::ALIVE_WECHAT_ACTIVE,
]
)
->where('deviceId', 'in', $deviceIds)
@@ -179,7 +180,12 @@ class GetWechatsOnDevicesV1Controller extends BaseController
*/
protected function getLatestActiveTime(string $wechatId): string
{
return date('Y-m-d H:i:s', strtotime('-1 day'));
$wechatAccountId = Db::table('s2_wechat_account')->where(['wechatId' => $wechatId])->value('id');
if (empty($wechatAccountId)){
return '-';
}
$time = Db::table('s2_wechat_message')->where('wechatAccountId',$wechatAccountId)->order('id DESC')->value('wechatTime');
return !empty($time) ? date('Y-m-d H:i:s', $time) : '-';
}
/**
@@ -217,7 +223,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController
[
'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'
'l.deviceId','l.alive'
]
)
->join('device_wechat_login l', 'w.wechatId = l.wechatId AND l.companyId = '. $this->getUserInfo('companyId'))