Commit d58e92e2 authored by hangjun83's avatar hangjun83

财务开票模块更新

parent c9179618
...@@ -531,7 +531,7 @@ class InvoiceService ...@@ -531,7 +531,7 @@ class InvoiceService
$message .= "<a href=".$downloadUrl."电子发票下载地址</a>"; $message .= "<a href=".$downloadUrl."电子发票下载地址</a>";
$this->mailService->sendMail($title, 'hangjun@rhawn.cn',$message); $this->mailService->sendMailToHtml($title, 'hangjun@rhawn.cn',$message);
} }
public function getInvoicePdfDownloadUrl() public function getInvoicePdfDownloadUrl()
......
<?php <?php
namespace App\Mailer; namespace App\Mailer;
use App\Providers\MailerServiceProvider;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
class MailService{ class MailService{
private $type; public function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
$this->registerProvider($this->getMailAccountConfig());
}
public function setFromType($type) public function setFromType($type)
{ {
...@@ -22,27 +28,26 @@ class MailService{ ...@@ -22,27 +28,26 @@ class MailService{
$this->registerProvider($this->getMailAccountConfig($this->type)); $this->registerProvider($this->getMailAccountConfig($this->type));
} }
public function getMailAccountConfig() public function getMailAccountConfig($emailSmtp = 'rhawn')
{ {
$username = env("MAIL_USERNAME");
$password = env("MAIL_PASSWORD");
$address = env("MAIL_FROM_ADDRESS");
$fromName = env("MAIL_FROM_NAME");
$config = config('mail'); $config = config('mail');
$config['mailers']['smtp']['host'] = env(strtoupper($emailSmtp)."_MAIL_HOST");
$config['username'] = $username; $config['mailers']['smtp']['port'] = env(strtoupper($emailSmtp)."_MAIL_PORT");
$config['password'] = $password; $config['mailers']['smtp']['encryption'] = env(strtoupper($emailSmtp)."_MAIL_ENCRYPTION");
$config['from']['address'] = $address; $config['mailers']['smtp']['username'] = env(strtoupper($emailSmtp)."_MAIL_USERNAME");
$config['from']['name'] = $fromName; $config['mailers']['smtp']['password'] = env(strtoupper($emailSmtp)."_MAIL_PASSWORD");
$config['from']['address'] = env(strtoupper($emailSmtp)."_MAIL_FROM_ADDRESS");
$config['from']['name'] = env(strtoupper($emailSmtp)."_MAIL_FROM_NAME");
return $config; return $config;
} }
public function registerProvider($config) public function registerProvider($config)
{ {
config(['mail' => $config]); app('config')->set(['mail' => $config]);
app()->register(\Illuminate\Mail\MailServiceProvider::class); $mailerServiceProvider = app(MailerServiceProvider::class);
//$mailerServiceProvider->setMailerPlatform('rhawn');
app()->register($mailerServiceProvider);
} }
public function sendMail($title, $toUser, $message) public function sendMail($title, $toUser, $message)
...@@ -54,4 +59,9 @@ class MailService{ ...@@ -54,4 +59,9 @@ class MailService{
}); });
} }
public function sendMailToHtml($title, $toUser, $message)
{
$this->mailer->html('emails.invoice',['message'=> $message]);
}
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment