123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- namespace App\Services\Common;
- use App\Jobs\EmailJob;
- use Illuminate\Support\Facades\Cache;
- class EmailService
- {
-
- const TEMPLATE_TEST="mail_test";
-
- const TEMPLATE_VALIDATION="mail_vaildation";
-
- const TEMPLATE_PASSWORD_RESET="mail_password_reset";
-
- const TEMPLATE_SEND_RESUME = 'mail_send_resume';
-
- const TEMPLATE_SEND_CONTENT = 'mail_send_content';
-
- const TEMPLATE_JOBFAIR_APPLY_OK = 'mail_jobfair_apply_ok';
-
- const TEMPLATE_JOBFAIR_APPLY_ERROR = 'mail_jobfair_apply_error';
-
- const TEMPLATE_INVITE_INTERVIEWS = 'mail_invite';
-
- const TEMPLATE_MAIL_JOBSNOTALLOW = 'mail_jobsnotallow';
-
- const TEMPLATE_MAIL_JOBSALLOW = 'mail_jobsallow';
-
- protected $callback;
-
- protected $authTag;
- protected $check_route;
-
- public function __construct()
- {
- $this->callback = [];
- $this->authTag='none';
- $this->check_route="email.check";
- }
-
- public function sendMail($email, string $templateId, array $titleParams = [], array $contentParams = [])
- {
- $emailJob=new EmailJob($email, $templateId, $titleParams, $contentParams);
- $emailJob->setCallback($this->callback);
- dispatch($emailJob);
- }
-
- public function sendAuthMail($email, string $templateId)
- {
- $emailJob=new EmailJob($email, $templateId, [], [], true);
- $emailJob->setCallback($this->callback);
- $emailJob->setTag($this->authTag);
- $emailJob->setCheckRoute($this->check_route);
- dispatch($emailJob);
- }
-
- public function checkAuthEmail(string $code)
- {
- $result=Cache::pull($code, null);
- return $result;
- }
-
- public function sendBatchSms(array $mobiles, string $templateId, array $params = [])
- {
-
- }
-
- public function setCallback(string $obj, string $method, array $args)
- {
- $this->callback[]=[$obj, $method];
- $this->callback[]=$args;
- return $this;
- }
- public function setAuthTag(string $tag)
- {
- $this->authTag=$tag;
- return $this;
- }
-
- public function setCheckRoute(string $check_route)
- {
- $this->check_route = $check_route;
- return $this;
- }
- }
|