This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Avatr extends AbstractDb
{
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init('avatr', 'entity_id');
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel\Avatr;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* @inheritDoc
*/
protected $_idFieldName = 'entity_id';
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init(
\Stemcell\Customer\Model\Avatr::class,
\Stemcell\Customer\Model\ResourceModel\Avatr::class
);
}
}
@@ -0,0 +1,104 @@
<?php
namespace Stemcell\Customer\Model\ResourceModel;
use Magento\Customer\Api\CustomerMetadataInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory;
use Magento\Customer\Api\GroupRepositoryInterface;
use Magento\Customer\Model\Customer\NotificationStorage;
use Magento\Customer\Model\CustomerFactory;
use Magento\Customer\Model\CustomerRegistry;
use Magento\Customer\Model\Data\CustomerSecureFactory;
use Magento\Customer\Model\Delegation\Storage as DelegatedStorage;
use Magento\Customer\Model\ResourceModel;
use Magento\Customer\Model\ResourceModel\AddressRepository;
use Magento\Customer\Model\ResourceModel\Customer;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\ExtensibleDataObjectConverter;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\ImageProcessorInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Psr\Log\LoggerInterface;
class CustomerRepository extends ResourceModel\CustomerRepository
{
const MOBILE_PATTERN = '/^(1(([3456789][0-9])|(47)|[8][01236789]))\d{8}$/';
protected CollectionFactory $customerCollectionFactory;
public function __construct(
CustomerFactory $customerFactory,
CustomerSecureFactory $customerSecureFactory,
CustomerRegistry $customerRegistry,
AddressRepository $addressRepository,
Customer $customerResourceModel,
CustomerMetadataInterface $customerMetadata,
CustomerSearchResultsInterfaceFactory $searchResultsFactory,
ManagerInterface $eventManager,
StoreManagerInterface $storeManager,
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
DataObjectHelper $dataObjectHelper,
ImageProcessorInterface $imageProcessor,
JoinProcessorInterface $extensionAttributesJoinProcessor,
CollectionProcessorInterface $collectionProcessor,
NotificationStorage $notificationStorage,
CollectionFactory $customerCollectionFactory,
DelegatedStorage $delegatedStorage = null,
?GroupRepositoryInterface $groupRepository = null
) {
$this->customerCollectionFactory = $customerCollectionFactory;
parent::__construct($customerFactory, $customerSecureFactory, $customerRegistry, $addressRepository, $customerResourceModel, $customerMetadata, $searchResultsFactory, $eventManager, $storeManager, $extensibleDataObjectConverter, $dataObjectHelper, $imageProcessor, $extensionAttributesJoinProcessor, $collectionProcessor, $notificationStorage, $delegatedStorage, $groupRepository);
}
/**
* @param String $mobile
* @param null $websiteId
* @return \Magento\Customer\Model\Customer
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function getCustomerByMobile(String $mobile, $websiteId = null) {
$websiteId = $websiteId?: $this->storeManager->getDefaultStoreView()->getWebsiteId();
/* @var $customer \Magento\Customer\Model\Customer */
$customer = $this->customerCollectionFactory->create()
->addAttributeToSelect('*')
->addAttributeToFilter('mobile', $mobile)
->addAttributeToFilter(CustomerInterface::WEBSITE_ID, $websiteId)
->getFirstItem();
if (!$customer->getId()) {
throw new NoSuchEntityException(
__(
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
[
'fieldName' => 'mobile',
'fieldValue' => $mobile,
'field2Name' => 'websiteId',
'field2Value' => $websiteId
]
)
);
}
return $customer;
}
/**
* @param string $email
* @param null $websiteId
* @return \Magento\Customer\Api\Data\CustomerInterface
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function get($email, $websiteId = null)
{
if (preg_match(self::MOBILE_PATTERN, $email)) {
return $this->getCustomerByMobile($email, $websiteId)->getDataModel();
}
return parent::get($email, $websiteId);
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Lab extends AbstractDb
{
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init('lab', 'lab_id');
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel\Lab;
use Magento\Framework\DataObject;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* @inheritDoc
*/
protected $_idFieldName = 'lab_id';
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init(
\Stemcell\Customer\Model\Lab::class,
\Stemcell\Customer\Model\ResourceModel\Lab::class
);
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Salesperson extends AbstractDb
{
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init('salesperson', 'salesperson_id');
}
}
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Stemcell\Customer\Model\ResourceModel\Salesperson;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* @inheritDoc
*/
protected $_idFieldName = 'salesperson_id';
/**
* @inheritDoc
*/
protected function _construct()
{
$this->_init(
\Stemcell\Customer\Model\Salesperson::class,
\Stemcell\Customer\Model\ResourceModel\Salesperson::class
);
}
/**
* @param $valueField
* @param $labelField
* @param $additional
* @return array
*/
protected function _toOptionArray($valueField = 'salesperson_id', $labelField = 'name', $additional = [])
{
return parent::_toOptionArray($valueField, $labelField, $additional);
}
}