正在显示
13 个修改的文件
包含
424 行增加
和
2 行删除
app/Console/Commands/Task/EmailGroupSend.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Task; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Mail\TextMail; | ||
| 7 | +use App\Models\Subscribe\GroupSendTask; | ||
| 8 | +use App\Models\Subscribe\GroupSendTaskLog; | ||
| 9 | +use App\Models\Subscribe\Smtp; | ||
| 10 | +use Illuminate\Console\Command; | ||
| 11 | +use Illuminate\Support\Facades\Config; | ||
| 12 | +use Illuminate\Support\Facades\Mail; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * | ||
| 16 | + * Class TaskDistribution | ||
| 17 | + * @package App\Console\Commands | ||
| 18 | + * @author zbj | ||
| 19 | + * @date 2023/11/28 | ||
| 20 | + */ | ||
| 21 | +class EmailGroupSend extends Command | ||
| 22 | +{ | ||
| 23 | + | ||
| 24 | + protected $signature = 'email_group_send_task'; | ||
| 25 | + protected $description = '邮件群发任务'; | ||
| 26 | + | ||
| 27 | + public function handle() | ||
| 28 | + { | ||
| 29 | + while (true) { | ||
| 30 | + $tasks = GroupSendTask::where('status', GroupSendTask::STATUS_PENDING)->where('send_time', '<=', time())->get(); | ||
| 31 | + if (!$tasks->count()) { | ||
| 32 | + sleep(10); | ||
| 33 | + } | ||
| 34 | + foreach ($tasks as $task) { | ||
| 35 | + $this->toQueue($task); | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public function toQueue(GroupSendTask $task) | ||
| 41 | + { | ||
| 42 | + $this->output('开始执行任务:' . $task->id); | ||
| 43 | + $smtp_config = Smtp::where('project_id', $task->project_id)->first(); | ||
| 44 | + if (!$smtp_config) { | ||
| 45 | + $task->status = GroupSendTask::STATUS_ERROR; | ||
| 46 | + $task->remark = '未配置SMTP'; | ||
| 47 | + $task->save(); | ||
| 48 | + | ||
| 49 | + $this->output('任务:' . $task->id . '失败,未配置SMTP'); | ||
| 50 | + return false; | ||
| 51 | + } | ||
| 52 | + Config::set('mail.mailers.smtp.host', $smtp_config['host']); | ||
| 53 | + Config::set('mail.mailers.smtp.username', $smtp_config['email']); | ||
| 54 | + Config::set('mail.mailers.smtp.password', $smtp_config['password']); | ||
| 55 | + Config::set('mail.from.address', $smtp_config['email']); | ||
| 56 | + Config::set('mail.from.name', $smtp_config['from_name']); | ||
| 57 | + foreach ($task->emails as $email) { | ||
| 58 | + try { | ||
| 59 | + Mail::to([$email])->send(new TextMail(['subject' => $task->subject, 'text' => $task->text])); | ||
| 60 | + GroupSendTaskLog::addLog($task->id, $task->project_id, $smtp_config['email'], $email); | ||
| 61 | + } catch (\Exception $e) { | ||
| 62 | + GroupSendTaskLog::addLog($task->id, $task->project_id, $smtp_config['email'], $email, 2, $e->getMessage()); | ||
| 63 | + $this->output('任务:' . $task->id . ' 邮箱' . $email . '发送失败,' . $e->getMessage()); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + $task->status = GroupSendTask::STATUS_SUCCESS; | ||
| 67 | + $task->save(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 输出处理日志 | ||
| 72 | + */ | ||
| 73 | + public function output($message): bool | ||
| 74 | + { | ||
| 75 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 76 | + return true; | ||
| 77 | + } | ||
| 78 | +} |
| @@ -15,6 +15,7 @@ use App\Models\RouteMap\RouteMap; | @@ -15,6 +15,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 15 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 15 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 16 | use App\Models\User\ProjectRole as ProjectRoleModel; | 16 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 17 | use App\Models\User\User; | 17 | use App\Models\User\User; |
| 18 | +use Illuminate\Database\Eloquent\Model; | ||
| 18 | use Illuminate\Support\Facades\Cache; | 19 | use Illuminate\Support\Facades\Cache; |
| 19 | 20 | ||
| 20 | /*** | 21 | /*** |
| @@ -109,6 +110,10 @@ class ComController extends BaseController | @@ -109,6 +110,10 @@ class ComController extends BaseController | ||
| 109 | if($projectCode != 1){ | 110 | if($projectCode != 1){ |
| 110 | $info['role_menu'] = trim(str_replace(',50,',',',','.$info['role_menu'].','),','); | 111 | $info['role_menu'] = trim(str_replace(',50,',',',','.$info['role_menu'].','),','); |
| 111 | } | 112 | } |
| 113 | + $is_subscribe = $this->getIsSubscribe(); | ||
| 114 | + if(!$is_subscribe){ | ||
| 115 | + $info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),','); | ||
| 116 | + } | ||
| 112 | $this->map = [ | 117 | $this->map = [ |
| 113 | 'status'=>0, | 118 | 'status'=>0, |
| 114 | 'is_role'=>0, | 119 | 'is_role'=>0, |
| @@ -217,6 +222,11 @@ class ComController extends BaseController | @@ -217,6 +222,11 @@ class ComController extends BaseController | ||
| 217 | return 0; | 222 | return 0; |
| 218 | } | 223 | } |
| 219 | 224 | ||
| 225 | + | ||
| 226 | + public function getIsSubscribe(){ | ||
| 227 | + return $this->project['is_subscribe']; | ||
| 228 | + } | ||
| 229 | + | ||
| 220 | /** | 230 | /** |
| 221 | * @name :登录用户编辑资料/修改密码 | 231 | * @name :登录用户编辑资料/修改密码 |
| 222 | * @author :liyuhang | 232 | * @author :liyuhang |
| @@ -26,6 +26,7 @@ class BaseController extends Controller | @@ -26,6 +26,7 @@ class BaseController extends Controller | ||
| 26 | protected $map = [];//处理后的参数 | 26 | protected $map = [];//处理后的参数 |
| 27 | protected $uid = 0; | 27 | protected $uid = 0; |
| 28 | protected $user = [];//当前登录用户详情 | 28 | protected $user = [];//当前登录用户详情 |
| 29 | + protected $project = [];//当前登录项目详情 | ||
| 29 | /** | 30 | /** |
| 30 | * ceshi获取所有参数 | 31 | * ceshi获取所有参数 |
| 31 | */ | 32 | */ |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Subscribe; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Enums\Common\Code; | ||
| 7 | +use App\Helper\Arr; | ||
| 8 | +use App\Http\Controllers\Bside\BaseController; | ||
| 9 | +use App\Http\Logic\Bside\Inquiry\InquiryLogic; | ||
| 10 | +use App\Models\Inquiry\InquiryForm; | ||
| 11 | +use App\Models\Subscribe\Email; | ||
| 12 | +use App\Models\Subscribe\GroupSendTask; | ||
| 13 | +use App\Models\Subscribe\Smtp; | ||
| 14 | +use App\Rules\Ids; | ||
| 15 | +use App\Services\BatchExportService; | ||
| 16 | +use Illuminate\Http\Request; | ||
| 17 | +use Illuminate\Support\Facades\Storage; | ||
| 18 | +use Illuminate\Support\Str; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 订阅邮件管理 | ||
| 22 | + * Class EmailController | ||
| 23 | + * @package App\Http\Controllers\Bside\Subscribe | ||
| 24 | + * @author zbj | ||
| 25 | + * @date 2024/8/29 | ||
| 26 | + */ | ||
| 27 | +class EmailController extends BaseController | ||
| 28 | +{ | ||
| 29 | + | ||
| 30 | + public function list(Email $emailModel) | ||
| 31 | + { | ||
| 32 | + $lists = $emailModel->lists($this->map, $this->page, $this->row); | ||
| 33 | + $this->response('success', Code::SUCCESS, $lists); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public function delete(Email $emailModel) | ||
| 37 | + { | ||
| 38 | + $this->request->validate([ | ||
| 39 | + 'id' => 'required', | ||
| 40 | + ], [ | ||
| 41 | + 'id.required' => 'id不为空', | ||
| 42 | + ]); | ||
| 43 | + $emailModel->del(['id' => $this->param['id']]); | ||
| 44 | + $this->response('success'); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + public function export(Email $emailModel) | ||
| 49 | + { | ||
| 50 | + $data = $emailModel->list([], 'id', ['*'], 'desc', 1000); | ||
| 51 | + //生成文件,发送到客户端 | ||
| 52 | + $map = [ | ||
| 53 | + 'email' => '邮箱', | ||
| 54 | + 'created_at' => '订阅时间', | ||
| 55 | + ]; | ||
| 56 | + $table = new BatchExportService("订阅邮箱导出"); | ||
| 57 | + $file = $table->head($map)->data($data)->save(); | ||
| 58 | + if (!$file) { | ||
| 59 | + throw new \Exception('文件生成失败,请重试'); | ||
| 60 | + } | ||
| 61 | + $fileurl = Storage::disk('runtime')->url($file); | ||
| 62 | + $this->response('success', Code::SUCCESS, ['url' => $fileurl]); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + public function set_smtp(Smtp $smtp) | ||
| 67 | + { | ||
| 68 | + $this->request->validate([ | ||
| 69 | + 'project_id' => ['required'], | ||
| 70 | + 'email' => ['required', 'email', 'max:200'], | ||
| 71 | + 'password' => ['required', 'max:200'], | ||
| 72 | + 'host' => ['required', 'max:200', 'regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/'], | ||
| 73 | + 'from_name' => ['required', 'max:200'], | ||
| 74 | + ], [ | ||
| 75 | + 'project_id.required' => '参数异常', | ||
| 76 | + 'email.required' => '邮箱必须', | ||
| 77 | + 'email.email' => '邮箱格式错误', | ||
| 78 | + 'password.required' => '授权码/密码必须', | ||
| 79 | + 'host.required' => 'smtp地址必须', | ||
| 80 | + 'host.regex' => 'smtp格式错误', | ||
| 81 | + 'from_name.required' => '发信人昵称必须', | ||
| 82 | + ]); | ||
| 83 | + $info = $smtp->read(['project_id' => $this->param['project_id']]); | ||
| 84 | + if (!$info) { | ||
| 85 | + $smtp->add($this->param); | ||
| 86 | + } else { | ||
| 87 | + $smtp->edit($this->param, ['project_id' => $this->param['project_id']]); | ||
| 88 | + } | ||
| 89 | + $this->response('success'); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public function group_send(GroupSendTask $groupSendTask) | ||
| 93 | + { | ||
| 94 | + $this->request->validate([ | ||
| 95 | + 'project_id' => ['required'], | ||
| 96 | + 'emails' => ['required'], | ||
| 97 | + 'subject' => ['required'], | ||
| 98 | + 'text' => ['required'], | ||
| 99 | + ], [ | ||
| 100 | + 'project_id.required' => '参数异常', | ||
| 101 | + 'emails.required' => '发送对象必须', | ||
| 102 | + 'subject.required' => '邮件主题必须', | ||
| 103 | + 'host.required' => 'smtp地址必须', | ||
| 104 | + ]); | ||
| 105 | + if($this->param['send_time'] && !strtotime($this->param['send_time'])){ | ||
| 106 | + $this->fail('发送时间格式错误',Code::USER_ERROR); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + $smtp = new Smtp(); | ||
| 110 | + $info = $smtp->read(['project_id' => $this->param['project_id']]); | ||
| 111 | + if(!$info){ | ||
| 112 | + $this->fail('请先设置SMTP',Code::USER_ERROR); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + $this->param['emails'] = Arr::a2s($this->param['emails']); | ||
| 116 | + $this->param['send_time'] = empty($this->param['send_time']) ? 0 : strtotime($this->param['send_time']); | ||
| 117 | + $this->param['user_id'] = $this->user['id']; | ||
| 118 | + $groupSendTask->add($this->param); | ||
| 119 | + $this->response('success'); | ||
| 120 | + } | ||
| 121 | +} |
| @@ -191,6 +191,7 @@ class UserLoginLogic | @@ -191,6 +191,7 @@ class UserLoginLogic | ||
| 191 | } | 191 | } |
| 192 | $info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority']; | 192 | $info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority']; |
| 193 | $info['is_inquiry_country'] = $project['is_inquiry_country']; | 193 | $info['is_inquiry_country'] = $project['is_inquiry_country']; |
| 194 | + $info['is_subscribe'] = $project['is_subscribe']; | ||
| 194 | //是否开通AMP | 195 | //是否开通AMP |
| 195 | $is_amp = 0; | 196 | $is_amp = 0; |
| 196 | if(!empty($project['deploy_optimize']['domain'])){ | 197 | if(!empty($project['deploy_optimize']['domain'])){ |
| @@ -299,6 +300,7 @@ class UserLoginLogic | @@ -299,6 +300,7 @@ class UserLoginLogic | ||
| 299 | } | 300 | } |
| 300 | $info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority']; | 301 | $info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority']; |
| 301 | $info['is_inquiry_country'] = $project['is_inquiry_country']; | 302 | $info['is_inquiry_country'] = $project['is_inquiry_country']; |
| 303 | + $info['is_subscribe'] = $project['is_subscribe']; | ||
| 302 | //是否开通AMP | 304 | //是否开通AMP |
| 303 | $is_amp = 0; | 305 | $is_amp = 0; |
| 304 | if(!empty($project['deploy_optimize']['domain'])){ | 306 | if(!empty($project['deploy_optimize']['domain'])){ |
app/Mail/TextMail.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Mail; | ||
| 4 | + | ||
| 5 | +use Illuminate\Bus\Queueable; | ||
| 6 | +use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 7 | +use Illuminate\Mail\Mailable; | ||
| 8 | +use Illuminate\Queue\SerializesModels; | ||
| 9 | + | ||
| 10 | +class TextMail extends Mailable | ||
| 11 | +{ | ||
| 12 | + use Queueable, SerializesModels; | ||
| 13 | + | ||
| 14 | + protected string $text; | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * Create a new message instance. | ||
| 18 | + * | ||
| 19 | + * @return void | ||
| 20 | + */ | ||
| 21 | + public function __construct($data) | ||
| 22 | + { | ||
| 23 | + $this->subject = $data['subject']; | ||
| 24 | + $this->text = $data['text']; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * Build the message. | ||
| 29 | + * | ||
| 30 | + * @return $this | ||
| 31 | + */ | ||
| 32 | + public function build() | ||
| 33 | + { | ||
| 34 | + return $this->subject($this->subject)->view('mail.text', ['text' => $this->text]); | ||
| 35 | + } | ||
| 36 | +} |
app/Models/Subscribe/Email.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Subscribe; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | +/** | ||
| 8 | + * Class Email | ||
| 9 | + * @package App\Models\Subscribe | ||
| 10 | + * @author zbj | ||
| 11 | + * @date 2024/8/27 | ||
| 12 | + */ | ||
| 13 | +class Email extends Base | ||
| 14 | +{ | ||
| 15 | + use SoftDeletes; | ||
| 16 | + | ||
| 17 | + //设置关联表名 | ||
| 18 | + /** | ||
| 19 | + * @var mixed | ||
| 20 | + */ | ||
| 21 | + protected $connection = "custom_mysql"; | ||
| 22 | + protected $table = 'gl_subscribe_email'; | ||
| 23 | + | ||
| 24 | +} |
app/Models/Subscribe/GroupSendTask.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Subscribe; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\Base; | ||
| 7 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 8 | +/** | ||
| 9 | + * Class GroupSendTask | ||
| 10 | + * @package App\Models\Subscribe | ||
| 11 | + * @author zbj | ||
| 12 | + * @date 2024/8/27 | ||
| 13 | + */ | ||
| 14 | +class GroupSendTask extends Base | ||
| 15 | +{ | ||
| 16 | + use SoftDeletes; | ||
| 17 | + | ||
| 18 | + const STATUS_PENDING = 0; | ||
| 19 | + const STATUS_QUEUE = 1; | ||
| 20 | + const STATUS_SUCCESS = 2; | ||
| 21 | + const STATUS_ERROR = 9; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + //设置关联表名 | ||
| 25 | + /** | ||
| 26 | + * @var mixed | ||
| 27 | + */ | ||
| 28 | + protected $table = 'gl_email_group_send_task'; | ||
| 29 | + | ||
| 30 | +// public function setEmailsAttribute($value){ | ||
| 31 | +// $this->attributes['emails'] = Arr::a2s($value); | ||
| 32 | +// } | ||
| 33 | + | ||
| 34 | + public function getEmailsAttribute($value){ | ||
| 35 | + return Arr::s2a($value); | ||
| 36 | + } | ||
| 37 | +} |
app/Models/Subscribe/GroupSendTaskLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Subscribe; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | +/** | ||
| 8 | + * Class GroupSendTaskLog | ||
| 9 | + * @package App\Models\Subscribe | ||
| 10 | + * @author zbj | ||
| 11 | + * @date 2024/8/27 | ||
| 12 | + */ | ||
| 13 | +class GroupSendTaskLog extends Base | ||
| 14 | +{ | ||
| 15 | + use SoftDeletes; | ||
| 16 | + | ||
| 17 | + //设置关联表名 | ||
| 18 | + /** | ||
| 19 | + * @var mixed | ||
| 20 | + */ | ||
| 21 | + protected $table = 'gl_email_group_send_task_log'; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + //`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
| 25 | + // `task_id` int(11) unsigned NOT NULL DEFAULT '0', | ||
| 26 | + // `project_id` int(11) unsigned NOT NULL DEFAULT '0', | ||
| 27 | + // `from` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
| 28 | + // `to` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
| 29 | + // `status` tinyint(1) unsigned NOT NULL DEFAULT '0', | ||
| 30 | + // `manage_id` int(11) unsigned NOT NULL DEFAULT '0', | ||
| 31 | + // `created_at` datetime NOT NULL, | ||
| 32 | + // `updated_at` datetime NOT NULL, | ||
| 33 | + // `deleted_at` datetime DEFAULT NULL, | ||
| 34 | + // `remark` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
| 35 | + | ||
| 36 | + public static function addLog($task_id, $project_id, $from, $to, $status = 1, $remark = '') | ||
| 37 | + { | ||
| 38 | + $model = new self(); | ||
| 39 | + $model->task_id = $task_id; | ||
| 40 | + $model->project_id = $project_id; | ||
| 41 | + $model->from = $from; | ||
| 42 | + $model->to = $to; | ||
| 43 | + $model->status = $status; | ||
| 44 | + $model->remark = $remark; | ||
| 45 | + $model->save(); | ||
| 46 | + } | ||
| 47 | +} |
app/Models/Subscribe/Smtp.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Subscribe; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | +/** | ||
| 8 | + * Class Smtp | ||
| 9 | + * @package App\Models\Subscribe | ||
| 10 | + * @author zbj | ||
| 11 | + * @date 2024/8/27 | ||
| 12 | + */ | ||
| 13 | +class Smtp extends Base | ||
| 14 | +{ | ||
| 15 | + use SoftDeletes; | ||
| 16 | + | ||
| 17 | + //设置关联表名 | ||
| 18 | + /** | ||
| 19 | + * @var mixed | ||
| 20 | + */ | ||
| 21 | + protected $table = 'gl_email_smtp'; | ||
| 22 | + | ||
| 23 | +} |
| @@ -8,8 +8,10 @@ use App\Models\Inquiry\InquiryForm; | @@ -8,8 +8,10 @@ use App\Models\Inquiry\InquiryForm; | ||
| 8 | use App\Models\Inquiry\InquiryFormData; | 8 | use App\Models\Inquiry\InquiryFormData; |
| 9 | use App\Models\Project\InquiryFilterConfig; | 9 | use App\Models\Project\InquiryFilterConfig; |
| 10 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 11 | +use App\Models\Subscribe\Email; | ||
| 11 | use App\Models\SyncSubmitTask\SyncSubmitTask; | 12 | use App\Models\SyncSubmitTask\SyncSubmitTask; |
| 12 | use App\Models\Visit\Visit; | 13 | use App\Models\Visit\Visit; |
| 14 | +use App\Utils\LogUtils; | ||
| 13 | use Illuminate\Support\Facades\Http; | 15 | use Illuminate\Support\Facades\Http; |
| 14 | use Illuminate\Support\Facades\URL; | 16 | use Illuminate\Support\Facades\URL; |
| 15 | use Illuminate\Support\Str; | 17 | use Illuminate\Support\Str; |
| @@ -52,6 +54,20 @@ class SyncSubmitTaskService | @@ -52,6 +54,20 @@ class SyncSubmitTaskService | ||
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | $action = $task['type']; | 56 | $action = $task['type']; |
| 57 | + | ||
| 58 | + //是否是订阅邮箱 | ||
| 59 | + if($action == 'inquiry' && !empty($project['is_subscribe'])){ | ||
| 60 | + //是否只有email字段 | ||
| 61 | + $filed = ''; | ||
| 62 | + foreach ($data['data']['data'] as $k => $v){ | ||
| 63 | + if(Str::startsWith(strtolower($k),'globalso-')){ | ||
| 64 | + continue; | ||
| 65 | + } | ||
| 66 | + $filed .= $k; | ||
| 67 | + } | ||
| 68 | + $filed == 'email' && $action = 'subscribe'; | ||
| 69 | + } | ||
| 70 | + | ||
| 55 | $handler = new self(); | 71 | $handler = new self(); |
| 56 | return $handler->$action($data, $date); | 72 | return $handler->$action($data, $date); |
| 57 | } | 73 | } |
| @@ -75,7 +91,25 @@ class SyncSubmitTaskService | @@ -75,7 +91,25 @@ class SyncSubmitTaskService | ||
| 75 | return $referer; | 91 | return $referer; |
| 76 | } | 92 | } |
| 77 | 93 | ||
| 78 | - | 94 | + /** |
| 95 | + * | ||
| 96 | + * 订阅邮箱 | ||
| 97 | + * @param $data | ||
| 98 | + * @param $date | ||
| 99 | + * @throws InquiryFilterException | ||
| 100 | + * @author zbj | ||
| 101 | + * @date 2024/8/27 | ||
| 102 | + */ | ||
| 103 | + public function subscribe($data, $date){ | ||
| 104 | + $email = $data['data']['data']['email']; | ||
| 105 | + if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | ||
| 106 | + $model = new Email(); | ||
| 107 | + $model->email = $email; | ||
| 108 | + $model->save(); | ||
| 109 | + }else{ | ||
| 110 | + throw new InquiryFilterException( '邮箱格式异常:' . $email); | ||
| 111 | + } | ||
| 112 | + } | ||
| 79 | 113 | ||
| 80 | /** | 114 | /** |
| 81 | * 询盘 | 115 | * 询盘 |
| @@ -87,7 +121,6 @@ class SyncSubmitTaskService | @@ -87,7 +121,6 @@ class SyncSubmitTaskService | ||
| 87 | */ | 121 | */ |
| 88 | public function inquiry($data, $date) | 122 | public function inquiry($data, $date) |
| 89 | { | 123 | { |
| 90 | - | ||
| 91 | $this->inquiryFilter($data['project_id'], $data); | 124 | $this->inquiryFilter($data['project_id'], $data); |
| 92 | 125 | ||
| 93 | //数组key转为小写 | 126 | //数组key转为小写 |
resources/views/mail/text.blade.php
0 → 100644
| 1 | +{{$text}} |
| @@ -608,6 +608,15 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -608,6 +608,15 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 608 | Route::any('/getInfo', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'getInfo'])->name('operation_heartbeat_getInfo'); | 608 | Route::any('/getInfo', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'getInfo'])->name('operation_heartbeat_getInfo'); |
| 609 | 609 | ||
| 610 | }); | 610 | }); |
| 611 | + | ||
| 612 | + //订阅邮件管理 | ||
| 613 | + Route::prefix('subscribe')->group(function () { | ||
| 614 | + Route::any('/', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'list'])->name('subscribe_email_list'); | ||
| 615 | + Route::any('/del', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'delete'])->name('subscribe_email_del'); | ||
| 616 | + Route::any('/export', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'export'])->name('subscribe_email_export'); | ||
| 617 | + Route::any('/set_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'set_smtp'])->name('subscribe_email_set_smtp'); | ||
| 618 | + Route::any('/group_send', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'group_send'])->name('subscribe_email_group_send'); | ||
| 619 | + }); | ||
| 611 | }); | 620 | }); |
| 612 | //无需登录验证的路由组 | 621 | //无需登录验证的路由组 |
| 613 | Route::group([], function () { | 622 | Route::group([], function () { |
-
请 注册 或 登录 后发表评论