init
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Checkout\Controller\Cart;
|
||||
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Customer\Model\ResourceModel\Lab\CollectionFactory as LabCollectionFactory;
|
||||
use Stemcell\Customer\Model\ResourceModel\Salesperson\CollectionFactory as SalespersonCollectionFactory;
|
||||
|
||||
/**
|
||||
* 找到与销售、当前登录的经销商绑定的Lab
|
||||
*/
|
||||
class GetLabsFromSalesperson implements HttpGetActionInterface
|
||||
{
|
||||
public function __construct(
|
||||
protected Context $context,
|
||||
protected \Magento\Customer\Model\Session $customerSession,
|
||||
protected \Magento\Framework\Controller\Result\JsonFactory $jsonFactory,
|
||||
protected LabCollectionFactory $labCollectionFactory,
|
||||
protected SalespersonCollectionFactory $salespersonCollectionFactory
|
||||
){
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
||||
$data = [];
|
||||
if ($this->customerSession->isLoggedIn()) {
|
||||
$salespersonId = $this->context->getRequest()->getParam('salesperson_id', 0);
|
||||
$data = $this->labCollectionFactory->create()
|
||||
->addFieldToFilter('is_active', 1)
|
||||
->addFieldToFilter('salesperson_id', $salespersonId)
|
||||
->addFieldToFilter('customer_id', $this->customerSession->getCustomerId())
|
||||
->addFieldToSelect(['lab_id', 'lab_code', 'booking_account'])
|
||||
->getData();
|
||||
}
|
||||
return $this->jsonFactory->create()->setData(['labs' => $data]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user