ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace JR\ReportIntegration\Model;
use Magento\Quote\Api\Data\CartInterface;
class ChangeQuoteControl extends \Magento\Quote\Model\ChangeQuoteControl
{
protected $forceIsAllowed = false;
public function forceIsAllowed($forceIsAllowed) {
$this->forceIsAllowed = $forceIsAllowed;
return $this;
}
public function isAllowed(CartInterface $quote): bool
{
return $this->forceIsAllowed || parent::isAllowed($quote);
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use \JR\ReportIntegration\Api\Service\RequestServiceInterface;
use \JR\ReportIntegration\Api\Model\ConfirmManagementInterface;
use \Magento\Customer\Api\CustomerRepositoryInterface;
use \JR\ReportIntegration\Model\ChangeQuoteControl;
class ConfirmManagement implements ConfirmManagementInterface
{
/**
* @var RequestServiceInterface
*/
private $requestService;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var ChangeQuoteControl
*/
protected $changeQuoteControl;
/**
* @param RequestServiceInterface
* @param CustomerRepositoryInterface
*
* @return void
*/
public function __construct(
RequestServiceInterface $requestService,
CustomerRepositoryInterface $customerRepository,
ChangeQuoteControl $changeQuoteControl
) {
$this->requestService = $requestService;
$this->customerRepository = $customerRepository;
$this->changeQuoteControl = $changeQuoteControl;
}
/**
* {@inheritdoc}
*/
public function postConfirm($email, $secret, $id, $sales_rep)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'confirm'],
['id' => $id, 'sales_rep' => $sales_rep]
);
}
/**
* {@inheritdoc}
*/
public function confirm($id, $sales_rep)
{
$result = [];
try {
$customer = $this->customerRepository->getById($id);
$customer->setCustomAttribute('sales_rep', $sales_rep);
$customer->setGroupId(2);
$customer->setConfirmation(null);
$this->changeQuoteControl->forceIsAllowed(true);
$this->customerRepository->save($customer);
$result[] = array('account' => $customer->getEmail(), 'error' => NULL);
} catch (\Exception $e) {
$result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage());
}
return $result;
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use \JR\ReportIntegration\Api\Service\RequestServiceInterface;
use \JR\ReportIntegration\Api\Model\DenyManagementInterface;
use \Magento\Customer\Api\CustomerRepositoryInterface;
use \JR\ReportIntegration\Model\ChangeQuoteControl;
class DenyManagement implements DenyManagementInterface
{
/**
* @var RequestServiceInterface
*/
private $requestService;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var ChangeQuoteControl
*/
protected $changeQuoteControl;
/**
* @param RequestServiceInterface
* @param CustomerRepositoryInterface
*
* @return void
*/
public function __construct(
RequestServiceInterface $requestService,
CustomerRepositoryInterface $customerRepository,
ChangeQuoteControl $changeQuoteControl
) {
$this->requestService = $requestService;
$this->customerRepository = $customerRepository;
$this->changeQuoteControl = $changeQuoteControl;
}
/**
* {@inheritdoc}
*/
public function postDeny($email, $secret, $id, $customer_group)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'deny'],
['id' => $id, 'customer_group' => $customer_group]
);
}
/**
* {@inheritdoc}
*/
public function deny($id, $customer_group)
{
$result = [];
$groups = [
'Enduser' => 5,
'Competitor' => 6,
'Other' => 7,
];
try {
$customer = $this->customerRepository->getById($id);
$customer->setCustomAttribute('sales_rep', '');
$customer->setGroupId(array_key_exists($customer_group, $groups) ? $groups[$customer_group] : 7);
$this->changeQuoteControl->forceIsAllowed(true);
$this->customerRepository->save($customer);
$result[] = array('account' => $customer->getEmail(), 'error' => NULL);
} catch (\Exception $e) {
$result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage());
}
return $result;
}
}
@@ -0,0 +1,91 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Customer\Api\CustomerRepositoryInterface;
use JR\ReportIntegration\Api\Model\DisableAccountsManagementInterface;
use JR\ReportIntegration\Service\RequestService;
use JR\ReportIntegration\Model\ChangeQuoteControl;
class DisableAccountsManagement implements DisableAccountsManagementInterface
{
/**
* @var Json
*/
protected $json;
/**
* @var RequestService
*/
protected $requestService;
/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
/**
* @var ChangeQuoteControl
*/
protected $changeQuoteControl;
/**
* @param Json
* @param CustomerRepositoryInterface
*
*/
public function __construct(
Json $json,
RequestService $requestService,
CustomerRepositoryInterface $customerRepository,
ChangeQuoteControl $changeQuoteControl
) {
$this->json = $json;
$this->requestService = $requestService;
$this->customerRepository = $customerRepository;
$this->changeQuoteControl = $changeQuoteControl;
}
/**
* POST for disableAccounts api
* @param string $email
* @param string $secret
* @param string $ids
*/
public function postDisableAccounts($email, $secret, $ids)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'disableAccounts'],
['ids' => $this->json->unserialize($ids)]
);
}
/**
* {@inheritdoc}
*/
public function disableAccounts($ids)
{
$result = [];
foreach ($ids as $id) {
try {
$customer = $this->customerRepository->getById($id);
$customer->setGroupId(5);
$customer->setConfirmation('non-empty string');
$this->changeQuoteControl->forceIsAllowed(true);
$this->customerRepository->save($customer);
$result[] = array('account' => $customer->getEmail(), 'error' => NULL);
} catch (\Exception $e) {
$result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage());
}
}
return $result;
}
}
@@ -0,0 +1,100 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use Magento\Framework\Serialize\Serializer\Json;
use JR\ReportIntegration\Api\Model\InternalAccountsManagementInterface;
use JR\ReportIntegration\Api\Service\RequestServiceInterface;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
class InternalAccountsManagement implements InternalAccountsManagementInterface
{
/**
* @var Json
*/
protected $json;
/**
* @var RequestServiceInterface
*/
protected $requestService;
/**
* @var CustomerCollectionFactory
*/
protected $customerCollectionFactory;
/**
* @param Json
* @param CustomerCollectionFactory
*
* @return void
*/
public function __construct(
Json $json,
RequestServiceInterface $requestService,
CustomerCollectionFactory $customerCollectionFactory
) {
$this->json = $json;
$this->requestService = $requestService;
$this->customerCollectionFactory = $customerCollectionFactory;
}
/**
* {@inheritdoc}
*/
public function postInternalAccounts($email, $secret)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'getInternalAccounts']
);
}
/**
* {@inheritdoc}
*/
public function getInternalAccounts()
{
$internalDomains = [
'laviewsecurity.com',
'laviewusa.com',
'ltschicago.com',
'ltsecurity.com',
'ltsecurityinc.com',
'ltshouston.com',
'ltsla.com',
'ltsmall.com',
'ltsmd.com',
'ltsnewyork.com',
'ltsnj.com',
'ltstechnologies.com',
'epoweron.com'
];
$collection = $this->customerCollectionFactory->create();
$orConditions = [];
foreach ($internalDomains as $domain) {
$orConditions[] = ['like' => '%' . $domain . '%'];
}
$collection->addFieldToFilter('email', $orConditions);
$collection->addFieldToFilter('group_id', ['neq' => 5]);
$collection->addAttributeToSelect(['entity_id', 'email', 'group_id']);
$accounts = [];
foreach ($collection as $account) {
$accounts[] = [
'id' => $account->getId(),
'email' => $account->getEmail(),
'gid' => $account->getGroupId()
];
}
return $accounts;
}
}
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use JR\ReportIntegration\Helper\Data as Helper;
use JR\ReportIntegration\Service\RequestService;
use Magento\Framework\Exception\LocalizedException;
use Magento\Customer\Api\CustomerRepositoryInterface;
class SetOfficeManagement implements \JR\ReportIntegration\Api\Model\SetOfficeManagementInterface
{
/**
* @var RequestService
*/
protected $requestService;
/**
* @var Helper
*/
protected $helper;
/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
/**
* @param RequestService
* @param Helper
* @param CustomerRepositoryInterface
*
* @return void
*/
public function __construct(
RequestService $requestService,
Helper $helper,
CustomerRepositoryInterface $customerRepository
) {
$this->requestService = $requestService;
$this->helper = $helper;
$this->customerRepository = $customerRepository;
}
/**
* {@inheritdoc}
*/
public function postSetOffice($email, $secret, $id, $office)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'setOffice'],
['id' => $id, 'office' => $office]
);
}
/**
* {@inheritdoc}
*/
public function setOffice($id, $office)
{
$result = [];
try {
$customer = $this->customerRepository->getById($id);
if ($this->helper->hasOfficeName($office)) {
$customer->setCustomAttribute('lts_office', $this->helper->getOfficeValueByShortName($office));
$this->customerRepository->save($customer);
$result[] = array('account' => $customer->getEmail(), 'error' => NULL);
} else {
throw new LocalizedException(__("'$office' is an invalid office."));
}
} catch (\Exception $e) {
$result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage());
}
return $result;
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
/**
* Copyright © JR All rights reserved.
* See COPYING.txt for license details.
*/
namespace JR\ReportIntegration\Model;
use \JR\ReportIntegration\Api\Service\RequestServiceInterface;
use \JR\ReportIntegration\Api\Model\SetSalesManagementInterface;
use \Magento\Customer\Api\CustomerRepositoryInterface;
class SetSalesManagement implements SetSalesManagementInterface
{
/**
* @var RequestServiceInterface
*/
private $requestService;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @param RequestServiceInterface
* @param CustomerRepositoryInterface
*
* @return void
*/
public function __construct(
RequestServiceInterface $requestService,
CustomerRepositoryInterface $customerRepository
) {
$this->requestService = $requestService;
$this->customerRepository = $customerRepository;
}
/**
* {@inheritdoc}
*/
public function postSetSales($email, $secret, $id, $sales_rep)
{
return $this->requestService->post(
$email,
$secret,
[$this, 'setSales'],
['id' => $id, 'sales_rep' => $sales_rep]
);
}
/**
* {@inheritdoc}
*/
public function setSales($id, $sales_rep)
{
$result = [];
try {
$customer = $this->customerRepository->getById($id);
$customer->setCustomAttribute('sales_rep', $sales_rep);
if ($sales_rep == '' && $customer->getGroupId() == 2) {
$customer->setGroupId(1);
}
$this->customerRepository->save($customer);
$result[] = array('account' => $customer->getEmail(), 'error' => NULL);
} catch (\Exception $e) {
$result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage());
}
return $result;
}
}