From 61114f0e92e6d1a72f79c5b37819b914d2c624da Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 20 Feb 2023 14:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3wechat=E7=B1=BB=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/LoginService.php | 11 ++++------- app/Services/UserService.php | 1 - app/Utils/WeChat.php | 3 +++ config/config.php | 29 ++++++++--------------------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/app/Services/LoginService.php b/app/Services/LoginService.php index 81b18a1..a0ba97b 100644 --- a/app/Services/LoginService.php +++ b/app/Services/LoginService.php @@ -9,7 +9,7 @@ use App\Model\UserPatient as UserPatientModel; use App\Model\UserPharmacist as UserPharmacistModel; use App\Utils\Http; use App\Utils\Jwt; -use App\Utils\WeChat; +use Extend\Wechat\Wechat; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; use Psr\Container\ContainerExceptionInterface; @@ -29,7 +29,7 @@ class LoginService extends BaseService $wx_code = $this->request->input('wx_code'); $user_type = $this->request->input('user_type'); - $weChat = $this->container->get(WeChat::class); + $weChat = new Wechat($user_type); // 获取手机号 $phone_info = $weChat->getPhone($phone_code); @@ -111,6 +111,7 @@ class LoginService extends BaseService Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } + $client_user_id = $user_doctor['doctor_id']; } } else { @@ -187,12 +188,8 @@ class LoginService extends BaseService $data = array(); $data['login_ip'] = $login_ip ?? ""; $data['last_login_at'] = date('Y-m-d H:i:s', time()); - $res = UserModel::editUser($params,$data); - if (!$res){ - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } + UserModel::editUser($params,$data); // 组合生成token的数据 $token_user_data = array(); $token_user_data['user_id'] = $user['user_id']; // 用户id diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 351a9ef..e57c4fb 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -10,7 +10,6 @@ use App\Model\UserPatient as UserPatientModel; use App\Model\UserPharmacist as UserPharmacistModel; use App\Utils\Http; use App\Utils\Jwt; -use App\Utils\WeChat; use Hyperf\DbConnection\Db; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; diff --git a/app/Utils/WeChat.php b/app/Utils/WeChat.php index da5293f..751fba3 100644 --- a/app/Utils/WeChat.php +++ b/app/Utils/WeChat.php @@ -19,6 +19,9 @@ use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; +/** + * 废弃 + */ class WeChat { protected Application $app; diff --git a/config/config.php b/config/config.php index 5050112..6b718cc 100644 --- a/config/config.php +++ b/config/config.php @@ -32,28 +32,15 @@ return [ "ttl" => env('JWT_TTL', '3600 * 24 * 70'),// 过期时间 'algo' => env('JWT_ALGO', 'HS256'), ], - "easy_we_chat" => [ // 微信配置 - // 测试 - "app_id" => env('WE_CHAT_APP_ID', 'wxc83296720404aa7b'), - "secret" => env('WE_CHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'), - 'http' => [ - 'throw' => false, // 状态码非 200、300 时是否抛出异常,默认为开启 - 'timeout' => 5.0, - // 'base_uri' => 'https://api.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri - - 'retry' => true, // 使用默认重试配置 - // 'retry' => [ - // // 仅以下状态码重试 - // 'http_codes' => [429, 500] - // // 最大重试次数 - // 'max_retries' => 3, - // // 请求间隔 (毫秒) - // 'delay' => 1000, - // // 如果设置,每次重试的等待时间都会增加这个系数 - // // (例如. 首次:1000ms; 第二次: 3 * 1000ms; etc.) - // 'multiplier' => 3 - // ], + "we_chat" => [ // 微信配置 + "doctor" => [ + "app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'), + "secret" => env('DOCTOR_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'), ], + "patient" => [ + "app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'), + "secret" => env('PATIENT_WECHAT_APP_SECRET', '2671d2f4285180ddec5a5a2b16ed50f2'), + ] ], "alibaba" => [// 阿里 "dysms" => [// 阿里云大鱼短信