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']); });