|
|
@@ -13,6 +13,7 @@ use App\Models\Manager\Process\SubNoticeLog as SubNoticeLogModel;
|
|
|
use App\Models\Manager\Process\StatisticsNotices as StatisticsNoticesModel;
|
|
|
use App\Servers\Email\VerifyCode as EmailVerifyCode;
|
|
|
use App\Servers\Sms\VerifyCode as SmsVerifyCode;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
/**
|
|
|
* 发送订阅通知
|
|
|
@@ -45,17 +46,26 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
try {
|
|
|
$company_id = $this->message_data['company_id'];
|
|
|
$SubNoticeLogModel = new SubNoticeLogModel();
|
|
|
-
|
|
|
//查询需要发送的通知,push_time等于当前时间,或者大于当前时间5分钟的通知
|
|
|
$now_time = time();
|
|
|
- $sub_notice_list = $SubNoticeLogModel->where(['company_id' => $company_id])->whereOr([['push_time', '=', $now_time], ['push_time', '>', $now_time - 300]])->get()->toarray();
|
|
|
+ $sub_notice_list = $SubNoticeLogModel->where('company_id', $company_id)
|
|
|
+ ->where(function($query) use ($now_time) {
|
|
|
+ $query->where('push_time', '=', $now_time)
|
|
|
+ ->orWhere('push_time', '>', $now_time - 300);
|
|
|
+ })
|
|
|
+ ->get();
|
|
|
if (empty($sub_notice_list)) return true;
|
|
|
//执行发送站内信
|
|
|
- $this->send_internal_msg($sub_notice_list);
|
|
|
+ $status1 = $this->send_internal_msg($sub_notice_list);
|
|
|
//执行发送邮件内容
|
|
|
- $this->send_email_content($sub_notice_list);
|
|
|
+ $status2=$this->send_email_content($sub_notice_list);
|
|
|
//执行发送短信记录
|
|
|
- // $this->send_sms_record($sub_notice_list);
|
|
|
+ $status3=$this->send_sms_record($sub_notice_list);
|
|
|
+ //获取所有$sub_notice_list ID
|
|
|
+ $id_list = array_column($sub_notice_list,'id');
|
|
|
+ if($status1 && $status2 && $status3){
|
|
|
+ $SubNoticeLogModel->whereIn('id',$id_list)->update(['status'=>'0']);
|
|
|
+ }
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
Log::info('job_error', '发送订阅通知队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
|
|
|
@@ -83,7 +93,7 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
}
|
|
|
$notices_data[] = [
|
|
|
'company_id' => $value['company_id'],
|
|
|
- 'employee_id' => $value['custom_uid'],
|
|
|
+ 'employee_id' => $value['employee_id'],
|
|
|
'title' => $value['internal_notice_content'],
|
|
|
'ext_data' => $value['ext_data'],
|
|
|
'insert_time' => time()
|
|
|
@@ -93,6 +103,7 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
$StatisticsNoticesModel->insert($notices_data);
|
|
|
//更新发送状态
|
|
|
$SubNoticeLogModel->whereIn('id', array_column($sub_notice_list, 'id'))->update(['internal_notice_status' => 0]);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -112,14 +123,19 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
continue;
|
|
|
}
|
|
|
$email_to = $value['email'];
|
|
|
+ if (empty($email_to)) {
|
|
|
+ $SubNoticeLogModel->where(['id' => $value['id']])->update(['email_status' => 0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$email_content = json_decode($value['email_content'], true);
|
|
|
- $email_title = $email_content['email_title'];
|
|
|
- $email_content = $email_content['email_content'];
|
|
|
+ $email_title = $email_content['title'];
|
|
|
+ $email_content = $email_content['content'];
|
|
|
$res_msg = $EmailVerifyCode->sendSmtpEmail($email_to, $email_title, $email_content);
|
|
|
Log::info('job_send_email', '订阅邮件通知推送队列记录', ['email' => $email_to, 'email_content' => $email_content, 'msg' => $res_msg]);
|
|
|
//更新发送状态
|
|
|
$SubNoticeLogModel->where(['id' => $value['id']])->update(['email_status' => 0]);
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -139,6 +155,10 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
continue;
|
|
|
}
|
|
|
$mobile = $value['mobile'];
|
|
|
+ if (empty($mobile)) {
|
|
|
+ $SubNoticeLogModel->where(['id' => $value['id']])->update(['status' => 0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$sms_content = json_decode($value['sms_content'], true);
|
|
|
$totle_number = $sms_content['totle_number'];
|
|
|
$number1 = $sms_content['number1'];
|
|
|
@@ -148,8 +168,9 @@ class SendNoticeJobs implements ShouldQueue
|
|
|
$res_msg = $SmsVerifyCode->sendContent($mobile, ['totle_number' => $totle_number, 'number1' => $number1, 'number2' => $number2, 'number3' => $number3], $sms_tpl_id);
|
|
|
Log::info('job_send_sms', '订阅短信通知推送队列记录', ['email' => $mobile, 'sms_tpl_id' => $sms_tpl_id, 'msg' => $res_msg]);
|
|
|
//更新发送状态
|
|
|
- $SubNoticeLogModel->where(['id' => $value['id']])->update(['status' => 0]);
|
|
|
+ $SubNoticeLogModel->where(['id' => $value['id']])->update(['sms_status' => 0]);
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|