From 3a07b79c4ab0f16475bb597cad03757679200b9e Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Sat, 13 May 2023 17:02:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=81=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=9B=B4=E6=96=B0openid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/LoginService.php | 43 ++++++++++++++++++++++++++++++++++- config/routes.php | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app/Services/LoginService.php b/app/Services/LoginService.php index 8b6f03f..a7ec6ce 100644 --- a/app/Services/LoginService.php +++ b/app/Services/LoginService.php @@ -170,11 +170,22 @@ class LoginService extends BaseService return fail(HttpEnumCode::USER_STATUS_ERROR); } - // 更新session_key $data = array(); if ($wx_info_data['session_key'] != $result['session_key']) { + // 更新session_key $data['wx_session_key'] = $wx_info_data['session_key']; } + + if ($wx_info_data['openid'] != $result['open_id']) { + // 更新open_id + $data['open_id'] = $wx_info_data['openid']; + } + + if ($wx_info_data['unionid'] != $result['union_id']) { + // 更新union_id + $data['union_id'] = $wx_info_data['unionid']; + } + $data['updated_at'] = date('Y-m-d H:i:s', time()); $params = array(); @@ -394,6 +405,36 @@ class LoginService extends BaseService Db::rollBack(); return fail(HttpEnumCode::USER_STATUS_ERROR); } + + $data = array(); + if ($wx_info_data['session_key'] != $result['session_key']) { + // 更新session_key + $data['wx_session_key'] = $wx_info_data['session_key']; + } + + if ($wx_info_data['openid'] != $result['open_id']) { + // 更新open_id + $data['open_id'] = $wx_info_data['openid']; + } + + $data['updated_at'] = date('Y-m-d H:i:s', time()); + + $params = array(); + if ($user['user_type'] == 1) { + $params['patient_id'] = $result['patient_id']; + $res = UserPatientModel::editUserPatient($params, $data); + } elseif ($user['user_type'] == 2) { + $params['doctor_id'] = $result['doctor_id']; + $res = UserDoctorModel::editUserDoctor($params, $data); + } elseif ($user['user_type'] == 3) { + $params['pharmacist_id'] = $result['pharmacist_id']; + $res = UserPharmacistModel::editUserPharmacist($params, $data); + } + + if (!$res) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } } // 记录用户登陆记录 diff --git a/config/routes.php b/config/routes.php index 0c3f411..cb6a50b 100644 --- a/config/routes.php +++ b/config/routes.php @@ -621,7 +621,7 @@ Router::addGroup('/test', function () { Router::get('', [TestController::class, 'test']); // 模拟退款 - Router::get('/refund', [TestController::class, 'refund']); +// Router::get('/refund', [TestController::class, 'refund']); });