mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'dillon/63-voucherify-updates' into 'master'
Test sending welcome voucher email through server See merge request CIEFWorldwideSdnBhd/exchange-2.0!163
This commit is contained in:
@@ -46,10 +46,10 @@ class SendWelcomeVoucherEmail implements ShouldQueue
|
||||
{
|
||||
$currentDatetime = Carbon::now();
|
||||
$dateToCompare = Carbon::parse($this->voucher->end_date);
|
||||
if (!$this->user->hasAttribute($this->voucher->code."_EMAIL_COUNT")
|
||||
&& $this->user->rewards->where('voucher_id', $this->voucher->id)->count() > 0
|
||||
&& $currentDatetime->isBefore($dateToCompare))
|
||||
{
|
||||
// if (!$this->user->hasAttribute($this->voucher->code."_EMAIL_COUNT")
|
||||
// && $this->user->rewards->where('voucher_id', $this->voucher->id)->count() > 0
|
||||
// && $currentDatetime->isBefore($dateToCompare))
|
||||
// {
|
||||
//Key #1
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
$this->voucher->code."_EMAIL_COUNT",
|
||||
@@ -65,6 +65,6 @@ class SendWelcomeVoucherEmail implements ShouldQueue
|
||||
(App()->make(CreatesKeyValuePair::class))->execute($this->user, $keyValuePairObject);
|
||||
|
||||
$this->user->notify(new WelcomeVoucherEmail($this->user, $this->voucher));
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Voucher;
|
||||
use App\Classes\ValueObjects\Constants\Vouchers;
|
||||
use App\Classes\Jobs\SendWelcomeVoucherEmail;
|
||||
use App\Classes\Modules\Vouchers\Services\FetchesVoucher;
|
||||
use App\Classes\Jobs\SendUserVerificationEmail;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesEmailVerificationAttempt;
|
||||
use App\Classes\Jobs\SendResetPasswordEmail;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesPasswordReset;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OneTimeTestVoucherifyEmailCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'one-time-test-voucherify-email';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'One time test sending voucherify email to see out of alignment issue';
|
||||
|
||||
/** @var FetchesVoucher */
|
||||
private $fetchesVoucher;
|
||||
|
||||
/** @var GeneratesEmailVerificationAttempt */
|
||||
private $generatesEmailVerificationAttempt;
|
||||
|
||||
/** @var SendUserVerificationEmail */
|
||||
private $sendUserVerificationEmail;
|
||||
|
||||
/** @var GeneratesPasswordReset */
|
||||
private $generatesPasswordReset;
|
||||
|
||||
/** @var SendResetPasswordEmail */
|
||||
private $sendResetPasswordEmail;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(FetchesVoucher $fetchesVoucher, GeneratesEmailVerificationAttempt $generatesEmailVerificationAttempt, SendUserVerificationEmail $sendUserVerificationEmail, GeneratesPasswordReset $generatesPasswordReset, SendResetPasswordEmail $sendResetPasswordEmail)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->fetchesVoucher = $fetchesVoucher;
|
||||
$this->generatesEmailVerificationAttempt = $generatesEmailVerificationAttempt;
|
||||
$this->sendUserVerificationEmail = $sendUserVerificationEmail;
|
||||
$this->generatesPasswordReset = $generatesPasswordReset;
|
||||
$this->sendResetPasswordEmail = $sendResetPasswordEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try{ //In case voucher got deleted unintentionally
|
||||
$user = User::where('id', 3974)->first(); //5436, 3974
|
||||
|
||||
Log::info(json_encode($user));
|
||||
$voucher = $this->fetchesVoucher->execute(['code' => Vouchers::WELCOME_50_PERCENT_OFF]);
|
||||
Log::info(json_encode($voucher));
|
||||
if($voucher) SendWelcomeVoucherEmail::dispatch($user, $voucher, 1);
|
||||
|
||||
// $attempt = $this->generatesEmailVerificationAttempt->execute($user);
|
||||
// $this->sendUserVerificationEmail::dispatch($user, $attempt);
|
||||
|
||||
// $attempt = $this->generatesPasswordReset->execute($user);
|
||||
// $this->sendResetPasswordEmail::dispatch($user, $attempt);
|
||||
}
|
||||
catch(\Exception $e){}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user