Cocker Setup
This commit is contained in:
parent
8fdaa0ba1d
commit
8c11130b5d
191 changed files with 8152 additions and 18186 deletions
|
|
@ -38,23 +38,23 @@ class CheckPaymentsAccount extends Command
|
|||
$this->info('COMMAND [payments:check-accounts] started.');
|
||||
|
||||
// Die Logik wurde 1:1 aus der checkPaymentsAccounts-Methode übernommen
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
|
||||
$renewalDate = Carbon::now()->modify('+' . (config('mivita.remind_first_days') + 1) . ' days');
|
||||
Log::channel('cron')->info('Erneuerungsdatum für Zahlungen: ' . $renewalDate->format('Y-m-d H:i:s'));
|
||||
|
||||
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
|
||||
Log::channel('cron')->info('Found ' . $users->count() . ' users for payment reminders.');
|
||||
$this->info('Found ' . $users->count() . ' users for payment reminders.');
|
||||
|
||||
foreach ($users as $user){
|
||||
Log::channel('cron')->info('Prüfe Zahlungserinnerungen für Benutzer: ' . $user->email);
|
||||
$this->checkReminderPayments($user);
|
||||
foreach ($users as $user) {
|
||||
Log::channel('cron')->info('Prüfe Zahlungserinnerungen für Benutzer: ' . $user->email);
|
||||
$this->checkReminderPayments($user);
|
||||
}
|
||||
|
||||
|
||||
Log::channel('cron')->info('COMMAND [payments:check-accounts] finished.');
|
||||
$this->info('COMMAND [payments:check-accounts] finished.');
|
||||
return 0; // Success
|
||||
|
|
@ -79,28 +79,28 @@ class CheckPaymentsAccount extends Command
|
|||
private function checkReminderPayments(User $user)
|
||||
{
|
||||
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
|
||||
if(!$user->isActiveAccount()){
|
||||
if (!$user->isActiveAccount()) {
|
||||
Log::channel('cron')->info('Inaktives Konto für Benutzer: ' . $user->email);
|
||||
$this->checkIsReminderSend($user, 35);
|
||||
return;
|
||||
}
|
||||
|
||||
//34 reminder_last
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
|
||||
if ($user->daysActiveAccount() <= config('mivita.remind_last_days')) {
|
||||
Log::channel('cron')->info('Letzte Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$this->checkIsReminderSend($user, 34);
|
||||
return;
|
||||
}
|
||||
|
||||
//33 reminder_sec
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
|
||||
if ($user->daysActiveAccount() <= config('mivita.remind_sec_days')) {
|
||||
Log::channel('cron')->info('Zweite Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$this->checkIsReminderSend($user, 33);
|
||||
return;
|
||||
}
|
||||
|
||||
//31 reminder_first
|
||||
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
|
||||
if ($user->daysActiveAccount() > config('mivita.remind_sec_days')) {
|
||||
Log::channel('cron')->info('Erste Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$this->checkIsReminderSend($user, 31);
|
||||
return;
|
||||
|
|
@ -117,28 +117,28 @@ class CheckPaymentsAccount extends Command
|
|||
private function checkIsReminderSend(User $user, $status)
|
||||
{
|
||||
$isSend = UserHistory::whereUserId($user->id)
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->latest()
|
||||
->first();
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if($isSend){
|
||||
if ($isSend) {
|
||||
Log::channel('cron')->info('Erinnerung bereits gesendet für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Log::channel('cron')->info('Sende neue Erinnerung für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
$referenz = $this->sendReminderMail($user, $status);
|
||||
|
||||
|
||||
UserHistory::create([
|
||||
'user_id' => $user->id,
|
||||
'action' => 'reminder_payments',
|
||||
'referenz' => $referenz,
|
||||
'identifier' => $user->payment_account,
|
||||
'user_id' => $user->id,
|
||||
'action' => 'reminder_payments',
|
||||
'referenz' => $referenz,
|
||||
'identifier' => $user->payment_account,
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -155,8 +155,8 @@ class CheckPaymentsAccount extends Command
|
|||
$pay_date = Carbon::parse($user->payment_account)->modify('- ' . config('mivita.abo_booking_days') . ' days')->format('d.m.Y');
|
||||
$datetime = $user->getPaymentAccountDateFormat();
|
||||
$price = "";
|
||||
|
||||
if($user->payment_order_id && isset($user->payment_order_product->price)){
|
||||
|
||||
if ($user->payment_order_id && isset($user->payment_order_product->price)) {
|
||||
$price = 'von ' . $user->payment_order_product->getFormattedPrice() . ' EUR';
|
||||
}
|
||||
|
||||
|
|
@ -171,16 +171,16 @@ class CheckPaymentsAccount extends Command
|
|||
'subject' => __('reminder.subject') . " | ID: " . $status,
|
||||
'message' => $message,
|
||||
'message_last' => $message_last,
|
||||
'url' => route('user_membership'),
|
||||
'url' => config('app.url') . '/user/membership',
|
||||
'button' => $button,
|
||||
];
|
||||
|
||||
|
||||
$sender = User::find(1);
|
||||
$customer_mail = UserMessage::create(['user_id' => $user->id, 'send_user_id' => $sender->id, 'email' => $user->email, 'subject' => $data['subject'], 'message' => $data['message'] . " " . $data['message_last']]);
|
||||
|
||||
|
||||
try {
|
||||
if(!Util::isTestSystem()){
|
||||
if($status >= 34){
|
||||
if (!Util::isTestSystem()) {
|
||||
if ($status >= 34) {
|
||||
Log::channel('cron')->info('Sende kritische Erinnerung mit BCC an: ' . $user->email);
|
||||
Mail::to($user->email)
|
||||
->locale($user->getLocale())
|
||||
|
|
@ -195,19 +195,19 @@ class CheckPaymentsAccount extends Command
|
|||
} else {
|
||||
Log::channel('cron')->info('Testsystem: E-Mail-Versand simuliert für: ' . $user->email);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::channel('cron')->error('Mail-Fehler für Benutzer ' . $user->email . ': ' . $e->getMessage());
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
|
||||
|
||||
Log::channel('cron')->info('Erinnerungsmail erfolgreich gesendet an: ' . $user->email);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue