Merge branch 'register-honey-trap' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development

# Conflicts:
#	app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php
This commit is contained in:
edmondlang
2023-05-31 08:25:06 +08:00
2 changed files with 22 additions and 2 deletions
@@ -19,12 +19,15 @@ use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\CompanyType;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Classes\Jobs\CreatePerfexCRMCustomer;
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
use App\Models\Company;
use App\Models\Segment;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
class CreateCustomerLogic extends AbstractControllerLogic
{
@@ -66,6 +69,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
/** @var CreatePerfexCRMLeadProcessor */
private $createPerfexCRMLeadProcessor;
/** @var CreatesSeasonalSegment */
private $createsSeasonalSegment;
/**
* CreateCustomerLogic constructor.
* @param CreateUserProcessor $createUserProcessor
@@ -77,8 +83,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
* @param AssignSegmentProcessor $assignCompanyToSegmentProcessor
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
* @param CreatesSeasonalSegment $createsSeasonalSegment
*/
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, AssignSegmentProcessor $assignCompanyToSegmentProcessor, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, AssignSegmentProcessor $assignCompanyToSegmentProcessor, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, CreatesSeasonalSegment $createsSeasonalSegment)
{
$this->createUserProcessor = $createUserProcessor;
$this->createCompanyProcessor = $createCompanyProcessor;
@@ -89,6 +96,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
$this->assignCompanyToSegmentProcessor = $assignCompanyToSegmentProcessor;
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
$this->createsSeasonalSegment = $createsSeasonalSegment;
}
/**
@@ -119,8 +127,19 @@ class CreateCustomerLogic extends AbstractControllerLogic
$Object = new EmploymentObject($company, $user);
$this->assignEmployeeProcessor->execute($Object);
// assign STANDARD_SEGMENT to all new customers
$this->assignSegmentProcessor->execute($company);
// assign other standard segment to all new customers
$otherDefaultSegmentToAdd = Segment::whereIn('name', ['HONEY TRAP NEW REGISTRATION'])->get();
$start_date = Carbon::now();
$end_date = $start_date->addDays(30);
foreach ($otherDefaultSegmentToAdd as $segment) {
$seasonalSegmentObject = new SeasonalSegmentObject($company->id, $segment->id, $start_date, $end_date ?? null);
$this->createsSeasonalSegment->execute($seasonalSegmentObject);
$this->assignSegmentProcessor->execute($company, $segment->id);
}
if(config('perfexcrm.is_enabled') == 'true'){
//$this->createPerfexCRMLeadProcessor->execute($request);
$createLeadPerfexCRMObject = new CreateLeadPerfexCRMObject(
@@ -36,6 +36,7 @@
@endphp
<section id="customer-account" class="m-b-50">
<h3>Customer Account</h3>
<p>Company Id: <span>{{$company->id}}</span></p>
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif