修正wechat类,

This commit is contained in:
wucongxing 2023-02-20 14:13:01 +08:00
parent 24a6a529fb
commit 61114f0e92
4 changed files with 15 additions and 29 deletions

View File

@ -9,7 +9,7 @@ use App\Model\UserPatient as UserPatientModel;
use App\Model\UserPharmacist as UserPharmacistModel; use App\Model\UserPharmacist as UserPharmacistModel;
use App\Utils\Http; use App\Utils\Http;
use App\Utils\Jwt; use App\Utils\Jwt;
use App\Utils\WeChat; use Extend\Wechat\Wechat;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis; use Hyperf\Redis\Redis;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
@ -29,7 +29,7 @@ class LoginService extends BaseService
$wx_code = $this->request->input('wx_code'); $wx_code = $this->request->input('wx_code');
$user_type = $this->request->input('user_type'); $user_type = $this->request->input('user_type');
$weChat = $this->container->get(WeChat::class); $weChat = new Wechat($user_type);
// 获取手机号 // 获取手机号
$phone_info = $weChat->getPhone($phone_code); $phone_info = $weChat->getPhone($phone_code);
@ -111,6 +111,7 @@ class LoginService extends BaseService
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::SERVER_ERROR); return fail(HttpEnumCode::SERVER_ERROR);
} }
$client_user_id = $user_doctor['doctor_id']; $client_user_id = $user_doctor['doctor_id'];
} }
} else { } else {
@ -187,12 +188,8 @@ class LoginService extends BaseService
$data = array(); $data = array();
$data['login_ip'] = $login_ip ?? ""; $data['login_ip'] = $login_ip ?? "";
$data['last_login_at'] = date('Y-m-d H:i:s', time()); $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的数据
$token_user_data = array(); $token_user_data = array();
$token_user_data['user_id'] = $user['user_id']; // 用户id $token_user_data['user_id'] = $user['user_id']; // 用户id

View File

@ -10,7 +10,6 @@ use App\Model\UserPatient as UserPatientModel;
use App\Model\UserPharmacist as UserPharmacistModel; use App\Model\UserPharmacist as UserPharmacistModel;
use App\Utils\Http; use App\Utils\Http;
use App\Utils\Jwt; use App\Utils\Jwt;
use App\Utils\WeChat;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;

View File

@ -19,6 +19,9 @@ use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
/**
* 废弃
*/
class WeChat class WeChat
{ {
protected Application $app; protected Application $app;

View File

@ -32,28 +32,15 @@ return [
"ttl" => env('JWT_TTL', '3600 * 24 * 70'),// 过期时间 "ttl" => env('JWT_TTL', '3600 * 24 * 70'),// 过期时间
'algo' => env('JWT_ALGO', 'HS256'), 'algo' => env('JWT_ALGO', 'HS256'),
], ],
"easy_we_chat" => [ // 微信配置 "we_chat" => [ // 微信配置
// 测试 "doctor" => [
"app_id" => env('WE_CHAT_APP_ID', 'wxc83296720404aa7b'), "app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'),
"secret" => env('WE_CHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'), "secret" => env('DOCTOR_WECHAT_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
// ],
], ],
"patient" => [
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
"secret" => env('PATIENT_WECHAT_APP_SECRET', '2671d2f4285180ddec5a5a2b16ed50f2'),
]
], ],
"alibaba" => [// 阿里 "alibaba" => [// 阿里
"dysms" => [// 阿里云大鱼短信 "dysms" => [// 阿里云大鱼短信