feat : wx login

This commit is contained in:
2025-03-24 09:26:43 +08:00
parent f98b9f1ff7
commit 8925d4bbd8
2 changed files with 13 additions and 2 deletions

View File

@@ -11,19 +11,28 @@ declare(strict_types=1);
namespace App\Service\Api\Login; namespace App\Service\Api\Login;
use App\Constants\Common\ThirdCode; use App\Constants\Common\ThirdCode;
use App\Event\RegistrationEvent;
use App\Exception\ErrException; use App\Exception\ErrException;
use App\Model\UserAccount; use App\Model\UserAccount;
use App\Model\UserThird; use App\Model\UserThird;
use App\Service\ServiceTrait\Api\WxMiniTrait; use App\Service\ServiceTrait\Api\WxMiniTrait;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use RedisException; use RedisException;
class WxFastLoginService extends LoginBaseService class WxFastLoginService extends LoginBaseService
{ {
use WxMiniTrait; use WxMiniTrait;
/**
* @var EventDispatcherInterface
*/
#[Inject]
private EventDispatcherInterface $eventDispatcher;
/** /**
* 登录类型 2=微信小程序 * 登录类型 2=微信小程序
*/ */
@@ -101,8 +110,9 @@ class WxFastLoginService extends LoginBaseService
// 邀请过来的 邀请方有没有奖励 被邀请方有没有奖励 // 邀请过来的 邀请方有没有奖励 被邀请方有没有奖励
$this->checkInvite(); $this->checkInvite();
// 有没有注册奖励 // 有没有注册奖励 事件机制
$this->addCoupon(); // $this->addCoupon();
$this->eventDispatcher->dispatch(new RegistrationEvent($this->userId));
}); });
} }

View File

@@ -12,4 +12,5 @@ declare(strict_types=1);
return [ return [
Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::class, Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::class,
Hyperf\Command\Listener\FailToHandleListener::class, Hyperf\Command\Listener\FailToHandleListener::class,
App\Listener\FirstRegistrationListener::class,
]; ];