修复微信管理数据展示问题
This commit is contained in:
@@ -71,14 +71,17 @@ class GetDeviceListV1Controller extends BaseController
|
||||
*/
|
||||
protected function getDeviceList(array $where): \think\Paginator
|
||||
{
|
||||
|
||||
$companyId = $this->getUserInfo('companyId');
|
||||
$query = DeviceModel::alias('d')
|
||||
->field([
|
||||
'd.id', 'd.imei', 'd.memo', 'd.alive',
|
||||
'l.wechatId',
|
||||
'a.nickname', 'a.alias', 'a.avatar', '0 totalFriend'
|
||||
])
|
||||
->leftJoin('device_wechat_login l', 'd.id = l.deviceId and l.alive =' . DeviceWechatLoginModel::ALIVE_WECHAT_ACTIVE . ' and l.companyId = d.companyId')
|
||||
->leftJoin('wechat_account a', 'l.wechatId = a.wechatId')
|
||||
->join('(SELECT MAX(id) AS id, deviceId FROM ck_device_wechat_login WHERE companyId='.$companyId.' GROUP BY deviceId) dwl_max','dwl_max.deviceId = d.id')
|
||||
->join('device_wechat_login l','l.id = dwl_max.id')
|
||||
->join('wechat_account a', 'l.wechatId = a.wechatId')
|
||||
->order('d.id desc');
|
||||
|
||||
foreach ($where as $key => $value) {
|
||||
|
||||
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user