From 8925d4bbd88838f7aabe5d64efbd462e65d364b6 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Mon, 24 Mar 2025 09:26:43 +0800 Subject: [PATCH] feat : wx login --- app/Service/Api/Login/WxFastLoginService.php | 14 ++++++++++++-- config/autoload/listeners.php | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Service/Api/Login/WxFastLoginService.php b/app/Service/Api/Login/WxFastLoginService.php index 3496436..fb696a0 100644 --- a/app/Service/Api/Login/WxFastLoginService.php +++ b/app/Service/Api/Login/WxFastLoginService.php @@ -11,19 +11,28 @@ declare(strict_types=1); namespace App\Service\Api\Login; use App\Constants\Common\ThirdCode; +use App\Event\RegistrationEvent; use App\Exception\ErrException; use App\Model\UserAccount; use App\Model\UserThird; use App\Service\ServiceTrait\Api\WxMiniTrait; use Hyperf\DbConnection\Db; +use Hyperf\Di\Annotation\Inject; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Psr\EventDispatcher\EventDispatcherInterface; use RedisException; class WxFastLoginService extends LoginBaseService { use WxMiniTrait; + /** + * @var EventDispatcherInterface + */ + #[Inject] + private EventDispatcherInterface $eventDispatcher; + /** * 登录类型 2=微信小程序 */ @@ -101,8 +110,9 @@ class WxFastLoginService extends LoginBaseService // 邀请过来的 邀请方有没有奖励 被邀请方有没有奖励 $this->checkInvite(); - // 有没有注册奖励 - $this->addCoupon(); + // 有没有注册奖励 事件机制 +// $this->addCoupon(); + $this->eventDispatcher->dispatch(new RegistrationEvent($this->userId)); }); } diff --git a/config/autoload/listeners.php b/config/autoload/listeners.php index 8a2c7a2..ce45341 100644 --- a/config/autoload/listeners.php +++ b/config/autoload/listeners.php @@ -12,4 +12,5 @@ declare(strict_types=1); return [ Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::class, Hyperf\Command\Listener\FailToHandleListener::class, + App\Listener\FirstRegistrationListener::class, ];