diff --git a/Server/application/common/controller/PasswordLoginController.php b/Server/application/common/controller/PasswordLoginController.php index 534a978a..232e4e68 100644 --- a/Server/application/common/controller/PasswordLoginController.php +++ b/Server/application/common/controller/PasswordLoginController.php @@ -106,7 +106,7 @@ class PasswordLoginController extends BaseController * @return array * @throws \Exception */ - protected function doLogin(string $account, string $password, int $typeId): array + protected function doLogin(string $account, string $password, int $typeId, string $deviceId): array { // 获取用户信息 $member = $this->getUser($account, $password, $typeId); @@ -116,10 +116,10 @@ class PasswordLoginController extends BaseController if ($typeId == 2 && !empty($deviceId)){ $deviceUser = Db::name('device_user')->where(['companyId' => $member['companyId'],'userId' => $member['id'],'deleteTime' => 0])->find(); if (!empty($deviceUser)){ - $s2_device = Db::table('s2_device')->where(['companyId' => $member['companyId'],'deleteTime' => 0,'id' => $deviceUser])->find(); - if (!empty($s2_device) && empty($s2_device['deviceImei'])){ - Db::table('s2_device')->where(['id' => $s2_device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]); - Db::name('device')->where(['id' => $s2_device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]); + $device = Db::name('device')->where(['companyId' => $member['companyId'],'deleteTime' => 0,'id' => $deviceUser['deviceId']])->find(); + if (!empty($device) && empty($device['deviceImei'])){ + Db::table('s2_device')->where(['id' => $device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]); + Db::name('device')->where(['id' => $device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]); } } } @@ -140,10 +140,12 @@ class PasswordLoginController extends BaseController { $params = $this->request->only(['account', 'password', 'typeId','deviceId']); try { + $deviceId = isset($params['deviceId']) ? $params['deviceId'] : ''; $userData = $this->dataValidate($params)->doLogin( $params['account'], $params['password'], $params['typeId'], + $deviceId );