Commit 193dcac2 authored by hj's avatar hj

更新提交

parent ffd831f8
...@@ -12,6 +12,7 @@ use App\Mailer\MailService; ...@@ -12,6 +12,7 @@ use App\Mailer\MailService;
use App\Repositories\Contracts\ThirdApiPlatformRepository; use App\Repositories\Contracts\ThirdApiPlatformRepository;
use App\Repositories\Transformers\Finance\InvoiceRecordStatusDetailTransformer; use App\Repositories\Transformers\Finance\InvoiceRecordStatusDetailTransformer;
use App\Repositories\Transformers\Finance\InvoiceRecordTransformer; use App\Repositories\Transformers\Finance\InvoiceRecordTransformer;
use App\Services\EmailSendLogsService;
use App\Services\ThirdPlatform\PlatformBaseService; use App\Services\ThirdPlatform\PlatformBaseService;
use App\Support\Facades\SimpleLogs; use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers; use App\Support\Traits\Helpers;
...@@ -671,8 +672,11 @@ class InvoiceService ...@@ -671,8 +672,11 @@ class InvoiceService
} }
if($cusInfo){ if($cusInfo){
$cusInfo = current($cusInfo); $cusInfo = current($cusInfo);
$this->mailService->sendMailToHtml($invoiceParams['invoice_platform'], $title, $cusInfo['cus_invoice_email'],$message); $result = $this->mailService->sendMailToHtml($invoiceParams['invoice_platform'], $title, $cusInfo['cus_invoice_email'],$message);
if($result){
app(EmailSendLogsService::class)->saveEmailLogs($platformName, $invoiceParams['invoice_platform'], $cusInfo, $message);
SimpleLogs::writeLog($message, __CLASS__.':'.__FUNCTION__.' 邮件发送成功:');
}
$this->apiService->storePlatformDataEntries('invoice_sended_mail_list',array_merge($sended,[$invoiceParams['invoice_real_number']])); $this->apiService->storePlatformDataEntries('invoice_sended_mail_list',array_merge($sended,[$invoiceParams['invoice_real_number']]));
} }
} }
......
...@@ -66,7 +66,7 @@ class MailService{ ...@@ -66,7 +66,7 @@ class MailService{
public function sendMailToHtml($type, $title, $toUser, $html) public function sendMailToHtml($type, $title, $toUser, $html)
{ {
$this->setFromType($type)->initSendService(); $this->setFromType($type)->initSendService();
Mail::mailer('smtp_'.$type)->html($html,function($mail) use ($toUser, $title){ return Mail::mailer('smtp_'.$type)->html($html,function($mail) use ($toUser, $title){
$mail->to($toUser); $mail->to($toUser);
$mail->subject($title); $mail->subject($title);
......
<?php
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
interface EmailSendLogsRepository extends RepositoryInterface
{
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\EmailSendLogsRepository;
use App\Repositories\Models\EmailSendLogs;
use App\Repositories\BaseRepository;
class EmailSendLogsRepositoryEloquent extends BaseRepository implements EmailSendLogsRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return EmailSendLogs::class;
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Models;
class EmailSendLogs extends Model
{
protected $table = 'email_send_logs';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'send_platform_name', 'send_platform_type', 'send_type', 'cus_name', 'cus_email', 'send_content',
'created_at', 'updated_at'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Services;
use App\Repositories\Contracts\EmailSendLogsRepository;
use App\Services\Traits\BaseService;
use App\Support\Traits\Helpers;
class EmailSendLogsService
{
use Helpers, BaseService;
public function __construct(EmailSendLogsRepository $emailSendLogsRepository)
{
$this->setRepository($emailSendLogsRepository);
}
public function saveEmailLogs($platformName, $platformType, $cusInfo, $message, $sendType = 'invoiceEmail')
{
$saveParams = [];
$saveParams['send_platform_name'] = $platformName;
$saveParams['send_platform_type'] = $platformType;
$saveParams['send_type'] = $sendType;
$saveParams['cus_name'] = $cusInfo['cus_name'];
$saveParams['cus_email'] = $cusInfo['cus_invoice_email'];
$saveParams['send_content'] = $message;
return $this->getRepository()->createOrUpdate($saveParams);
}
}
...@@ -2,14 +2,7 @@ ...@@ -2,14 +2,7 @@
namespace App\Services\Traits; namespace App\Services\Traits;
use App\Exceptions\ServerRunTimeException;
use App\Repositories\Criteria\BaseCriteria; use App\Repositories\Criteria\BaseCriteria;
use App\Services\AuthService as adminAuth;
use App\Services\Traits\DataEntriesService;
use App\Services\YyBao\Auth\AuthService as frontAuth;
use App\Services\YyBao\CustomersService;
use App\Services\YyBao\ImportExportTasksService;
use Illuminate\Support\Facades\DB;
trait BaseService trait BaseService
{ {
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEmailSendLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('email_send_logs', function (Blueprint $table) {
$table->id();
$table->string('send_platform_name')->comment('发送方')->nullable(false);
$table->string('send_platform_type')->comment('发送平台')->nullable(false);
$table->string('send_type')->comment('发送类型')->nullable(false);
$table->string('cus_name')->comment('收件方名称')->nullable(false);
$table->text('cus_email')->comment('收件方email')->nullable(false);
$table->longText('send_content')->comment('发送内容')->nullable(false);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('email_send_logs');
}
}
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