|
|
@@ -1,220 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace App\Jobs\Manager\Process;
|
|
|
-
|
|
|
-use Illuminate\Bus\Queueable;
|
|
|
-use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
|
-use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
-use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
-use Illuminate\Queue\InteractsWithQueue;
|
|
|
-use Illuminate\Queue\SerializesModels;
|
|
|
-use App\Facades\Servers\Logs\Log;
|
|
|
-use App\Servers\Email\VerifyCode as EmailVerifyCode;
|
|
|
-use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
|
|
|
-use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
|
|
|
-use App\Models\Manager\Process\ViolationProductMember as ViolationProductMemberModel;
|
|
|
-use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
|
|
|
-use Illuminate\Support\Carbon;
|
|
|
-use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
|
|
|
-use App\Models\Manager\Process\ViolationStoreMember as ViolationStoreMemberModel;
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 订阅邮件通知
|
|
|
- * @author 唐远望
|
|
|
- * @version 1.0
|
|
|
- * @date 2026-03-30
|
|
|
- */
|
|
|
-class SubEmailJobs implements ShouldQueue
|
|
|
-{
|
|
|
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
- protected $message_data;
|
|
|
- /**
|
|
|
- * Create a new job instance.
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function __construct(array $message_data)
|
|
|
- {
|
|
|
- $this->message_data = $message_data;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Execute the job.
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function handle()
|
|
|
- {
|
|
|
- try {
|
|
|
- $notice_type = $this->message_data['notice_type'];
|
|
|
- $company_id = $this->message_data['company_id'];
|
|
|
- switch ($notice_type) {
|
|
|
- case 'low_price_goods':
|
|
|
- $this->send_low_price_goods_notice($company_id);
|
|
|
- break;
|
|
|
- case 'violation_product':
|
|
|
- $this->send_violation_product($company_id);
|
|
|
- break;
|
|
|
- case 'violation_store':
|
|
|
- $this->send_violation_store($company_id);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
- Log::info('job_error', '订阅邮件通知推送队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 邮件消息消息订阅推送(低价挂网)
|
|
|
- * @author 唐远望
|
|
|
- * @version 1.0
|
|
|
- * @date 2026-03-04
|
|
|
- */
|
|
|
- private function send_low_price_goods_notice($company_id)
|
|
|
- {
|
|
|
- $EmailVerifyCode = new EmailVerifyCode();
|
|
|
- $LowPriceGoodsMemberModel = new LowPriceGoodsMemberModel();
|
|
|
- $LowPriceGoodsModel = new LowPriceGoodsModel();
|
|
|
- //获取今日待处理的商品记录
|
|
|
- $todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
- $todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
- $lowprice_ids = $LowPriceGoodsModel->where([['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd], ['company_id', '=', $company_id]])->pluck('id')->toArray();
|
|
|
- if (empty($lowprice_ids)) return true;
|
|
|
- //获取开启了通知服务的用户
|
|
|
- $usert_list = $LowPriceGoodsMemberModel
|
|
|
- ->whereIn('lowprice_product_logid', $lowprice_ids)
|
|
|
- ->join('personnel_employee', 'process_lowprice_product_member.employee_id', '=', 'personnel_employee.id')
|
|
|
- ->where('personnel_employee.open_notice', 0)
|
|
|
- ->where('personnel_employee.company_id', $company_id)
|
|
|
- ->where([['personnel_employee.email', '!=', ''], ['personnel_employee.email', '!=', null]])
|
|
|
- ->select(['process_lowprice_product_member.*', 'personnel_employee.email'])
|
|
|
- ->get()->toArray();
|
|
|
- if (empty($usert_list)) return true;
|
|
|
- //按用户统计待处理的商品数量
|
|
|
- $user_data = [];
|
|
|
- foreach ($usert_list as $key => $value) {
|
|
|
- $user_id = $value['employee_id'];
|
|
|
- if (!isset($user_data[$user_id])) {
|
|
|
- $user_data[$user_id]['employee_id'] = $user_id;
|
|
|
- $user_data[$user_id]['email'] = $value['email'];
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['lowprice_product_logid'];
|
|
|
- } else {
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['lowprice_product_logid'];
|
|
|
- }
|
|
|
- }
|
|
|
- //发送邮件
|
|
|
- foreach ($user_data as $key => $value) {
|
|
|
- $email_to = $value['email'];
|
|
|
- $totle_number = count($value['log_ids']);
|
|
|
- $email_title = '低价挂网商品提醒';
|
|
|
- $email_content = '今日待处理链接共' . $totle_number . '条,请及时登录智价云系统处理。';
|
|
|
- $EmailVerifyCode->sendSmtpEmail($email_to, $email_title, $email_content);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 邮件消息消息订阅推送(禁止挂网)
|
|
|
- * @author 唐远望
|
|
|
- * @version 1.0
|
|
|
- * @date 2026-03-04
|
|
|
- */
|
|
|
- private function send_violation_product($company_id)
|
|
|
- {
|
|
|
- $EmailVerifyCode = new EmailVerifyCode();
|
|
|
- $ViolationProductMemberModel = new ViolationProductMemberModel();
|
|
|
- $ViolationProductModel = new ViolationProductModel();
|
|
|
- //获取今日待处理的商品记录
|
|
|
- $todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
- $todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
- $violation_price_ids = $ViolationProductModel->where([['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd], ['company_id', '=', $company_id]])->pluck('id')->toArray();
|
|
|
- if (empty($violation_price_ids)) return true;
|
|
|
- //获取开启了通知服务的用户
|
|
|
- $usert_list = $ViolationProductMemberModel
|
|
|
- ->whereIn('violation_product_logid', $violation_price_ids)
|
|
|
- ->join('personnel_employee', 'process_violation_product_member.employee_id', '=', 'personnel_employee.id')
|
|
|
- ->where('personnel_employee.open_notice', 0)
|
|
|
- ->where('personnel_employee.company_id', $company_id)
|
|
|
- ->where([['personnel_employee.email', '!=', ''], ['personnel_employee.email', '!=', null]])
|
|
|
- ->select(['process_violation_product_member.*', 'personnel_employee.email'])
|
|
|
- ->get()->toArray();
|
|
|
- if (empty($usert_list)) return true;
|
|
|
- //按用户统计待处理的商品数量
|
|
|
- $user_data = [];
|
|
|
- foreach ($usert_list as $key => $value) {
|
|
|
- $user_id = $value['employee_id'];
|
|
|
- if (!isset($user_data[$user_id])) {
|
|
|
- $user_data[$user_id]['employee_id'] = $user_id;
|
|
|
- $user_data[$user_id]['email'] = $value['email'];
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['violation_product_logid'];
|
|
|
- } else {
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['violation_product_logid'];
|
|
|
- }
|
|
|
- }
|
|
|
- //发送邮件
|
|
|
- foreach ($user_data as $key => $value) {
|
|
|
- $email_to = $value['email'];
|
|
|
- $totle_number = count($value['log_ids']);
|
|
|
- $email_title = '禁止挂网商品提醒';
|
|
|
- $email_content = '今日待处理链接共' . $totle_number . '条,请及时登录智价云系统处理。';
|
|
|
- $EmailVerifyCode->sendSmtpEmail($email_to, $email_title, $email_content);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 邮件消息消息订阅推送(禁止店铺)
|
|
|
- * @author 唐远望
|
|
|
- * @version 1.0
|
|
|
- * @date 2026-03-04
|
|
|
- */
|
|
|
- private function send_violation_store($company_id){
|
|
|
- $EmailVerifyCode = new EmailVerifyCode();
|
|
|
- $ViolationStoreMemberModel = new ViolationStoreMemberModel();
|
|
|
- $ViolationStoreModel = new ViolationStoreModel();
|
|
|
- //获取今日待处理的店铺记录
|
|
|
- $todayStart = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
|
|
|
- $todayEnd = Carbon::today()->endOfDay()->getTimestamp(); // 今天结束时间 23:59:59
|
|
|
- $violation_price_ids = $ViolationStoreModel->where([['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd], ['company_id', '=', $company_id]])->pluck('id')->toArray();
|
|
|
- if (empty($violation_price_ids)) return true;
|
|
|
- //获取开启了通知服务的用户
|
|
|
- $usert_list = $ViolationStoreMemberModel
|
|
|
- ->whereIn('violation_store_logid', $violation_price_ids)
|
|
|
- ->join('personnel_employee', 'process_violation_store_member.employee_id', '=', 'personnel_employee.id')
|
|
|
- ->where('personnel_employee.open_notice', 0)
|
|
|
- ->where('personnel_employee.company_id', $company_id)
|
|
|
- ->where([['personnel_employee.email', '!=', ''], ['personnel_employee.email', '!=', null]])
|
|
|
- ->select(['process_violation_store_member.*', 'personnel_employee.email'])
|
|
|
- ->get()->toArray();
|
|
|
- if (empty($usert_list)) return true;
|
|
|
- //按用户统计待处理的商品数量
|
|
|
- $user_data = [];
|
|
|
- foreach ($usert_list as $key => $value) {
|
|
|
- $user_id = $value['employee_id'];
|
|
|
- if (!isset($user_data[$user_id])) {
|
|
|
- $user_data[$user_id]['employee_id'] = $user_id;
|
|
|
- $user_data[$user_id]['email'] = $value['email'];
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['violation_store_logid'];
|
|
|
- } else {
|
|
|
- $user_data[$user_id]['log_ids'][] = $value['violation_store_logid'];
|
|
|
- }
|
|
|
- }
|
|
|
- //发送邮件
|
|
|
- foreach ($user_data as $key => $value) {
|
|
|
- $email_to = $value['email'];
|
|
|
- $totle_number = count($value['log_ids']);
|
|
|
- $email_title = '禁止挂网店铺提醒';
|
|
|
- $email_content = '今日待处理店铺共' . $totle_number . '条,请及时登录智价云系统处理。';
|
|
|
- $EmailVerifyCode->sendSmtpEmail($email_to, $email_title, $email_content);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- public function failed(\Throwable $exception)
|
|
|
- {
|
|
|
- Log::info('job_error', '订阅邮件通知推送队列完全失败', ['data' => $this->message_data, 'error' => $exception]);
|
|
|
- }
|
|
|
-}
|