Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into dillon/voucherify-35

This commit is contained in:
edmondlang
2023-06-27 18:08:47 +08:00
2 changed files with 26 additions and 4 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
{
@@ -63,6 +66,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
/** @var CreatePerfexCRMLeadProcessor */
private $createPerfexCRMLeadProcessor;
/** @var CreatesSeasonalSegment */
private $createsSeasonalSegment;
/**
* CreateCustomerLogic constructor.
* @param CreateUserProcessor $createUserProcessor
@@ -73,9 +79,10 @@ class CreateCustomerLogic extends AbstractControllerLogic
* @param AuthenticationProcessor $authenticationProcessor
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
* @param CreatesSeasonalSegment $createsSeasonalSegment
*/
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor,
CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, CreatesSeasonalSegment $createsSeasonalSegment)
{
$this->createUserProcessor = $createUserProcessor;
$this->createCompanyProcessor = $createCompanyProcessor;
@@ -85,6 +92,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
$this->authenticationProcessor = $authenticationProcessor;
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
$this->createsSeasonalSegment = $createsSeasonalSegment;
}
/**
@@ -109,8 +117,20 @@ 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(
@@ -32,6 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'DocNo',
'DocDate',
'DebtorCode',
'Ref',
'DebtorName',
'CurrencyCode',
'ShipInfo',
@@ -67,7 +68,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
if($start_date && $end_date) {
$query->whereBetween('created_at', [
Carbon::parse($start_date)->format('Y-m-d 0:00:00'),
Carbon::parse($start_date)->format('Y-m-d 0:00:00'),
Carbon::parse($end_date)->format('Y-m-d 23:59:59')
]);
}
@@ -95,6 +96,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'<<New>>',
$transaction->updated_at->format('m/d/Y H:m'),
$company->debtor,
$booking->marking,
'',
'MYR',
$booking->marking,
@@ -107,4 +109,4 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'CIEF'
];
}
}
}