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
+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;
}
}