init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Directory\Helper\Data as DirectoryHelper;
|
||||
use Magento\Framework\Json\Helper\Data as JsonHelper;
|
||||
|
||||
class Reject extends \Magento\Backend\Block\Template
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
protected \Magento\Framework\Registry $_coreRegistry,
|
||||
array $data = [],
|
||||
?JsonHelper $jsonHelper = null,
|
||||
?DirectoryHelper $directoryHelper = null
|
||||
)
|
||||
{
|
||||
parent::__construct($context, $data, $jsonHelper, $directoryHelper);
|
||||
$this->_authorization = $context->getAuthorization();
|
||||
}
|
||||
|
||||
public function getRejectUrl()
|
||||
{
|
||||
return $this->getUrl('sales/*/reject');
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->_coreRegistry->registry('current_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $resourceId
|
||||
* @return bool
|
||||
*/
|
||||
public function canReject(string $resourceId = 'Magento_Sales::cancel') {
|
||||
return $this->_authorization->isAllowed($resourceId) && $this->getOrder()->canCancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Adminhtml\Order;
|
||||
|
||||
use Magento\Framework\DataObject;
|
||||
|
||||
class Totals extends \Magento\Sales\Block\Adminhtml\Order\Totals
|
||||
{
|
||||
protected function _initTotals()
|
||||
{
|
||||
\Magento\Sales\Block\Adminhtml\Totals::_initTotals();
|
||||
$this->_totals['paid'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'paid',
|
||||
'strong' => true,
|
||||
'value' => $this->getSource()->getTotalPaid(),
|
||||
'base_value' => $this->getSource()->getBaseTotalPaid(),
|
||||
'label' => __('Total Paid'),
|
||||
'area' => 'footer',
|
||||
]
|
||||
);
|
||||
$this->_totals['refunded'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'refunded',
|
||||
'strong' => true,
|
||||
'value' => $this->getSource()->getTotalRefunded(),
|
||||
'base_value' => $this->getSource()->getBaseTotalRefunded(),
|
||||
'label' => __('Total Refunded'),
|
||||
'area' => 'footer',
|
||||
]
|
||||
);
|
||||
$this->_totals['customer_discount_amount'] = new DataObject(
|
||||
[
|
||||
'code' => 'customer_discount_amount',
|
||||
'strong' => true,
|
||||
'value' => '¥'.number_format($this->getSource()->getData('customer_discount'), 2, '.', ''),
|
||||
'label' => __('优惠金额'),
|
||||
'area' => 'footer',
|
||||
]
|
||||
);
|
||||
$code = 'due';
|
||||
$label = 'Total Due';
|
||||
$value = $this->getSource()->getTotalDue();
|
||||
$baseValue = $this->getSource()->getBaseTotalDue();
|
||||
if ($this->getSource()->getTotalCanceled() > 0 && $this->getSource()->getBaseTotalCanceled() > 0) {
|
||||
$code = 'canceled';
|
||||
$label = 'Total Canceled';
|
||||
$value = $this->getSource()->getTotalCanceled();
|
||||
$baseValue = $this->getSource()->getBaseTotalCanceled();
|
||||
}
|
||||
$this->_totals[$code] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'due',
|
||||
'strong' => true,
|
||||
'value' => $value,
|
||||
'base_value' => $baseValue,
|
||||
'label' => __($label),
|
||||
'area' => 'footer',
|
||||
]
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
||||
use Magento\Sales\Model\ConfigInterface;
|
||||
use Magento\Sales\Model\Order;
|
||||
|
||||
class View extends \Magento\Sales\Block\Adminhtml\Order\View
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReviewUrl()
|
||||
{
|
||||
return $this->getUrl('stemcell_sales/*/review');
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_objectId = 'order_id';
|
||||
$this->_controller = 'adminhtml_order';
|
||||
$this->_mode = 'view';
|
||||
|
||||
Container::_construct();
|
||||
|
||||
$this->removeButton('delete');
|
||||
$this->removeButton('reset');
|
||||
$this->removeButton('save');
|
||||
$this->setId('sales_order_view');
|
||||
$order = $this->getOrder();
|
||||
|
||||
if (!$order) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->_isAllowedAction('Magento_Sales::cancel')
|
||||
&& $order->canCancel()
|
||||
&& $order->getState() != Order::STATE_PROCESSING
|
||||
) {
|
||||
$this->addButton(
|
||||
'order_cancel',
|
||||
[
|
||||
'label' => __('Cancel'),
|
||||
'class' => 'cancel',
|
||||
'id' => 'order-view-cancel-button',
|
||||
'data_attribute' => [
|
||||
'url' => $this->getCancelUrl()
|
||||
]
|
||||
]
|
||||
);
|
||||
$this->addButton(
|
||||
'order_reject',
|
||||
[
|
||||
'label' => __('驳回'),
|
||||
'class' => 'order_reject',
|
||||
'onclick' => 'orderReject()'
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// if ($this->_isAllowedAction('Magento_Sales::email') && !$order->isCanceled()) {
|
||||
// $message = __('Are you sure you want to send an order email to customer?');
|
||||
// $this->addButton(
|
||||
// 'send_notification',
|
||||
// [
|
||||
// 'label' => __('Send Email'),
|
||||
// 'class' => 'send-email',
|
||||
// 'onclick' => "confirmSetLocation('{$message}', '{$this->getEmailUrl()}')"
|
||||
// ]
|
||||
// );
|
||||
// }
|
||||
|
||||
if ($this->_isAllowedAction(
|
||||
'Magento_Sales::ship'
|
||||
) && $order->canShip() && !$order->getForcedShipmentWithInvoice()
|
||||
) {
|
||||
|
||||
$this->addButton(
|
||||
'order_ship',
|
||||
[
|
||||
'label' => __('Ship'),
|
||||
'onclick' => 'setLocation(\'' . $this->getShipUrl() . '\')',
|
||||
'class' => 'ship'
|
||||
]
|
||||
);
|
||||
if ($order->getState() != Order::STATE_PROCESSING) {
|
||||
$this->addButton(
|
||||
'order_review',
|
||||
[
|
||||
'label' => __('审核'),
|
||||
'class' => 'order_review',
|
||||
'onclick' => 'setLocation(\'' . $this->getReviewUrl() . '\')',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_isAllowedAction(
|
||||
'Magento_Sales::reorder'
|
||||
) && $this->_reorderHelper->isAllowed(
|
||||
$order->getStore()
|
||||
) && $order->canReorderIgnoreSalable()
|
||||
) {
|
||||
$this->addButton(
|
||||
'order_reorder',
|
||||
[
|
||||
'label' => __('Reorder'),
|
||||
'onclick' => 'setLocation(\'' . $this->getReorderUrl() . '\')',
|
||||
'class' => 'reorder'
|
||||
]
|
||||
);
|
||||
}
|
||||
$this->removeButton('order_edit');
|
||||
$this->removeButton('order_invoice');
|
||||
$this->removeButton('order_hold');
|
||||
$this->removeButton('send_notification');
|
||||
if ($order->getState() == Order::STATE_PROCESSING) {
|
||||
$this->removeButton('order_cancel');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Adminhtml\Order\View\Items\Renderer;
|
||||
|
||||
use Magento\Sales\Model\Order\Item;
|
||||
|
||||
class DefaultRenderer extends \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer
|
||||
{
|
||||
/**
|
||||
* Retrieve rendered column html content
|
||||
*
|
||||
* @param \Magento\Framework\DataObject|Item $item
|
||||
* @param string $column
|
||||
* @param string $field
|
||||
* @return string
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @since 100.1.0
|
||||
*/
|
||||
public function getColumnHtml(\Magento\Framework\DataObject $item, $column, $field = null)
|
||||
{
|
||||
$html = '';
|
||||
switch ($column) {
|
||||
case 'product':
|
||||
if ($this->canDisplayContainer()) {
|
||||
$html .= '<div id="' . $this->getHtmlId() . '">';
|
||||
}
|
||||
$html .= $this->getColumnHtml($item, 'name');
|
||||
if ($this->canDisplayContainer()) {
|
||||
$html .= '</div>';
|
||||
}
|
||||
break;
|
||||
case 'status':
|
||||
$html = $item->getStatus();
|
||||
break;
|
||||
case 'sku':
|
||||
$html = $item->getSku();
|
||||
break;
|
||||
case 'cd-code':
|
||||
$html = $item->getData('cd');
|
||||
break;
|
||||
case 'quote-code':
|
||||
$html = $item->getData('quote');
|
||||
break;
|
||||
case 'price-original':
|
||||
$html = $this->displayPriceAttribute('original_price');
|
||||
break;
|
||||
case 'tax-amount':
|
||||
$html = $this->displayPriceAttribute('tax_amount');
|
||||
break;
|
||||
case 'tax-percent':
|
||||
$html = $this->displayTaxPercent($item);
|
||||
break;
|
||||
case 'discont':
|
||||
$html = number_format($item->getData('customer_discount_percent'), 2, '.', '').'%';
|
||||
break;
|
||||
default:
|
||||
$html = \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer::getColumnHtml($item, $column, $field);
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order\Email;
|
||||
|
||||
class Items extends \Magento\Sales\Block\Order\Email\Items
|
||||
{
|
||||
public function getPrice(\Magento\Sales\Model\Order\Item $item): string
|
||||
{
|
||||
// $discountPercent = $item->getData('customer_discount_percent')*1.0;
|
||||
$price = $item->getPrice();
|
||||
// $price = $discountPercent? $price*((100-$discountPercent)/100):$price;
|
||||
return number_format($price, 2);
|
||||
}
|
||||
|
||||
public function getRowTotal(\Magento\Sales\Model\Order\Item $item): string
|
||||
{
|
||||
$discountPercent = $item->getData('customer_discount_percent')*1.0;
|
||||
$rowTotal = $item->getRowTotal();
|
||||
$rowTotal = $discountPercent? $rowTotal*((100-$discountPercent)/100):$rowTotal;
|
||||
|
||||
return number_format($rowTotal, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order\Email\Salesperson;
|
||||
|
||||
class Items extends \Magento\Sales\Block\Order\Email\Items
|
||||
{
|
||||
public function getPrice(\Magento\Sales\Model\Order\Item $item): string
|
||||
{
|
||||
// $discountPercent = $item->getData('customer_discount_percent')*1.0;
|
||||
$price = $item->getPrice();
|
||||
// $price = $discountPercent? $price*((100-$discountPercent)/100):$price;
|
||||
return number_format($price, 2);
|
||||
}
|
||||
|
||||
public function getRowTotal(\Magento\Sales\Model\Order\Item $item): string
|
||||
{
|
||||
$discountPercent = $item->getData('customer_discount_percent')*1.0;
|
||||
$rowTotal = $item->getRowTotal();
|
||||
$rowTotal = $discountPercent? $rowTotal*((100-$discountPercent)/100):$rowTotal;
|
||||
return number_format($rowTotal, 2);
|
||||
}
|
||||
|
||||
public function getSalespersonGrandTotal(\Magento\Sales\Model\Order $order): string
|
||||
{
|
||||
return '¥'.number_format($order->getGrandTotal(), 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface;
|
||||
|
||||
class History extends \Magento\Sales\Block\Order\History
|
||||
{
|
||||
protected CollectionFactoryInterface $orderCollectionFactory;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Framework\View\Element\Template\Context $context,
|
||||
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
|
||||
\Magento\Customer\Model\Session $customerSession,
|
||||
\Magento\Sales\Model\Order\Config $orderConfig,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $orderCollectionFactory, $customerSession, $orderConfig, $data);
|
||||
$this->orderCollectionFactory = $orderCollectionFactory;
|
||||
}
|
||||
|
||||
public function getOrders()
|
||||
{
|
||||
if (!($customerId = $this->_customerSession->getCustomerId())) {
|
||||
return false;
|
||||
}
|
||||
if (!$this->orders) {
|
||||
$this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
|
||||
'*'
|
||||
)->addFieldToFilter(
|
||||
'status',
|
||||
['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
|
||||
)->setOrder(
|
||||
'created_at',
|
||||
'desc'
|
||||
);
|
||||
}
|
||||
$q = trim((string)$this->_request->getParam('q', ''));
|
||||
if (!empty($q)) {
|
||||
$this->orders->addFieldToFilter('increment_id', ['like' => '%' . $q . '%']);
|
||||
}
|
||||
return $this->orders;
|
||||
}
|
||||
|
||||
protected function getOrderCollectionFactory()
|
||||
{
|
||||
if ($this->orderCollectionFactory === null) {
|
||||
$this->orderCollectionFactory = ObjectManager::getInstance()->get(CollectionFactoryInterface::class);
|
||||
}
|
||||
return $this->orderCollectionFactory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaBuilder;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Element\Template\Context as TemplateContext;
|
||||
use Magento\Payment\Helper\Data as PaymentHelper;
|
||||
use Magento\Sales\Model\Order\Address\Renderer as AddressRenderer;
|
||||
use Magento\Sales\Api\OrderStatusHistoryRepositoryInterface;
|
||||
use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory;
|
||||
use Stemcell\Sales\Model\OrderStatus;
|
||||
|
||||
class Info extends \Magento\Sales\Block\Order\Info
|
||||
{
|
||||
public function __construct(
|
||||
TemplateContext $context,
|
||||
Registry $registry,
|
||||
PaymentHelper $paymentHelper,
|
||||
AddressRenderer $addressRenderer,
|
||||
protected CollectionFactory $statusHistoryCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $registry, $paymentHelper, $addressRenderer, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRejectComment()
|
||||
{
|
||||
$collection = $this->getOrder()->getStatusHistoryCollection()
|
||||
->addFieldToFilter('status', OrderStatus::rejected->name);
|
||||
if ($collection->getSize()) {
|
||||
return $collection->getFirstItem()->getComment();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order\Item\Renderer;
|
||||
|
||||
use Magento\Catalog\Model\Product\OptionFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Stdlib\StringUtils;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Sales\Model\Order\Item;
|
||||
use Stemcell\Customer\Api\SalespersonRepositoryInterface;
|
||||
use Stemcell\Customer\Model\LabRepository;
|
||||
|
||||
class DefaultRenderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StringUtils $string,
|
||||
OptionFactory $productOptionFactory,
|
||||
private SalespersonRepositoryInterface $salespersonRepository,
|
||||
private LabRepository $labRepository,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $string, $productOptionFactory, $data);
|
||||
}
|
||||
|
||||
public function getSalespersonName(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getSalespersonId()) {
|
||||
$salesperson = $this->salespersonRepository->get($orderItem->getSalespersonId());
|
||||
return $salesperson->getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLabBookingAccount(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getLabId()) {
|
||||
try {
|
||||
$lab = $this->labRepository->get($orderItem->getLabId());
|
||||
return $lab->getBookingAccount();
|
||||
} catch (LocalizedException $e) {
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $orderItem
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCustomDiscountPercent(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getData('customer_discount_percent')) {
|
||||
return number_format(
|
||||
$orderItem->getData('customer_discount_percent')*1.0,
|
||||
2, '.', ''
|
||||
).'%';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order;
|
||||
|
||||
use Magento\Framework\DataObject;
|
||||
|
||||
class Totals extends \Magento\Sales\Block\Order\Totals
|
||||
{
|
||||
protected function addShippingTotal($source)
|
||||
{
|
||||
if (!$source->getIsVirtual()
|
||||
&& ($source->getShippingAmount() !== null
|
||||
|| $source->getShippingDescription())
|
||||
) {
|
||||
$shippingLabel = __('Shipping & Handling');
|
||||
|
||||
if (!isset($this->_totals['discount'])) {
|
||||
if ($source->getCouponCode()) {
|
||||
$shippingLabel .= " ({$source->getCouponCode()})";
|
||||
} elseif ($source->getDiscountDescription()) {
|
||||
$shippingLabel .= " ({$source->getDiscountDescription()})";
|
||||
}
|
||||
}
|
||||
$this->_totals['shipping'] = new DataObject(
|
||||
[
|
||||
'code' => 'shipping',
|
||||
'field' => 'shipping_amount',
|
||||
'value' => $source->getShippingAmount(),
|
||||
'label' => $shippingLabel,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
protected function _initTotals()
|
||||
{
|
||||
$source = $this->getSource();
|
||||
|
||||
$this->_totals = [];
|
||||
$this->_totals['subtotal'] = new \Magento\Framework\DataObject(
|
||||
['code' => 'subtotal', 'value' => $source->getSubtotal(), 'label' => __('Subtotal')]
|
||||
);
|
||||
|
||||
/**
|
||||
* Add discount
|
||||
*/
|
||||
if ((double)$this->getSource()->getDiscountAmount() != 0) {
|
||||
if ($this->getSource()->getDiscountDescription()) {
|
||||
$discountLabel = __('Discount (%1)', $source->getDiscountDescription());
|
||||
} else {
|
||||
$discountLabel = __('Discount');
|
||||
}
|
||||
$this->_totals['discount'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'discount',
|
||||
'field' => 'discount_amount',
|
||||
'value' => $source->getDiscountAmount(),
|
||||
'label' => $discountLabel,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$this->addShippingTotal($source);
|
||||
$this->_totals['customer_discount'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'customer_discount',
|
||||
'field' => 'customer_discount',
|
||||
'value' => $source->getData('customer_discount'),
|
||||
'label' => '优惠金额',
|
||||
]
|
||||
);
|
||||
$this->_totals['grand_total'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'grand_total',
|
||||
'field' => 'grand_total',
|
||||
'strong' => true,
|
||||
'value' => $source->getGrandTotal(),
|
||||
'label' => __('Grand Total'),
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
* Base grandtotal
|
||||
*/
|
||||
if ($this->getOrder()->isCurrencyDifferent()) {
|
||||
$this->_totals['base_grandtotal'] = new \Magento\Framework\DataObject(
|
||||
[
|
||||
'code' => 'base_grandtotal',
|
||||
'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
|
||||
'label' => __('Grand Total to be Charged'),
|
||||
'is_formated' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order;
|
||||
|
||||
use Stemcell\Sales\Model\OrderStatus;
|
||||
|
||||
class View extends \Magento\Sales\Block\Order\View
|
||||
{
|
||||
/**
|
||||
* @return \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection
|
||||
*/
|
||||
public function getRejectComment()
|
||||
{
|
||||
return $this->getOrder()->getStatusHistoryCollection()
|
||||
->addFieldToFilter('status', OrderStatus::rejected->name);
|
||||
|
||||
}
|
||||
|
||||
public function isOrderRejected() {
|
||||
return $this->getOrder()->getStatus() == OrderStatus::rejected->name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Tracking;
|
||||
|
||||
use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface;
|
||||
use Magento\Shipping\Model\Order\Track;
|
||||
use Magento\Shipping\Model\ResourceModel\Order\Track\CollectionFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Sales\Helper\Data;
|
||||
|
||||
class Popup extends \Magento\Shipping\Block\Tracking\Popup
|
||||
{
|
||||
protected Data $helper;
|
||||
protected CollectionFactory $trackCollectionFactory;
|
||||
public function __construct(
|
||||
\Magento\Framework\View\Element\Template\Context $context,
|
||||
\Magento\Framework\Registry $registry,
|
||||
DateTimeFormatterInterface $dateTimeFormatter,
|
||||
CollectionFactory $trackCollectionFactory,
|
||||
Data $helper,
|
||||
LoggerInterface $logger,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $registry, $dateTimeFormatter, $data);
|
||||
$this->trackCollectionFactory = $trackCollectionFactory;
|
||||
$this->helper = $helper;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExpressInfo(): array
|
||||
{
|
||||
$info = $this->_registry->registry('current_shipping_info');
|
||||
if ($info->getOrderId()) {
|
||||
/* @var $track Track */
|
||||
$track = $this->trackCollectionFactory->create()
|
||||
->setOrderFilter($info->getOrderId())
|
||||
->setItemObjectClass(Track::class)
|
||||
->getFirstItem();
|
||||
$expressInfo = json_decode($track->getDescription(), true);
|
||||
//是否已签收
|
||||
$isReceived = !empty($expressInfo) && isset($expressInfo['deliverystatus']) && $expressInfo['deliverystatus']==3;
|
||||
if ($track->getTrackNumber() && !$isReceived) {
|
||||
try {
|
||||
$result = $this->helper->getExpressInfo($track->getTrackNumber());
|
||||
if (isset($result['expName'])) {
|
||||
$track->setDescription(json_encode($result))->save();
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
$this->logger->critical('request express info fail, message:'.$exception->getMessage(), $exception->getTrace());
|
||||
}
|
||||
}
|
||||
if ($track->getDescription()) {
|
||||
if (isset($expressInfo['list']) && is_array($expressInfo['list'])) {
|
||||
return $expressInfo['list'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Controller\Adminhtml\Export;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
class GridToCsv extends \Magento\Ui\Controller\Adminhtml\Export\GridToCsv
|
||||
{
|
||||
/**
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->fileFactory->create('export-'.date('YmdHis').'.xlsx', $this->converter->getCsvFile(), 'var');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Controller\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\App\Response\Http\FileFactory;
|
||||
use Magento\Framework\Controller\Result\JsonFactory;
|
||||
use Magento\Framework\Controller\Result\RawFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Translate\InlineInterface;
|
||||
use Magento\Framework\View\Result\LayoutFactory;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\Sales\Api\OrderManagementInterface;
|
||||
use Magento\Sales\Api\OrderRepositoryInterface;
|
||||
use Magento\Sales\Model\Order;
|
||||
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Sales\Model\OrderStatus;
|
||||
|
||||
class MassReview extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction implements HttpPostActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Magento_Sales::sales_order';
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Filter $filter
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param OrderManagementInterface|null $orderManagement
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory,
|
||||
protected OrderManagementInterface $orderManagement,
|
||||
protected OrderRepositoryInterface $orderRepository,
|
||||
protected LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($context, $filter);
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel selected orders
|
||||
*
|
||||
* @param AbstractCollection $collection
|
||||
* @return \Magento\Backend\Model\View\Result\Redirect
|
||||
*/
|
||||
protected function massAction(AbstractCollection $collection)
|
||||
{
|
||||
$success = $failure = [];
|
||||
$messages = [];
|
||||
/* @var $order Order */
|
||||
foreach ($collection->getItems() as $order) {
|
||||
try {
|
||||
if ($order->canShip()) {
|
||||
$this->orderManagement->setState(
|
||||
$order,
|
||||
Order::STATE_PROCESSING,
|
||||
OrderStatus::reviewed->name,
|
||||
'订单批量审核',
|
||||
null,
|
||||
false
|
||||
);
|
||||
$this->orderRepository->save($order);
|
||||
$success[] = $order->getIncrementId();
|
||||
} else {
|
||||
$failure[] = $order->getIncrementId();
|
||||
}
|
||||
} catch (LocalizedException $e) {
|
||||
// $messages .= sprintf('订单%s审核异常,原因:%s', $order->getIncrementId(), $e->getMessage()).'<br/>';
|
||||
$messages[$order->getIncrementId()] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
if ($messages) {
|
||||
$this->logger->critical('订单批量审核异常', $messages);
|
||||
}
|
||||
if ($failure) {
|
||||
$this->messageManager->addErrorMessage(sprintf('订单:%s 批量审核失败', implode(', ', $failure)));
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
$this->messageManager->addSuccessMessage(sprintf('批量审核%d笔订单, %d审核成功.', $collection->count(), count($success)));
|
||||
}
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$resultRedirect->setPath($this->getComponentRefererUrl());
|
||||
return $resultRedirect;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Controller\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
|
||||
use Magento\Framework\App\Response\Http\FileFactory;
|
||||
use Magento\Framework\Controller\Result\JsonFactory;
|
||||
use Magento\Framework\Controller\Result\RawFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Translate\InlineInterface;
|
||||
use Magento\Framework\View\Result\LayoutFactory;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\Sales\Api\OrderManagementInterface;
|
||||
use Magento\Sales\Api\OrderRepositoryInterface;
|
||||
use Magento\Sales\Model\Order;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Sales\Model\OrderStatus;
|
||||
|
||||
class Reject extends \Magento\Sales\Controller\Adminhtml\Order implements HttpPostActionInterface
|
||||
{
|
||||
const STATUS = 'rejected';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
Registry $coreRegistry,
|
||||
FileFactory $fileFactory,
|
||||
InlineInterface $translateInline,
|
||||
PageFactory $resultPageFactory,
|
||||
JsonFactory $resultJsonFactory,
|
||||
LayoutFactory $resultLayoutFactory,
|
||||
RawFactory $resultRawFactory,
|
||||
OrderManagementInterface $orderManagement,
|
||||
OrderRepositoryInterface $orderRepository,
|
||||
LoggerInterface $logger
|
||||
)
|
||||
{
|
||||
parent::__construct($context, $coreRegistry, $fileFactory, $translateInline, $resultPageFactory, $resultJsonFactory, $resultLayoutFactory, $resultRawFactory, $orderManagement, $orderRepository, $logger);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
if (!$this->isValidPostRequest()) {
|
||||
$this->messageManager->addErrorMessage(__('订单驳回失败.'));
|
||||
return $resultRedirect->setPath('sales/*/');
|
||||
}
|
||||
$order = $this->_initOrder();
|
||||
if ($order) {
|
||||
try {
|
||||
$this->orderManagement->setState(
|
||||
$order,
|
||||
Order::STATE_CANCELED,
|
||||
false,
|
||||
'',
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
$order->addCommentToStatusHistory($this->getRequest()->getPost('reason'),OrderStatus::rejected->name, true);
|
||||
$this->orderRepository->save($order);
|
||||
$this->messageManager->addSuccessMessage(__('订单已驳回.'));
|
||||
} catch (\Magento\Framework\Exception\LocalizedException $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage(__('订单驳回失败'));
|
||||
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
|
||||
}
|
||||
return $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
|
||||
}
|
||||
return $resultRedirect->setPath('sales/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Controller\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\App\Response\Http\FileFactory;
|
||||
use Magento\Framework\Controller\Result\JsonFactory;
|
||||
use Magento\Framework\Controller\Result\RawFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Translate\InlineInterface;
|
||||
use Magento\Framework\View\Result\LayoutFactory;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\Sales\Api\OrderManagementInterface;
|
||||
use Magento\Sales\Api\OrderRepositoryInterface;
|
||||
use Magento\Sales\Model\Order;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Sales\Model\OrderStatus;
|
||||
|
||||
class Review extends \Magento\Sales\Controller\Adminhtml\Order implements HttpGetActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Magento_Sales::sales_order';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
Registry $coreRegistry,
|
||||
FileFactory $fileFactory,
|
||||
InlineInterface $translateInline,
|
||||
PageFactory $resultPageFactory,
|
||||
JsonFactory $resultJsonFactory,
|
||||
LayoutFactory $resultLayoutFactory,
|
||||
RawFactory $resultRawFactory,
|
||||
OrderManagementInterface $orderManagement,
|
||||
OrderRepositoryInterface $orderRepository,
|
||||
LoggerInterface $logger
|
||||
)
|
||||
{
|
||||
parent::__construct($context, $coreRegistry, $fileFactory, $translateInline, $resultPageFactory, $resultJsonFactory, $resultLayoutFactory, $resultRawFactory, $orderManagement, $orderRepository, $logger);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
|
||||
$order = $this->_initOrder();
|
||||
if ($order) {
|
||||
try {
|
||||
$this->orderManagement->setState(
|
||||
$order,
|
||||
Order::STATE_PROCESSING,
|
||||
OrderStatus::reviewed->name,
|
||||
'',
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
$this->orderRepository->save($order);
|
||||
$this->messageManager->addSuccessMessage(__('订单已审核.'));
|
||||
} catch (\Magento\Framework\Exception\LocalizedException $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage(__('订单审核失败'));
|
||||
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
|
||||
}
|
||||
return $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
|
||||
}
|
||||
return $resultRedirect->setPath('sales/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Stemcell\Sales\Controller\Order;
|
||||
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Sales\Api\OrderManagementInterface;
|
||||
use Magento\Sales\Api\OrderRepositoryInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Sales\Model\Order;
|
||||
|
||||
class Cancel implements HttpGetActionInterface
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
protected OrderRepositoryInterface $orderRepository,
|
||||
protected OrderManagementInterface $orderManagement,
|
||||
protected \Magento\Framework\App\RequestInterface $request,
|
||||
protected \Magento\Customer\Model\Session $customerSession,
|
||||
protected ResultFactory $resultRedirectFactory,
|
||||
protected \Magento\Framework\Message\ManagerInterface $messageManager
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|(\Magento\Framework\Controller\Result\Redirect&\Magento\Framework\Controller\ResultInterface)|\Magento\Framework\Controller\ResultInterface|void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$resultRedirect = $this->resultRedirectFactory->create(ResultFactory::TYPE_REDIRECT);
|
||||
|
||||
try {
|
||||
|
||||
$order = $this->orderRepository->get($this->request->getParam('order_id'));
|
||||
if ($order->getCustomerId() == $this->customerSession->getCustomerId() && $order->getState() == Order::STATE_NEW) {
|
||||
$this->orderManagement->cancel($order->getEntityId());
|
||||
$order->addCommentToStatusHistory('用户主动取消订单', Order::STATE_CANCELED, false);
|
||||
$this->orderRepository->save($order);
|
||||
} else {
|
||||
$this->messageManager->addErrorMessage(__('您不能取消当前订单'));
|
||||
}
|
||||
|
||||
$this->messageManager->addSuccessMessage(__('You canceled the order.'));
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage(__('You have not canceled the item.'));
|
||||
return $resultRedirect->setPath('sales/order/history');
|
||||
}
|
||||
return $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getEntityId()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Helper;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Magento\Framework\App\Helper\Context;
|
||||
use GuzzleHttp\ClientFactory;
|
||||
use GuzzleHttp\Psr7\ResponseFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
class Data extends \Magento\Framework\App\Helper\AbstractHelper
|
||||
{
|
||||
const EXPRESS_REQUEST_URI = 'https://kdwlcxf.market.alicloudapi.com/';
|
||||
const APPCODE = '066aa3e12a754b09a5fa757bfcad91f4';
|
||||
/**
|
||||
* @var ClientFactory
|
||||
*/
|
||||
protected ClientFactory $clientFactory;
|
||||
|
||||
protected ResponseFactory $responseFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ClientFactory $clientFactory,
|
||||
ResponseFactory $responseFactory
|
||||
|
||||
){
|
||||
parent::__construct($context);
|
||||
$this->responseFactory = $responseFactory;
|
||||
$this->clientFactory = $clientFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expressNo
|
||||
* @return array
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function getExpressInfo(string $expressNo){
|
||||
/** @var Client $client */
|
||||
$client = $this->clientFactory->create(['config' => [
|
||||
'base_uri' => self::EXPRESS_REQUEST_URI
|
||||
]]);
|
||||
|
||||
try {
|
||||
$response = $client->request(
|
||||
'GET',
|
||||
'kdwlcx/?no='.$expressNo,
|
||||
['headers'=>['Authorization' => 'APPCODE '.self::APPCODE]]
|
||||
);
|
||||
} catch (GuzzleException $exception) {
|
||||
throw new LocalizedException(__($exception->getMessage()));
|
||||
}
|
||||
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if ($result['status']==0) {
|
||||
return (array)$result['result'];
|
||||
}
|
||||
|
||||
throw new LocalizedException(__($result['msg']));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Export;
|
||||
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use \PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Sales\Model\ResourceModel\Order\Item;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Magento\Ui\Model\Export\MetadataProvider;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ConvertToCsv extends \Magento\Ui\Model\Export\ConvertToCsv
|
||||
{
|
||||
private Item\Collection $itemCollection;
|
||||
private Filesystem\DirectoryList $directoryList;
|
||||
|
||||
public function __construct(
|
||||
Filesystem $filesystem,
|
||||
Filter $filter,
|
||||
MetadataProvider $metadataProvider,
|
||||
Item\Collection $itemCollection,
|
||||
Filesystem\DirectoryList $directoryList,
|
||||
protected LoggerInterface $logger,
|
||||
$pageSize = 200
|
||||
) {
|
||||
parent::__construct($filesystem, $filter, $metadataProvider, $pageSize);
|
||||
$this->itemCollection = $itemCollection;
|
||||
$this->directoryList = $directoryList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getHeaders() {
|
||||
return [
|
||||
'订单编号',
|
||||
'订单金额',
|
||||
'经销商',
|
||||
'销售',
|
||||
'下单时间',
|
||||
'订单状态',
|
||||
'货号',
|
||||
'商品名称',
|
||||
'经销商价格(¥)',
|
||||
'数量',
|
||||
'CD号',
|
||||
'Quote号',
|
||||
'折扣',
|
||||
'总金额(¥)',
|
||||
'订货账户',
|
||||
'账户名称',
|
||||
'PI SAP ID',
|
||||
// '最终用户单位',
|
||||
// 'PI',
|
||||
// '最终使用人',
|
||||
// '联系电话',
|
||||
// '邮箱地址',
|
||||
'终端类型',
|
||||
'备注',
|
||||
'订单备注',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOrderStatusLabel(\Magento\Sales\Model\Order $order)
|
||||
{
|
||||
try {
|
||||
return $order->getStatusLabel();
|
||||
} catch (LocalizedException $e) {
|
||||
$this->logger->critical(
|
||||
sprintf(
|
||||
'获取订单:: %s 的status: %s label失败, 原因:%s',
|
||||
$order->getIncrementId(),
|
||||
$order->getStatus(),
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Sales\Model\Order\Item $orderItem
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
public function getRowData(\Magento\Sales\Model\Order\Item $orderItem, array $fields): array
|
||||
{
|
||||
$timezone = ObjectManager::getInstance()->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
|
||||
$row = [];
|
||||
foreach ($fields as $column) {
|
||||
|
||||
$value = match ($column) {
|
||||
'booking_account' => $orderItem->getData('booking_account'),
|
||||
'user_type' => $orderItem->getData('user_type') == 0 ? '终端' : '二级经销商',
|
||||
'customer_discount_percent' => $this->getCustomerDiscountPercent($orderItem),
|
||||
'grand_total' => '¥'.number_format($orderItem->getData('grand_total'), 2),
|
||||
'price' => number_format(floatval($orderItem->getPrice()), 2),
|
||||
'status' => $this->getOrderStatusLabel($orderItem->getOrder()),
|
||||
'row_total' => $this->getRowTotal($orderItem),
|
||||
'name' => $orderItem->getProductOptionByCode('simple_name')?? $orderItem->getName(),
|
||||
'created_at' => $timezone->date($orderItem->getData($column))->format('Y-m-d H:i:s'),
|
||||
default => $orderItem->getData($column),
|
||||
};
|
||||
if ($value!=null && trim($value)=='-') $value = null;
|
||||
$row[] = $value;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
protected function getCustomerDiscountPercent(\Magento\Sales\Model\Order\Item $orderItem): string
|
||||
{
|
||||
$discountPercent = $orderItem->getData('customer_discount_percent');
|
||||
return $discountPercent == 0 ? '' : number_format($discountPercent, 2).'%';
|
||||
}
|
||||
|
||||
protected function getRowTotal(\Magento\Sales\Model\Order\Item $orderItem): string
|
||||
{
|
||||
return number_format($orderItem->getRowTotal(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item\Collection
|
||||
*/
|
||||
protected function getCollection(array $ordersId) {
|
||||
$this->itemCollection->addFieldToSelect([
|
||||
'sku', 'name', 'qty_ordered', 'row_total', 'cd', 'quote', 'lab_code', 'company', 'user', 'pi', 'pi_sap_id',
|
||||
'user_tel', 'user_email', 'note', 'user_type', 'order_id', 'price', 'customer_discount_percent', 'product_options'
|
||||
])
|
||||
->addFieldToFilter('main_table.order_id', ['in'=>$ordersId])
|
||||
->addFieldToFilter('main_table.parent_item_id', ['null' => true])
|
||||
->getSelect()
|
||||
->join(
|
||||
'sales_order',
|
||||
'main_table.order_id=sales_order.entity_id',
|
||||
[
|
||||
'increment_id', 'grand_total', 'customer_firstname', 'created_at', 'status', 'salesperson_id', 'customer_note'
|
||||
]
|
||||
)
|
||||
->joinLeft(
|
||||
'salesperson',
|
||||
'salesperson.salesperson_id=sales_order.salesperson_id',
|
||||
[
|
||||
'salesperson_name' => 'salesperson.name'
|
||||
|
||||
]
|
||||
)
|
||||
->joinLeft(
|
||||
'lab',
|
||||
'lab.lab_id=main_table.lab_id',
|
||||
[
|
||||
'lab_code' => 'lab.lab_code',
|
||||
'booking_account' => 'lab.booking_account',
|
||||
'pi_sap_id' => 'lab.pi_sap_id',
|
||||
]
|
||||
);
|
||||
|
||||
return $this->itemCollection;
|
||||
}
|
||||
|
||||
protected function getFields() {
|
||||
return [
|
||||
'increment_id', 'grand_total', 'customer_firstname', 'salesperson_name', 'created_at', 'status', 'sku',
|
||||
'name', 'price', 'qty_ordered', 'cd', 'quote', 'customer_discount_percent', 'row_total', 'lab_code', 'booking_account', 'pi_sap_id',
|
||||
// 'company', 'pi', 'user', 'user_tel', 'user_email',
|
||||
'user_type', 'note', 'customer_note'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws LocalizedException
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function getCsvFile()
|
||||
{
|
||||
/* @var $logger LoggerInterface */
|
||||
$logger = ObjectManager::getInstance()->get(LoggerInterface::class);
|
||||
/* @var $component \Magento\Ui\Component\Listing */
|
||||
$component = $this->filter->getComponent();
|
||||
|
||||
// md5() here is not for cryptographic use.
|
||||
// phpcs:ignore Magento2.Security.InsecureFunction
|
||||
$name = md5(microtime());
|
||||
$file = 'export/'. $component->getName() . $name . '.xlsx';
|
||||
|
||||
$this->filter->prepareComponent($component);
|
||||
$this->filter->applySelectionOnTargetProvider();
|
||||
|
||||
/* @var $dataProvider \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider */
|
||||
$dataProvider = $component->getContext()->getDataProvider();
|
||||
$fields = $this->getFields();
|
||||
|
||||
$this->directory->create('export');
|
||||
$filePath = $this->directoryList->getPath('var').'/'.$file;
|
||||
$dataProvider->setLimit(0, 100);
|
||||
$ordersId = [];
|
||||
$items = $dataProvider->getSearchResult()->getItems();
|
||||
foreach ($items as $item) {
|
||||
/* @var $item \Magento\Framework\View\Element\UiComponent\DataProvider\Document */
|
||||
$ordersId[] = $item->getId();
|
||||
}
|
||||
|
||||
$collection = $this->getCollection($ordersId);
|
||||
|
||||
$dataGroupByOrderId = [];
|
||||
foreach ($collection as $item) {
|
||||
/* @var $item \Magento\Sales\Model\Order\Item */
|
||||
$dataGroupByOrderId[$item->getOrderId()][] = $this->getRowData($item, $fields);
|
||||
}
|
||||
$styles = [
|
||||
'alignment' => [
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
];
|
||||
$rowIndex = 2;
|
||||
$spreadSheet = new Spreadsheet();
|
||||
$writer = IOFactory::createWriter($spreadSheet, 'Xlsx');
|
||||
$worksheet = $spreadSheet->getActiveSheet();
|
||||
$columnIndex = 'A';
|
||||
foreach ($this->getHeaders() as $row) {
|
||||
$cell = $worksheet->getCell($columnIndex.'1');
|
||||
$cell->getAppliedStyle()->applyFromArray($styles);
|
||||
$cell->setValue($row);
|
||||
$columnIndex++;
|
||||
}
|
||||
$worksheet->getRowDimension(1)->setRowHeight(20);
|
||||
krsort($dataGroupByOrderId);
|
||||
foreach ($dataGroupByOrderId as $rows) {
|
||||
$rowCount = count($rows);
|
||||
$mergeColumnsIndex = ['A', 'B', 'C', 'D', 'E', 'F', 'T'];
|
||||
foreach ($mergeColumnsIndex as $index) {
|
||||
$worksheet->mergeCells($index.$rowIndex.':'.$index.$rowIndex+$rowCount-1);
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
$columnIndex = 'A';
|
||||
foreach ($row as $value) {
|
||||
$worksheet->getColumnDimension($columnIndex)->setWidth(15);
|
||||
$worksheet->getRowDimension($rowIndex)->setRowHeight(20);
|
||||
$cell = $worksheet->getCell($columnIndex.$rowIndex);
|
||||
$cell->getAppliedStyle()->applyFromArray($styles);
|
||||
$cell->setValue($value);
|
||||
$columnIndex++;
|
||||
}
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
$writer->save($filePath);
|
||||
return [
|
||||
'type' => 'filename',
|
||||
'value' => $file,
|
||||
'rm' => true // can delete file after use
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Email\Attachment;
|
||||
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use \PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Sales\Model\ResourceModel\Order\Item;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Customer\Api\Data\SalespersonInterface;
|
||||
use Stemcell\Sales\Model\Order\Email\Sender\OrderSender;
|
||||
|
||||
class Order
|
||||
{
|
||||
private Item\Collection $itemCollection;
|
||||
private Filesystem\DirectoryList $directoryList;
|
||||
private Filesystem\Directory\WriteInterface $directory;
|
||||
private \Magento\Store\Model\StoreManagerInterface $storeManager;
|
||||
|
||||
protected SalespersonInterface $salesperson;
|
||||
|
||||
protected OrderSender $orderSender;
|
||||
|
||||
protected \Magento\Sales\Model\Order $order;
|
||||
|
||||
/**
|
||||
* @var \Magento\Sales\Model\Order\Item[]
|
||||
*/
|
||||
protected array $orderItems;
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(
|
||||
Filesystem $filesystem,
|
||||
Item\Collection $itemCollection,
|
||||
Filesystem\DirectoryList $directoryList,
|
||||
\Magento\Store\Model\StoreManagerInterface $storeManager,
|
||||
protected LoggerInterface $logger,
|
||||
protected TimezoneInterface $timezone
|
||||
) {
|
||||
$this->itemCollection = $itemCollection;
|
||||
$this->directoryList = $directoryList;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getHeaders() {
|
||||
return [
|
||||
'订单编号',
|
||||
'订单金额',
|
||||
'经销商',
|
||||
'销售',
|
||||
'下单时间',
|
||||
'订单状态',
|
||||
'货号',
|
||||
'商品名称',
|
||||
'经销商价格(¥)',
|
||||
'数量',
|
||||
'CD号',
|
||||
'Quote号',
|
||||
'折扣',
|
||||
'总金额(¥)',
|
||||
'订货账户',
|
||||
'账户名称',
|
||||
'PI SAP ID',
|
||||
// '最终用户单位',
|
||||
// 'PI',
|
||||
// '最终使用人',
|
||||
// '联系电话',
|
||||
// '邮箱地址',
|
||||
'终端类型',
|
||||
'备注',
|
||||
'订单备注',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOrderStatusLabel(\Magento\Sales\Model\Order $order)
|
||||
{
|
||||
try {
|
||||
return $order->getStatusLabel();
|
||||
} catch (LocalizedException $e) {
|
||||
$this->logger->critical(
|
||||
sprintf(
|
||||
'获取订单:: %s 的status: %s label失败, 原因:%s',
|
||||
$order->getIncrementId(),
|
||||
$order->getStatus(),
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getCurrentTimezoneTime(string $time)
|
||||
{
|
||||
try {
|
||||
$time = $this->timezone->date(new \DateTime($time))->format('Y-m-d H:i:s');
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->critical('发给销售的邮件附件在做数据转换时异常: ' . $e->getMessage());
|
||||
}
|
||||
return $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一笔订单,可能因为用户在购物车给不同商品选择的账户(lab)不一样,这时对应的销售(salesperson)可能不一样,
|
||||
* 因此同一个订单需要根据销售来拆分,这就导致同一个订单可能发多个邮件给不同的销售。因此这个的order_items并不是订单的全部items。
|
||||
* 此数据来源于\Stemcell\Sales\Observer\SalespersonNotify。
|
||||
* 故此,grand_total的不能用order的grand total
|
||||
* @param \Magento\Sales\Model\Order\Item $orderItem
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
public function getRowData(\Magento\Sales\Model\Order\Item $orderItem, array $fields): array
|
||||
{
|
||||
$row = [];
|
||||
foreach ($fields as $column) {
|
||||
|
||||
$value = match ($column) {
|
||||
'booking_account' => $orderItem->getData('booking_account'),
|
||||
'user_type' => $orderItem->getData('user_type') == 0 ? '终端' : '二级经销商',
|
||||
'customer_discount_percent' => $this->getCustomerDiscountPercent($orderItem),
|
||||
'grand_total' => $this->getGrandTotal(),
|
||||
'price' => number_format($orderItem->getData('price'), 2),
|
||||
'row_total' => $this->getRowTotal($orderItem),
|
||||
'status' => $this->getOrderStatusLabel($orderItem->getOrder()),
|
||||
'salesperson_name' => $orderItem->getData('salesperson_name'),
|
||||
'created_at' => $this->getCurrentTimezoneTime($orderItem->getData('created_at')),
|
||||
'name' => $this->getProductName($orderItem),
|
||||
default => $orderItem->getData($column),
|
||||
};
|
||||
|
||||
if ($value!=null && trim($value)=='-') $value = null;
|
||||
$row[] = $value;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
protected function getProductName(\Magento\Sales\Model\Order\Item $orderItem): string
|
||||
{
|
||||
return $orderItem->getProductOptionByCode('simple_name')?? $orderItem->getName();
|
||||
}
|
||||
protected function getCustomerDiscountPercent(\Magento\Sales\Model\Order\Item $orderItem): string
|
||||
{
|
||||
$discountPercent = $orderItem->getData('customer_discount_percent');
|
||||
return $discountPercent == 0 ? '' : number_format($discountPercent, 2).'%';
|
||||
}
|
||||
|
||||
protected function getRowTotal(\Magento\Sales\Model\Order\Item $orderItem): string
|
||||
{
|
||||
return number_format($orderItem->getRowTotal(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
protected function getOrderItemsId(): array
|
||||
{
|
||||
return array_map(function (\Magento\Sales\Model\Order\Item $item){
|
||||
return $item->getItemId();
|
||||
}, $this->order->getAllVisibleItems());
|
||||
}
|
||||
|
||||
protected function getGrandTotal(): string
|
||||
{
|
||||
return '¥'.number_format($this->order->getGrandTotal(), 2);
|
||||
}
|
||||
/**
|
||||
* @return Item\Collection
|
||||
*/
|
||||
protected function getCollection(array $ordersId) {
|
||||
$this->itemCollection->addFieldToSelect([
|
||||
'sku', 'name', 'price', 'qty_ordered', 'cd', 'quote', 'customer_discount_percent', 'row_total', 'lab_code',
|
||||
// 'company', 'user',
|
||||
'pi_sap_id',
|
||||
// 'user_tel', 'user_email',
|
||||
'note', 'user_type', 'order_id', 'product_options'
|
||||
])
|
||||
->addFieldToFilter('main_table.item_id', ['in'=>$this->getOrderItemsId()])
|
||||
->addFieldToFilter('main_table.parent_item_id', ['null' => true])
|
||||
->getSelect()
|
||||
->join(
|
||||
'sales_order',
|
||||
'main_table.order_id=sales_order.entity_id',
|
||||
[
|
||||
'increment_id', 'grand_total', 'customer_firstname', 'created_at', 'status', 'sales_order.salesperson_id',
|
||||
'customer_note'
|
||||
]
|
||||
)
|
||||
->joinLeft(
|
||||
'salesperson',
|
||||
'salesperson.salesperson_id=sales_order.salesperson_id',
|
||||
[
|
||||
'salesperson_name' => 'salesperson.name'
|
||||
|
||||
]
|
||||
)->joinLeft(
|
||||
'lab',
|
||||
'lab.lab_id=main_table.lab_id',
|
||||
[
|
||||
'lab_code' => 'lab.lab_code',
|
||||
'booking_account' => 'lab.booking_account',
|
||||
'pi_sap_id' => 'lab.pi_sap_id',
|
||||
]
|
||||
);
|
||||
$this->logger->debug('create order attachment sql: '.$this->itemCollection->getSelectSql(true));
|
||||
return $this->itemCollection;
|
||||
}
|
||||
|
||||
protected function getFields() {
|
||||
return [
|
||||
'increment_id', 'grand_total', 'customer_firstname', 'salesperson_name', 'created_at', 'status', 'sku',
|
||||
'name', 'price', 'qty_ordered', 'cd', 'quote', 'customer_discount_percent',
|
||||
'row_total', 'lab_code', 'booking_account', 'pi_sap_id',
|
||||
// 'company', 'pi', 'user', 'user_tel', 'user_email',
|
||||
'user_type', 'note', 'customer_note'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Sales\Model\Order $order
|
||||
* @return string
|
||||
*/
|
||||
protected function getShippingAddress(\Magento\Sales\Model\Order $order)
|
||||
{
|
||||
$address = $order->getShippingAddress();
|
||||
return '收货地址: '.$address->getRegion() . ' ' . $address->getCity() . ' '
|
||||
. implode(' ', $address->getStreet());
|
||||
}
|
||||
/**
|
||||
* @param \Magento\Sales\Model\Order $order
|
||||
* @param OrderSender $orderSender
|
||||
* @return string
|
||||
* @throws FileSystemException
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function getFile(\Magento\Sales\Model\Order $order, OrderSender $orderSender)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->orderSender = $orderSender;
|
||||
$name = md5(microtime());
|
||||
$file = 'attachment/'. $name . '.xlsx';
|
||||
|
||||
$fields = $this->getFields();
|
||||
|
||||
$this->directory->create('attachment');
|
||||
$filePath = $this->directoryList->getPath(UrlInterface::URL_TYPE_MEDIA).'/'.$file;
|
||||
|
||||
$ordersId = [$order->getId()];
|
||||
|
||||
$collection = $this->getCollection($ordersId);
|
||||
|
||||
$dataGroupByOrderId = [];
|
||||
foreach ($collection as $item) {
|
||||
/* @var $item \Magento\Sales\Model\Order\Item */
|
||||
$dataGroupByOrderId[$item->getData('salesperson_id')][] = $this->getRowData($item, $fields);
|
||||
}
|
||||
$styles = [
|
||||
'alignment' => [
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
];
|
||||
$rowIndex = 2;
|
||||
$spreadSheet = new Spreadsheet();
|
||||
$writer = IOFactory::createWriter($spreadSheet, IOFactory::WRITER_XLSX);
|
||||
$worksheet = $spreadSheet->getActiveSheet();
|
||||
$columnIndex = 'A';
|
||||
foreach ($this->getHeaders() as $row) {
|
||||
$cell = $worksheet->getCell($columnIndex.'1');
|
||||
$cell->getAppliedStyle()->applyFromArray($styles);
|
||||
$cell->setValue($row);
|
||||
$columnIndex++;
|
||||
}
|
||||
$worksheet->getRowDimension(1)->setRowHeight(20);
|
||||
foreach ($dataGroupByOrderId as $rows) {
|
||||
$rowCount = count($rows);
|
||||
$mergeColumnsIndex = ['A', 'B', 'C', 'D', 'E', 'F', 'T'];
|
||||
foreach ($mergeColumnsIndex as $index) {
|
||||
$worksheet->mergeCells($index.$rowIndex.':'.$index.$rowIndex+$rowCount-1);
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
$columnIndex = 'A';
|
||||
foreach ($row as $value) {
|
||||
$worksheet->getColumnDimension($columnIndex)->setWidth(15);
|
||||
$worksheet->getRowDimension($rowIndex)->setRowHeight(20);
|
||||
$cell = $worksheet->getCell($columnIndex.$rowIndex);
|
||||
$cell->getAppliedStyle()->applyFromArray($styles);
|
||||
$cell->setValue($value);
|
||||
$columnIndex++;
|
||||
}
|
||||
$rowIndex++;
|
||||
}
|
||||
}
|
||||
$worksheet->mergeCells("A{$rowIndex}:$columnIndex{$rowIndex}");
|
||||
$worksheet->setCellValue("A{$rowIndex}", $this->getShippingAddress($order));
|
||||
$writer->save($filePath);
|
||||
$content = $this->directory->readFile($filePath);
|
||||
$this->directory->delete($filePath);
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Email\Container;
|
||||
|
||||
class OrderIdentity extends \Magento\Sales\Model\Order\Email\Container\OrderIdentity
|
||||
{
|
||||
protected array $cc = [];
|
||||
|
||||
public function getEmailCopyTo()
|
||||
{
|
||||
return empty($this->cc)? false:$this->cc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $emailCopyTo
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailCopyTo(array $emailCopyTo): static
|
||||
{
|
||||
$this->cc = $emailCopyTo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTemplateId(): string
|
||||
{
|
||||
return 'sales_email_order_new_salesperson_template';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Email\Sender;
|
||||
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Payment\Helper\Data as PaymentHelper;
|
||||
use Magento\Sales\Model\Order;
|
||||
use Magento\Sales\Model\Order\Email\Container\Template;
|
||||
use Magento\Sales\Model\Order\Email\Sender;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use Stemcell\Customer\Api\Data\SalespersonInterface;
|
||||
use Stemcell\Sales\Model\Order\Email\SenderBuilder;
|
||||
use Stemcell\Sales\Model\Order\Email\SenderBuilderFactory;
|
||||
use Magento\Sales\Model\ResourceModel\Order as OrderResource;
|
||||
use Magento\Sales\Model\Order\Address\Renderer;
|
||||
use Magento\Framework\Event\ManagerInterface;
|
||||
use Magento\Framework\DataObject;
|
||||
use Stemcell\Customer\Api\SalespersonRepositoryInterface;
|
||||
use Stemcell\Sales\Model\Order\Email\Container\OrderIdentity;
|
||||
|
||||
/**
|
||||
* Sends order email to the customer.
|
||||
*
|
||||
* @api
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class OrderSender extends Sender
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Renderer
|
||||
*/
|
||||
protected $addressRenderer;
|
||||
|
||||
/**
|
||||
* Application Event Dispatcher
|
||||
*
|
||||
* @var ManagerInterface
|
||||
*/
|
||||
protected ManagerInterface $eventManager;
|
||||
private SalespersonRepositoryInterface $salespersonRepository;
|
||||
private \Stemcell\Sales\Model\Order\Email\Attachment\Order $orderAttachment;
|
||||
private string $file;
|
||||
|
||||
/**
|
||||
* @var \Magento\Sales\Model\Order\Item[]
|
||||
*/
|
||||
protected array $orderItems = [];
|
||||
|
||||
protected SalespersonInterface $salesperson;
|
||||
|
||||
protected \Magento\Sales\Model\Order $order;
|
||||
|
||||
/**
|
||||
* @param Template $templateContainer
|
||||
* @param OrderIdentity $identityContainer
|
||||
* @param SenderBuilderFactory $senderBuilderFactory
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* @param Renderer $addressRenderer
|
||||
* @param PaymentHelper $paymentHelper
|
||||
* @param OrderResource $orderResource
|
||||
* @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig
|
||||
* @param ManagerInterface $eventManager
|
||||
*/
|
||||
public function __construct(
|
||||
Template $templateContainer,
|
||||
OrderIdentity $identityContainer,
|
||||
SenderBuilderFactory $senderBuilderFactory,
|
||||
\Psr\Log\LoggerInterface $logger,
|
||||
Renderer $addressRenderer,
|
||||
SalespersonRepositoryInterface $salespersonRepository,
|
||||
\Stemcell\Sales\Model\Order\Email\Attachment\Order $orderAttachment
|
||||
) {
|
||||
parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory, $logger, $addressRenderer);
|
||||
$this->salespersonRepository = $salespersonRepository;
|
||||
$this->orderAttachment = $orderAttachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* inject $salesperson
|
||||
* @param SalespersonInterface $salesperson
|
||||
* @return $this
|
||||
*/
|
||||
public function setSalesperson(SalespersonInterface $salesperson): static
|
||||
{
|
||||
$this->salesperson = $salesperson;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSalesperson(): SalespersonInterface
|
||||
{
|
||||
return $this->salesperson;
|
||||
}
|
||||
/**
|
||||
* inject $salesperson
|
||||
* @param SalespersonInterface $salesperson
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function setOrderItems(array $orderItems): static
|
||||
{
|
||||
foreach ($orderItems as $item) {
|
||||
if (!$item instanceof \Magento\Sales\Model\Order\Item) {
|
||||
throw new LocalizedException(__('One of item in parameter orderItems array are not instance of \Magento\Sales\Model\Order\Item class'));
|
||||
}
|
||||
}
|
||||
$this->orderItems = $orderItems;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Order\Item[]
|
||||
*/
|
||||
public function getOrderItems(): array
|
||||
{
|
||||
return $this->orderItems;
|
||||
}
|
||||
/**
|
||||
* @param Order $order
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkAndSend(Order $order): bool
|
||||
{
|
||||
$this->identityContainer->setStore($order->getStore());
|
||||
|
||||
// if (!$this->identityContainer->isEnabled()) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
$this->prepareTemplate($order);
|
||||
|
||||
/** @var SenderBuilder $sender */
|
||||
$sender = $this->getSender();
|
||||
try {
|
||||
$sender->setAttachmentFile($this->orderAttachment->getFile($order, $this));
|
||||
$sender->send();
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage(), $e->getTrace());
|
||||
return false;
|
||||
}
|
||||
// if ($this->identityContainer->getCopyMethod() == 'copy') {
|
||||
// try {
|
||||
// $sender->sendCopyTo();
|
||||
// } catch (\Exception $e) {
|
||||
// $this->logger->error($e->getMessage(), $e->getTrace());
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
public function send(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
return $this->checkAndSend($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare email template with variables
|
||||
*
|
||||
* @param Order $order
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareTemplate(Order $order)
|
||||
{
|
||||
try {
|
||||
$transport = [
|
||||
'order' => $order,
|
||||
'orderItems' => $this->orderItems,
|
||||
'salesperson' => $this->salesperson,
|
||||
'order_id' => $order->getId(),
|
||||
'file' => $this->file = $this->orderAttachment->getFile($order, $this),
|
||||
'order_data' => [
|
||||
'customer_name' => $order->getCustomerName(),
|
||||
'is_not_virtual' => $order->getIsNotVirtual(),
|
||||
'order_id' => $order->getId(),
|
||||
'order_item' => $order->getAllVisibleItems(),
|
||||
'frontend_status_label' => $order->getFrontendStatusLabel()
|
||||
]
|
||||
];
|
||||
|
||||
$this->identityContainer->setEmailCopyTo($this->getEmailCopyTo($order));
|
||||
$this->templateContainer->setTemplateVars($transport);
|
||||
|
||||
parent::prepareTemplate($order);
|
||||
} catch (FileSystemException | \PhpOffice\PhpSpreadsheet\Writer\Exception | Exception $e) {
|
||||
$this->logger->critical($e->getMessage(), $e->getTrace());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getEmailCopyTo(Order $order): array
|
||||
{
|
||||
$cc = [$order->getCustomerEmail()];
|
||||
|
||||
$fields = ['email', 'rsm_email', 'sisr_email', 'csr_email'];
|
||||
foreach ($fields as $field) {
|
||||
if ($email = $this->salesperson->getData($field)) {
|
||||
$email = strval($email);
|
||||
$email = trim($email, ',');
|
||||
$temp = array_map('trim', explode(',', $email));
|
||||
$cc = array_merge($cc, $temp);
|
||||
}
|
||||
}
|
||||
return $cc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Email;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\MailException;
|
||||
use Stemcell\Sales\Model\Order\Template\TransportBuilder;
|
||||
use Magento\Framework\Mail\Template\TransportBuilderByStore;
|
||||
use Magento\Sales\Model\Order\Email\Container\IdentityInterface;
|
||||
use Magento\Sales\Model\Order\Email\Container\Template;
|
||||
|
||||
class SenderBuilder extends \Magento\Sales\Model\Order\Email\SenderBuilder
|
||||
{
|
||||
protected string $filePath;
|
||||
|
||||
public function __construct(Template $templateContainer, IdentityInterface $identityContainer, TransportBuilder $transportBuilder, TransportBuilderByStore $transportBuilderByStore = null)
|
||||
{
|
||||
parent::__construct($templateContainer, $identityContainer, $transportBuilder, $transportBuilderByStore);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MailException
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$this->configureEmailTemplate();
|
||||
$copyTo = $this->identityContainer->getEmailCopyTo();
|
||||
$this->transportBuilder->addTo(
|
||||
$this->identityContainer->getCustomerEmail(),
|
||||
$this->identityContainer->getCustomerName()
|
||||
);
|
||||
|
||||
if (!empty($copyTo)) {
|
||||
$this->transportBuilder->addTo($copyTo);
|
||||
$this->transportBuilder->setMessageData('to', $copyTo);
|
||||
}
|
||||
if (isset($this->filePath)) {
|
||||
$attachmentMime = [
|
||||
'type' => 'application/vnd.ms-excel',
|
||||
'content' => $this->filePath,
|
||||
'disposition' => \Laminas\Mime\Mime::DISPOSITION_ATTACHMENT,
|
||||
'encoding' => \Laminas\Mime\Mime::ENCODING_BASE64,
|
||||
'fileName' => 'order.xlsx'
|
||||
];
|
||||
$this->transportBuilder->setAttachmentMimePart($attachmentMime);
|
||||
}
|
||||
|
||||
$transport = $this->transportBuilder->getTransport();
|
||||
$transport->sendMessage();
|
||||
}
|
||||
|
||||
public function setAttachmentFile(string $filePath): static
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Email;
|
||||
|
||||
class SenderBuilderFactory extends \Magento\Sales\Model\Order\Email\SenderBuilderFactory
|
||||
{
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Stemcell\\Sales\Model\\Order\\Email\\SenderBuilder')
|
||||
{
|
||||
parent::__construct($objectManager, $instanceName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order;
|
||||
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Sales\Model\Order\Item;
|
||||
|
||||
class ShipmentFactory extends \Magento\Sales\Model\Order\ShipmentFactory
|
||||
{
|
||||
/**
|
||||
* Serializer data
|
||||
*
|
||||
* @var Json
|
||||
*/
|
||||
private Json $serializer;
|
||||
|
||||
/**
|
||||
* Validate order item before shipment
|
||||
*
|
||||
* @param Item $orderItem
|
||||
* @param array $items
|
||||
* @return bool
|
||||
*/
|
||||
private function validateItem(\Magento\Sales\Model\Order\Item $orderItem, array $items)
|
||||
{
|
||||
if (!$this->canShipItem($orderItem, $items)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from shipment items without qty or with qty=0
|
||||
if (!$orderItem->isDummy(true)
|
||||
&& (!isset($items[$orderItem->getId()]) || (float) $items[$orderItem->getId()] <= 0)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set prepared items to shipment document
|
||||
*
|
||||
* @param \Magento\Sales\Api\Data\ShipmentInterface $shipment
|
||||
* @param array $shipmentItems
|
||||
* @return \Magento\Sales\Api\Data\ShipmentInterface
|
||||
*/
|
||||
private function setItemsToShipment(\Magento\Sales\Api\Data\ShipmentInterface $shipment, $shipmentItems)
|
||||
{
|
||||
$totalQty = 0;
|
||||
|
||||
/**
|
||||
* Verify that composite products shipped separately has children, if not -> remove from collection
|
||||
*/
|
||||
/** @var \Magento\Sales\Model\Order\Shipment\Item $shipmentItem */
|
||||
foreach ($shipmentItems as $key => $shipmentItem) {
|
||||
if ($shipmentItem->getOrderItem()->getHasChildren()
|
||||
&& $shipmentItem->getOrderItem()->isShipSeparately()
|
||||
) {
|
||||
$containerId = $shipmentItem->getOrderItem()->getId();
|
||||
$childItems = array_filter($shipmentItems, function ($item) use ($containerId) {
|
||||
return $containerId == $item->getOrderItem()->getParentItemId();
|
||||
});
|
||||
|
||||
if (count($childItems) <= 0) {
|
||||
unset($shipmentItems[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$totalQty += $shipmentItem->getQty();
|
||||
$shipment->addItem($shipmentItem);
|
||||
}
|
||||
return $shipment->setTotalQty($totalQty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts Qty to float or integer type
|
||||
*
|
||||
* @param Item $item
|
||||
* @param string|int|float $qty
|
||||
* @return float|int
|
||||
*/
|
||||
private function castQty(\Magento\Sales\Model\Order\Item $item, $qty)
|
||||
{
|
||||
if ($item->getIsQtyDecimal()) {
|
||||
$qty = (double)$qty;
|
||||
} else {
|
||||
$qty = (int)$qty;
|
||||
}
|
||||
|
||||
return $qty > 0 ? $qty : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tracks to the shipment.
|
||||
*
|
||||
* @param \Magento\Sales\Api\Data\ShipmentInterface $shipment
|
||||
* @param array $tracks
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
* @return \Magento\Sales\Api\Data\ShipmentInterface
|
||||
*/
|
||||
protected function prepareTracks(\Magento\Sales\Api\Data\ShipmentInterface $shipment, array $tracks)
|
||||
{
|
||||
foreach ($tracks as $data) {
|
||||
if (empty($data['number'])) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(
|
||||
__('Please enter a tracking number.')
|
||||
);
|
||||
}
|
||||
|
||||
$shipment->addTrack(
|
||||
$this->trackFactory->create()->addData($data)
|
||||
);
|
||||
}
|
||||
|
||||
return $shipment;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\Order\Template;
|
||||
|
||||
use Magento\Framework\App\TemplateTypesInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Mail\AddressConverter;
|
||||
use Magento\Framework\Mail\EmailMessageInterfaceFactory;
|
||||
use Magento\Framework\Mail\MessageInterface;
|
||||
use Magento\Framework\Mail\MessageInterfaceFactory;
|
||||
use Magento\Framework\Mail\MimeInterface;
|
||||
use Magento\Framework\Mail\MimeMessageInterfaceFactory;
|
||||
use Magento\Framework\Mail\MimePartInterfaceFactory;
|
||||
use Magento\Framework\Mail\Template\FactoryInterface;
|
||||
use Magento\Framework\Mail\Template\SenderResolverInterface;
|
||||
use Magento\Framework\Mail\TransportInterfaceFactory;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Phrase;
|
||||
|
||||
class TransportBuilder extends \Magento\Framework\Mail\Template\TransportBuilder
|
||||
{
|
||||
/**
|
||||
* Param that used for storing all message data until it will be used
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $messageData = [];
|
||||
|
||||
/**
|
||||
* @var EmailMessageInterfaceFactory
|
||||
*/
|
||||
protected EmailMessageInterfaceFactory $emailMessageInterfaceFactory;
|
||||
|
||||
/**
|
||||
* @var MimeMessageInterfaceFactory
|
||||
*/
|
||||
protected MimeMessageInterfaceFactory $mimeMessageInterfaceFactory;
|
||||
|
||||
protected ?\Magento\Framework\Mail\MimePartInterface $attachmentMimePart = null;
|
||||
|
||||
/**
|
||||
* @var MimePartInterfaceFactory
|
||||
*/
|
||||
protected MimePartInterfaceFactory $mimePartInterfaceFactory;
|
||||
|
||||
public function __construct(FactoryInterface $templateFactory, MessageInterface $message, SenderResolverInterface $senderResolver, ObjectManagerInterface $objectManager, TransportInterfaceFactory $mailTransportFactory, MessageInterfaceFactory $messageFactory = null, EmailMessageInterfaceFactory $emailMessageInterfaceFactory = null, MimeMessageInterfaceFactory $mimeMessageInterfaceFactory = null, MimePartInterfaceFactory $mimePartInterfaceFactory = null, AddressConverter $addressConverter = null)
|
||||
{
|
||||
parent::__construct($templateFactory, $message, $senderResolver, $objectManager, $mailTransportFactory, $messageFactory, $emailMessageInterfaceFactory, $mimeMessageInterfaceFactory, $mimePartInterfaceFactory, $addressConverter);
|
||||
$this->emailMessageInterfaceFactory = $emailMessageInterfaceFactory ?: $this->objectManager
|
||||
->get(EmailMessageInterfaceFactory::class);
|
||||
$this->mimeMessageInterfaceFactory = $mimeMessageInterfaceFactory ?: $this->objectManager
|
||||
->get(MimeMessageInterfaceFactory::class);
|
||||
$this->mimePartInterfaceFactory = $mimePartInterfaceFactory ?: $this->objectManager
|
||||
->get(MimePartInterfaceFactory::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $messageData
|
||||
*/
|
||||
public function setMessageData(string $key, array $emails): static
|
||||
{
|
||||
$data = [];
|
||||
foreach ($emails as $email) {
|
||||
if (is_string($email)) {
|
||||
$data[] = new \Magento\Framework\Mail\Address($email, $email);
|
||||
}
|
||||
}
|
||||
if (!empty($data))
|
||||
$this->messageData[$key] = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare message.
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException if template type is unknown
|
||||
*/
|
||||
protected function prepareMessage()
|
||||
{
|
||||
$template = $this->getTemplate();
|
||||
$content = $template->processTemplate();
|
||||
|
||||
switch ($template->getType()) {
|
||||
case TemplateTypesInterface::TYPE_TEXT:
|
||||
$partType = MimeInterface::TYPE_TEXT;
|
||||
break;
|
||||
|
||||
case TemplateTypesInterface::TYPE_HTML:
|
||||
$partType = MimeInterface::TYPE_HTML;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LocalizedException(
|
||||
new Phrase('Unknown template type')
|
||||
);
|
||||
}
|
||||
|
||||
/** @var \Magento\Framework\Mail\MimePartInterface $mimePart */
|
||||
$mimePart = $this->mimePartInterfaceFactory->create(
|
||||
[
|
||||
'content' => $content,
|
||||
'type' => $partType
|
||||
]
|
||||
);
|
||||
|
||||
$this->messageData['sender'] = $mimePart->getCharset();
|
||||
$this->messageData['encoding'] = $mimePart->getCharset();
|
||||
$parts = [$mimePart];
|
||||
if ($this->attachmentMimePart!=null) {
|
||||
$parts[] = $this->attachmentMimePart;
|
||||
}
|
||||
$this->messageData['body'] = $this->mimeMessageInterfaceFactory->create(
|
||||
['parts' => $parts]
|
||||
);
|
||||
|
||||
$this->messageData['subject'] = html_entity_decode(
|
||||
(string)$template->getSubject(),
|
||||
ENT_QUOTES
|
||||
);
|
||||
$this->messageData['sender'] = new \Magento\Framework\Mail\Address('no-reply@stemcellmart.com.cn', 'STEMCELL在线商城');
|
||||
$this->messageData['form'] = $this->messageData['sender'];
|
||||
|
||||
|
||||
$this->message = $this->emailMessageInterfaceFactory->create($this->messageData);
|
||||
$this->message->setFromAddress('no-reply@stemcellmart.com.cn', 'STEMCELL经销商下单系统');
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function setAttachmentMimePart(array $attachment): static
|
||||
{
|
||||
$this->attachmentMimePart = $this->mimePartInterfaceFactory->create($attachment);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model;
|
||||
|
||||
enum OrderStatus
|
||||
{
|
||||
case rejected;
|
||||
|
||||
case reviewed;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model\ResourceModel\Order\Grid;
|
||||
|
||||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
|
||||
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
|
||||
use Magento\Framework\Event\ManagerInterface as EventManager;
|
||||
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
|
||||
use Psr\Log\LoggerInterface as Logger;
|
||||
use Stemcell\Customer\Model\ResourceModel\Salesperson as SalespersonResource;
|
||||
|
||||
/**
|
||||
* Order grid extended collection
|
||||
*/
|
||||
class Collection extends OriginalCollection
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
public function __construct(
|
||||
EntityFactory $entityFactory,
|
||||
Logger $logger,
|
||||
FetchStrategy $fetchStrategy,
|
||||
EventManager $eventManager,
|
||||
$mainTable = 'sales_order_grid',
|
||||
$resourceModel = \Magento\Sales\Model\ResourceModel\Order::class
|
||||
)
|
||||
{
|
||||
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
|
||||
}
|
||||
|
||||
protected function _renderFiltersBefore()
|
||||
{
|
||||
$salespersonTable = $this->getTable('salesperson');
|
||||
$this->getSelect()
|
||||
->joinLeft($salespersonTable, 'salesperson.salesperson_id = sales_order.salesperson_id', ['salesperson_name'=>'salesperson.name']);
|
||||
|
||||
parent::_renderFiltersBefore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Model;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\ResourceConnection as AppResource;
|
||||
use Magento\SalesSequence\Model\Meta;
|
||||
|
||||
class Sequence extends \Magento\SalesSequence\Model\Sequence
|
||||
{
|
||||
const DEFAULT_PATTERN = "%s%s%'.05d";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $lastIncrementId;
|
||||
|
||||
/**
|
||||
* @var Meta
|
||||
*/
|
||||
protected Meta $meta;
|
||||
|
||||
protected false|\Magento\Framework\DB\Adapter\AdapterInterface $connection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $pattern;
|
||||
protected Session $customerSession;
|
||||
|
||||
public function __construct(
|
||||
Meta $meta,
|
||||
AppResource $resource,
|
||||
Session $customerSession,
|
||||
string $pattern = self::DEFAULT_PATTERN
|
||||
) {
|
||||
$this->customerSession = $customerSession;
|
||||
$this->meta = $meta;
|
||||
$this->connection = $resource->getConnection('sales');
|
||||
$this->pattern = $pattern;
|
||||
parent::__construct($meta, $resource, $pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate current value depends on start value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateCurrentValue()
|
||||
{
|
||||
return ($this->lastIncrementId - $this->meta->getActiveProfile()->getStartValue())
|
||||
* $this->meta->getActiveProfile()->getStep() + $this->meta->getActiveProfile()->getStartValue();
|
||||
}
|
||||
|
||||
protected function getCustomerAbbr(){
|
||||
if ($this->customerSession->isLoggedIn()) {
|
||||
return $this->customerSession->getCustomer()->getData('customer_abbr');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve next value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextValue(): ?string
|
||||
{
|
||||
$this->connection->insert($this->meta->getSequenceTable(), []);
|
||||
$this->lastIncrementId = $this->connection->lastInsertId($this->meta->getSequenceTable());
|
||||
return $this->getCurrentValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve current value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentValue(): ?string
|
||||
{
|
||||
if (!isset($this->lastIncrementId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'STI'.
|
||||
date('Ymd').
|
||||
$this->getCustomerAbbr().
|
||||
sprintf("%'.05d", $this->calculateCurrentValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Sales\Model\Order;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Customer\Api\Data\SalespersonInterface;
|
||||
use Stemcell\Customer\Api\SalespersonRepositoryInterface;
|
||||
use Stemcell\Sales\Model\Order\Email\Sender\OrderSender;
|
||||
|
||||
class SalespersonNotify implements ObserverInterface
|
||||
{
|
||||
private OrderSender $orderMailSender;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
OrderSender $orderMailSender,
|
||||
LoggerInterface $logger,
|
||||
protected SalespersonRepositoryInterface $salespersonRepository,
|
||||
) {
|
||||
$this->orderMailSender = $orderMailSender;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Observer $observer
|
||||
* @return void
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
/** @var $orderInstance Order */
|
||||
$orderInstance = $observer->getOrder();
|
||||
$salespersonId = $orderInstance->getData('salesperson_id');
|
||||
try {
|
||||
if ($salespersonId) {
|
||||
$salesperson = $this->salespersonRepository->get($salespersonId);
|
||||
$this->orderMailSender->setSalesperson($salesperson)->send($orderInstance);
|
||||
} else {
|
||||
$this->logger->critical(sprintf('发送给销售的邮件失败,原因:订单%s的salesperson_id为空', $orderInstance->getEntityId()));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->critical('发送给销售的邮件失败,原因:'.$e->getMessage(), $e->getTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Observer\Shipping\Tracking;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Sales\Model\Order\Shipment;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Sales\Helper\Data;
|
||||
|
||||
class ExpressInfo implements ObserverInterface
|
||||
{
|
||||
protected Data $data;
|
||||
protected LoggerInterface $logger;
|
||||
protected RequestInterface $request;
|
||||
|
||||
public function __construct(
|
||||
Data $data,
|
||||
RequestInterface $request,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->data = $data;
|
||||
$this->logger = $logger;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
/* @var $shipment Shipment */
|
||||
$shipment = $observer->getData('shipment');
|
||||
/* @var $track Shipment\Track */
|
||||
$track = $shipment->getTracksCollection()->getFirstItem();
|
||||
$trackNumber = trim($track->getTrackNumber());
|
||||
$tracking = $this->request->getParam('tracking');
|
||||
if ($trackNumber && is_array($tracking) && !empty($tracking)) {
|
||||
try {
|
||||
$result = $this->data->getExpressInfo($trackNumber);
|
||||
if (isset($result['expName']) && !empty($result['expName'])) {
|
||||
$track->setTitle($result['expName'])->setDescription(json_encode($result))->save();
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
$this->logger->critical('request express info fail, message:'.$exception->getMessage(), $exception->getTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# 此模块需要增加一下两个status
|
||||
|
||||
- code: rejected,
|
||||
Status Label: 已驳回, Assign Status to State: canceled。此状态用于订单驳回的业务
|
||||
|
||||
- code: reviewed, Status Label: 已审核, Assign Status to State: processing
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\UiComponent\DataProvider;
|
||||
|
||||
use Magento\Framework\Api\Filter;
|
||||
use Magento\Framework\Data\Collection;
|
||||
use Magento\Framework\Data\Collection\AbstractDb;
|
||||
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
|
||||
|
||||
class FulltextFilter extends \Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter
|
||||
{
|
||||
protected array $escapePatterns = [
|
||||
'/[@\.]/' => '\_',
|
||||
'/([+\-><\(\)~*]+)/' => ' ',
|
||||
];
|
||||
|
||||
protected function escapeAgainstValue(string $value): string
|
||||
{
|
||||
return preg_replace(array_keys($this->escapePatterns), array_values($this->escapePatterns), $value);
|
||||
}
|
||||
|
||||
public function apply(Collection $collection, Filter $filter)
|
||||
{
|
||||
if (!$collection instanceof AbstractDb) {
|
||||
throw new \InvalidArgumentException('Database collection required.');
|
||||
}
|
||||
|
||||
/** @var SearchResult $collection */
|
||||
$mainTable = $collection->getMainTable();
|
||||
$columns = $this->getFulltextIndexColumns($collection, $mainTable);
|
||||
if (!$columns) {
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = $this->addTableAliasToColumns($columns, $collection, $mainTable);
|
||||
$whereCondition = '';
|
||||
foreach ($columns as $key => $field) {
|
||||
$condition = $field . " LIKE '%".$filter->getValue()."%'";
|
||||
$whereCondition .= ($key === 0 ? '' : ' OR ') . $condition;
|
||||
}
|
||||
$collection->getSelect()->where($whereCondition);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "stemcell/module-sales",
|
||||
"description": "extend Magento Core Sales",
|
||||
"type": "magento2-module",
|
||||
"license": "proprietary",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Liang Feng",
|
||||
"email": "344531331@qq.com"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"phpoffice/phpspreadsheet": "^1.29"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"registration.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Stemcell\\Sales\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
|
||||
<type name="Magento\Ui\Controller\Adminhtml\Export\GridToCsv">
|
||||
<arguments>
|
||||
<argument name="converter" xsi:type="object">Stemcell\Sales\Model\Export\ConvertToCsv</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
|
||||
<preference for="Magento\Sales\Block\Adminhtml\Order\View" type="Stemcell\Sales\Block\Adminhtml\Order\View" />
|
||||
<preference for="Magento\Sales\Block\Adminhtml\Order\Totals" type="Stemcell\Sales\Block\Adminhtml\Order\Totals" />
|
||||
<preference for="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" type="Stemcell\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" />
|
||||
</config>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
|
||||
<router id="admin">
|
||||
<route id="stemcell_sales" frontName="stemcell_sales">
|
||||
<module name="Stemcell_Sales" before="Magento_Backend" />
|
||||
</route>
|
||||
</router>
|
||||
|
||||
</config>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
|
||||
<default>
|
||||
<sales>
|
||||
<orders>
|
||||
<items_per_page>50</items_per_page>
|
||||
</orders>
|
||||
</sales>
|
||||
</default>
|
||||
</config>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
|
||||
<type name="Magento\SalesSequence\Model\SequenceFactory">
|
||||
<arguments>
|
||||
<argument name="instanceName" xsi:type="string">\Stemcell\Sales\Model\Sequence</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
|
||||
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
|
||||
<arguments>
|
||||
<argument name="collections" xsi:type="array">
|
||||
<item name="sales_order_grid_data_source" xsi:type="string">Stemcell\Sales\Model\ResourceModel\Order\Grid\Collection</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<type name="Stemcell\Sales\Model\ResourceModel\Order\Grid\Collection">
|
||||
<arguments>
|
||||
<argument name="mainTable" xsi:type="string">sales_order_grid</argument>
|
||||
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
|
||||
<preference for="\Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter" type="Stemcell\Sales\UiComponent\DataProvider\FulltextFilter" />
|
||||
|
||||
<preference for="\Magento\Ui\Controller\Adminhtml\Export\GridToCsv" type="Stemcell\Sales\Controller\Adminhtml\Export\GridToCsv" />
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
|
||||
<template id="sales_email_order_new_salesperson_template" label="Salesperson New Order" file="order_new_salesperson.html" type="html" module="Stemcell_Sales" area="frontend"/>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
|
||||
<event name="sales_order_shipment_save_after">
|
||||
<observer name="add_express_info_to_order_tracking" instance="\Stemcell\Sales\Observer\Shipping\Tracking\ExpressInfo" />
|
||||
</event>
|
||||
<event name="checkout_submit_all_after">
|
||||
<observer name="notify_salesperson" instance="Stemcell\Sales\Observer\SalespersonNotify" />
|
||||
</event>
|
||||
</config>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
|
||||
<type name="Magento\SalesSequence\Model\SequenceFactory">
|
||||
<arguments>
|
||||
<argument name="instanceName" xsi:type="string">\Stemcell\Sales\Model\Sequence</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
|
||||
<preference for="\Magento\Sales\Block\Order\Info" type="Stemcell\Sales\Block\Order\Info" />
|
||||
<preference for="\Magento\Sales\Block\Order\View" type="Stemcell\Sales\Block\Order\View" />
|
||||
</config>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
<router id="standard">
|
||||
|
||||
<route id="stemcell_sales" frontName="stemcell_sales">
|
||||
<module name="Stemcell_Sales" />
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Stemcell_Sales">
|
||||
<sequence>
|
||||
<module name="Magento_Sales" />
|
||||
<module name="Magento_Backend"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Stemcell_Sales', __DIR__);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<update handle="styles"/>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Magento\Backend\Block\Template" name="some_css" template="Stemcell_Sales::custom/css.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
|
||||
<body>
|
||||
<referenceBlock name="sales_order_edit">
|
||||
<block class="Stemcell\Sales\Block\Adminhtml\Order\Reject"
|
||||
name="stemcell_order_reject_button"
|
||||
template="Stemcell_Sales::order/reject.phtml"/>
|
||||
</referenceBlock>
|
||||
<referenceBlock name="order_tab_info">
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::order/view/tab/info.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceBlock name="order_history">
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::order/view/history.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceBlock name="order_info">
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::order/view/info.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceBlock name="order_items">
|
||||
<action method="setColumns">
|
||||
<argument name="columns" xsi:type="array">
|
||||
<item name="sku" xsi:type="string" translate="true">货号</item>
|
||||
<item name="product" xsi:type="string" translate="true">商品名</item>
|
||||
<item name="price" xsi:type="string" translate="true">经销商价格</item>
|
||||
<item name="ordered-qty" xsi:type="string" translate="true">数量</item>
|
||||
<item name="cd-code" xsi:type="string" translate="true">CD号</item>
|
||||
<item name="quote-code" xsi:type="string" translate="true">Quote号</item>
|
||||
<item name="discont" xsi:type="string" translate="true">折扣</item>
|
||||
<item name="subtotal" xsi:type="string" translate="true">总金额</item>
|
||||
|
||||
</argument>
|
||||
</action>
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::order/view/items.phtml</argument>
|
||||
</action>
|
||||
<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" name="default_order_items_renderer" template="Magento_Sales::order/view/items/renderer/default.phtml">
|
||||
<arguments>
|
||||
<argument name="columns" xsi:type="array">
|
||||
<item name="sku" xsi:type="string" translate="false">col-sku</item>
|
||||
<item name="product" xsi:type="string" translate="false">col-product</item>
|
||||
<item name="price" xsi:type="string" translate="false">col-price</item>
|
||||
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
|
||||
<item name="cd-code" xsi:type="string" translate="true">cd-code</item>
|
||||
<item name="quote-code" xsi:type="string" translate="true">quote-code</item>
|
||||
<item name="discont" xsi:type="string" translate="false">col-discont</item>
|
||||
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
|
||||
|
||||
</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceBlock name="column_name">
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::items/column/name.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceBlock name="column_qty">
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Stemcell_Sales::items/column/qty.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
</body>
|
||||
|
||||
</page>
|
||||
@@ -0,0 +1,3 @@
|
||||
<style>
|
||||
.sales-order-index .data-grid-actions-cell a{text-wrap: nowrap}
|
||||
</style>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @var $block \Magento\Sales\Block\Adminhtml\Items\Column\Name
|
||||
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php
|
||||
/** @var \Magento\Catalog\Helper\Data $catalogHelper */
|
||||
$catalogHelper = $block->getData('catalogHelper');
|
||||
?>
|
||||
<?php if ($_item = $block->getItem()): ?>
|
||||
<div id="order_item_<?= (int) $_item->getId() ?>_title"
|
||||
class="product-title">
|
||||
<?= $block->escapeHtml($_item->getProductOptionByCode('simple_name')?? $_item->getName()) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if ($block->getOrderOptions()): ?>
|
||||
<dl class="item-options">
|
||||
<?php foreach ($block->getOrderOptions() as $_option): ?>
|
||||
<dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
|
||||
<dd>
|
||||
<?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
|
||||
<?= /* @noEscape */ $block->getCustomizedOptionValue($_option) ?>
|
||||
<?php else: ?>
|
||||
<?php $_option = $block->getFormattedOption($_option['value']); ?>
|
||||
<?php $dots = 'dots' . uniqid(); ?>
|
||||
<?php $id = 'id' . uniqid(); ?>
|
||||
<?= $block->escapeHtml($_option['value'], ['a', 'br']) ?>
|
||||
<?php if (isset($_option['remainder']) && $_option['remainder']): ?>
|
||||
<span id="<?= /* @noEscape */ $dots; ?>"> ...</span>
|
||||
<span id="<?= /* @noEscape */ $id; ?>">
|
||||
<?= $block->escapeHtml($_option['remainder'], ['a']) ?>
|
||||
</span>
|
||||
<?php $scriptString = <<<script
|
||||
require(['prototype'], function() {
|
||||
|
||||
script;
|
||||
$scriptString .= "$('" . /* @noEscape */ $id . "').hide();" . PHP_EOL;
|
||||
$scriptString .= "$('" . /* @noEscape */ $id .
|
||||
"').up().observe('mouseover', function(){ $('" . /* @noEscape */ $id . "').show();});" .
|
||||
PHP_EOL;
|
||||
$scriptString .= "$('" . /* @noEscape */ $id .
|
||||
"').up().observe('mouseover', function(){ $('" . /* @noEscape */ $dots .
|
||||
"').hide();});" . PHP_EOL;
|
||||
$scriptString .= "$('" . /* @noEscape */ $id .
|
||||
"').up().observe('mouseout', function(){ $('" . /* @noEscape */ $id .
|
||||
"').hide();});" . PHP_EOL;
|
||||
$scriptString .= "$('" . /* @noEscape */ $id .
|
||||
"').up().observe('mouseout', function(){ $('" . /* @noEscape */ $dots .
|
||||
"').show();});" . PHP_EOL . "});" . PHP_EOL;
|
||||
?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
<?= $block->escapeHtml($_item->getDescription()) ?>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php if ($item = $block->getItem()) : ?>
|
||||
<table class="qty-table">
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?= (float) $item->getQtyOrdered() ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if ((float)$item->getQtyInvoiced()) : ?>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?= (float) $item->getQtyInvoiced() ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ((float)$item->getQtyShipped()) : ?>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?= (float) $item->getQtyShipped() ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ((float)$item->getQtyRefunded()) : ?>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?= (float) $item->getQtyRefunded() ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ((float)$item->getQtyCanceled()) : ?>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><?= (float) $item->getQtyCanceled() ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $block */
|
||||
$_item = $block->getItem();
|
||||
?>
|
||||
<div class="price-excl-tax">
|
||||
<?= /* @noEscape */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $block */
|
||||
$_item = $block->getItem();
|
||||
?>
|
||||
<?= /* @noEscape */ $block->displayPrices($block->getBaseTotalAmount($_item), $block->getTotalAmount($_item)) ?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $block */
|
||||
$_item = $block->getItem();
|
||||
?>
|
||||
<div class="price-excl-tax">
|
||||
<?= /* @noEscape */ $block->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
// phpcs:disable Magento2.Templates.ThisInTemplate
|
||||
?>
|
||||
<?= $block->escapeHtml($block->getItem()->getName()) ?>
|
||||
<div><strong><?= $block->escapeHtml(__('SKU')) ?>:</strong> <?= /* @noEscape */ implode('<br />', $this->helper(\Magento\Catalog\Helper\Data::class)->splitSku($block->escapeHtml($block->getItem()->getSku()))) ?></div>
|
||||
<?php if ($block->getOrderOptions()) : ?>
|
||||
<ul class="item-options">
|
||||
<?php foreach ($block->getOrderOptions() as $option) : ?>
|
||||
<li><strong><?= $block->escapeHtml($option['label']) ?>:</strong><br />
|
||||
<?php if (is_array($option['value'])) : ?>
|
||||
<?php foreach ($option['value'] as $item) : ?>
|
||||
<?= $block->getValueHtml($item) ?><br />
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?= $block->escapeHtml($option['value']) ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?= $block->escapeHtml($block->getItem()->getDescription()) ?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/* @var $block \Stemcell\Sales\Block\Adminhtml\Order\Reject */
|
||||
$order = $block->getOrder();
|
||||
$rejectUrl = $block->getRejectUrl();
|
||||
?>
|
||||
<?php if ($block->canReject()): ?>
|
||||
<button id="order-reject-button"
|
||||
class="action-default scalable"
|
||||
type="button">
|
||||
驳回
|
||||
</button>
|
||||
|
||||
<div id="reject-modal" style="display:none;">
|
||||
<form id="reject-form" method="post" action="<?php echo $rejectUrl; ?>">
|
||||
<input type="hidden" name="form_key" value="<?php echo $block->getFormKey(); ?>"/>
|
||||
<input type="hidden" name="order_id" value="<?php echo $order->getId(); ?>"/>
|
||||
|
||||
<label for="reason">Reject Reason</label>
|
||||
<textarea name="reason" id="reason" style="width:100%; height:150px;"></textarea>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['jquery', 'Magento_Ui/js/modal/modal'], function ($, modal) {
|
||||
|
||||
var options = {
|
||||
type: 'popup',
|
||||
title: 'Reject Order',
|
||||
responsive: true,
|
||||
buttons: [{
|
||||
text: 'Submit',
|
||||
class: 'action-primary',
|
||||
click: function () {
|
||||
$('#reject-form').submit();
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
var popup = modal(options, $('#reject-modal'));
|
||||
|
||||
$('#order-reject-button').on('click', function () {
|
||||
$('#reject-modal').modal('openModal');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var \Magento\Sales\Block\Adminhtml\Order\View\History $block */
|
||||
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
|
||||
?>
|
||||
<div id="order_history_block" class="edit-order-comments">
|
||||
<?php if (0 && $block->canAddComment()): ?>
|
||||
<div class="order-history-block" id="history_form">
|
||||
|
||||
<div class="admin__field">
|
||||
<label for="history_status" class="admin__field-label"><?= $block->escapeHtml(__('Status')) ?></label>
|
||||
<div class="admin__field-control">
|
||||
<select name="history[status]" id="history_status" class="admin__control-select">
|
||||
<?php foreach ($block->getStatuses() as $_code => $_label): ?>
|
||||
<option value="<?= $block->escapeHtmlAttr($_code) ?>"
|
||||
<?php if ($_code == $block->getOrder()->getStatus()): ?> selected="selected"
|
||||
<?php endif; ?>>
|
||||
<?= $block->escapeHtml($_label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label for="history_comment" class="admin__field-label">
|
||||
<?= $block->escapeHtml(__('Comment')) ?>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<textarea name="history[comment]"
|
||||
rows="3"
|
||||
cols="5"
|
||||
id="history_comment"
|
||||
class="admin__control-textarea"></textarea>
|
||||
<div class="admin__field-note">
|
||||
<span>
|
||||
<?= $block->escapeHtml(
|
||||
__('A status change or comment text is required to submit a comment.')
|
||||
)?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<div class="order-history-comments-options">
|
||||
<div class="admin__field admin__field-option">
|
||||
<?php if ($block->canSendCommentEmail()): ?>
|
||||
<input name="history[is_customer_notified]"
|
||||
type="checkbox"
|
||||
id="history_notify"
|
||||
class="admin__control-checkbox"
|
||||
value="1" />
|
||||
<label class="admin__field-label" for="history_notify">
|
||||
<?= $block->escapeHtml(__('Notify Customer by Email')) ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="admin__field admin__field-option">
|
||||
<input name="history[is_visible_on_front]"
|
||||
type="checkbox"
|
||||
id="history_visible"
|
||||
class="admin__control-checkbox"
|
||||
value="1" />
|
||||
<label class="admin__field-label" for="history_visible">
|
||||
<?= $block->escapeHtml(__('Visible on Storefront')) ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="order-history-comments-actions">
|
||||
<?= $block->getChildHtml('submit_button') ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
|
||||
<ul class="note-list">
|
||||
<?php foreach ($block->getOrder()->getStatusHistoryCollection(true) as $_item): ?>
|
||||
<li class="note-list-item">
|
||||
<span class="note-list-date">
|
||||
<?= /* @noEscape */ $block->formatDate($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?>
|
||||
</span>
|
||||
<span class="note-list-time">
|
||||
<?= /* @noEscape */ $block->formatTime($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?>
|
||||
</span>
|
||||
<span class="note-list-status"><?= $block->escapeHtml($_item->getStatusLabel()) ?></span>
|
||||
<span class="note-list-customer">
|
||||
<?= $block->escapeHtml(__('Customer')) ?>
|
||||
<?php if ($block->isCustomerNotificationNotApplicable($_item)): ?>
|
||||
<span class="note-list-customer-notapplicable">
|
||||
<?= $block->escapeHtml(__('Notification Not Applicable')) ?>
|
||||
</span>
|
||||
<?php elseif ($_item->getIsCustomerNotified()): ?>
|
||||
<span class="note-list-customer-notified"><?= $block->escapeHtml(__('Notified')) ?></span>
|
||||
<?php else: ?>
|
||||
<span class="note-list-customer-not-notified"><?= $block->escapeHtml(__('Not Notified')) ?></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php if ($_item->getComment()): ?>
|
||||
<div class="note-list-comment">
|
||||
<?= $block->escapeHtml($_item->getComment(), ['b', 'br', 'strong', 'i', 'u', 'a']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php $scriptString = <<<script
|
||||
require(['prototype'], function(){
|
||||
if($('order_status'))$('order_status').update('{$block->escapeJs($block->getOrder()->getStatusLabel())}');
|
||||
});
|
||||
script;
|
||||
?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
|
||||
</div>
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var \Magento\Sales\Block\Adminhtml\Order\View\Info $block
|
||||
*/
|
||||
$order = $block->getOrder();
|
||||
|
||||
$baseCurrencyCode = (string)$order->getBaseCurrencyCode();
|
||||
$globalCurrencyCode = (string)$order->getGlobalCurrencyCode();
|
||||
$orderCurrencyCode = (string)$order->getOrderCurrencyCode();
|
||||
|
||||
$orderAdminDate = $block->formatDate(
|
||||
$block->getOrderAdminDate($order->getCreatedAt()),
|
||||
\IntlDateFormatter::MEDIUM,
|
||||
true
|
||||
);
|
||||
|
||||
$orderStoreDate = $block->formatDate(
|
||||
$order->getCreatedAt(),
|
||||
\IntlDateFormatter::MEDIUM,
|
||||
true,
|
||||
$block->getTimezoneForStore($order->getStore())
|
||||
);
|
||||
|
||||
$customerUrl = $block->getCustomerViewUrl();
|
||||
|
||||
$allowedAddressHtmlTags = ['b', 'br', 'em', 'i', 'li', 'ol', 'p', 'strong', 'sub', 'sup', 'ul'];
|
||||
?>
|
||||
|
||||
<section class="admin__page-section order-view-account-information">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Order & Account Information')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-content">
|
||||
<div class="admin__page-section-item order-information">
|
||||
<?php /* Order Information */ ?>
|
||||
<?php $confirmationEmailStatusMessage = $order->getEmailSent() ? __('The order confirmation email was sent') : __('The order confirmation email is not sent'); ?>
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title">
|
||||
<?php if ($block->getNoUseOrderLink()) : ?>
|
||||
<?= $block->escapeHtml(__('Order # %1', $order->getRealOrderId())) ?> (<span><?= $block->escapeHtml($confirmationEmailStatusMessage) ?></span>)
|
||||
<?php else : ?>
|
||||
<a href="<?= $block->escapeUrl($block->getViewUrl($order->getId())) ?>"><?= $block->escapeHtml(__('Order # %1', $order->getRealOrderId())) ?></a>
|
||||
<span>(<?= $block->escapeHtml($confirmationEmailStatusMessage) ?>)</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="admin__page-section-item-content">
|
||||
<table class="admin__table-secondary order-information-table">
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Order Date')) ?></th>
|
||||
<td><?= $block->escapeHtml($orderAdminDate) ?></td>
|
||||
</tr>
|
||||
<?php if ($orderAdminDate != $orderStoreDate) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Order Date (%1)', $block->getTimezoneForStore($order->getStore()))) ?></th>
|
||||
<td><?= $block->escapeHtml($orderStoreDate) ?></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Order Status')) ?></th>
|
||||
<td><span id="order_status"><?= $block->escapeHtml($order->getStatusLabel()) ?></span></td>
|
||||
</tr>
|
||||
<?= $block->getChildHtml() ?>
|
||||
<!-- --><?php //if ($block->isSingleStoreMode() == false) : ?>
|
||||
<!-- <tr>-->
|
||||
<!-- <th>--><?php //= $block->escapeHtml(__('Purchased From')) ?><!--</th>-->
|
||||
<!-- <td>--><?php //= $block->escapeHtml($block->getOrderStoreName(), ['br']) ?><!--</td>-->
|
||||
<!-- </tr>-->
|
||||
<!-- --><?php //endif; ?>
|
||||
<?php if ($order->getRelationChildId()) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Link to the New Order')) ?></th>
|
||||
<td>
|
||||
<a href="<?= $block->escapeUrl($block->getViewUrl($order->getRelationChildId())) ?>">
|
||||
<?= $block->escapeHtml($order->getRelationChildRealId()) ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($order->getRelationParentId()) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Link to the Previous Order')) ?></th>
|
||||
<td>
|
||||
<a href="<?= $block->escapeUrl($block->getViewUrl($order->getRelationParentId())) ?>">
|
||||
<?= $block->escapeHtml($order->getRelationParentRealId()) ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<!-- --><?php //if ($order->getRemoteIp() && $block->shouldDisplayCustomerIp()) : ?>
|
||||
<!-- <tr>-->
|
||||
<!-- <th>--><?php //= $block->escapeHtml(__('Placed from IP')) ?><!--</th>-->
|
||||
<!-- <td>--><?php //= $block->escapeHtml($order->getRemoteIp()); ?><!----><?php //= $order->getXForwardedFor() ? ' (' . $block->escapeHtml($order->getXForwardedFor()) . ')' : ''; ?><!--</td>-->
|
||||
<!-- </tr>-->
|
||||
<!-- --><?php //endif; ?>
|
||||
<?php if ($globalCurrencyCode !== $baseCurrencyCode) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('%1 / %2 rate:', $globalCurrencyCode, $baseCurrencyCode)) ?></th>
|
||||
<td><?= $block->escapeHtml($order->getBaseToGlobalRate()) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($baseCurrencyCode !== $orderCurrencyCode && $globalCurrencyCode !== $orderCurrencyCode) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('%1 / %2 rate:', $orderCurrencyCode, $baseCurrencyCode)) ?></th>
|
||||
<td><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__page-section-item order-account-information">
|
||||
<?php /* Account Information */ ?>
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Account Information')) ?></span>
|
||||
<div class="actions">
|
||||
<?php if ($customerUrl) : ?>
|
||||
<a href="<?= /* @noEscape */ $customerUrl ?>" target="_blank">
|
||||
<?= $block->escapeHtml(__('Edit Customer')) ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__page-section-item-content">
|
||||
<table class="admin__table-secondary order-account-information-table">
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Customer Name')) ?></th>
|
||||
<td>
|
||||
<?php if ($customerUrl) : ?>
|
||||
<a href="<?= $block->escapeUrl($customerUrl) ?>" target="_blank">
|
||||
<span><?= $block->escapeHtml($order->getCustomerName()) ?></span>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<?= $block->escapeHtml($order->getCustomerName()) ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Email')) ?></th>
|
||||
<td><a href="mailto:<?= $block->escapeHtmlAttr($order->getCustomerEmail()) ?>"><?= $block->escapeHtml($order->getCustomerEmail()) ?></a></td>
|
||||
</tr>
|
||||
<?php if ($groupName = $block->getCustomerGroupName()) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml(__('Customer Group')) ?></th>
|
||||
<td><?= $block->escapeHtml($groupName) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($block->getCustomerAccountData() as $data) : ?>
|
||||
<tr>
|
||||
<th><?= $block->escapeHtml($data['label']) ?></th>
|
||||
<td><?= $block->escapeHtml($data['value'], ['br']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?= $block->getChildHtml('extra_customer_info') ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="admin__page-section order-addresses">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Address Information')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-content">
|
||||
<div class="admin__page-section-item order-billing-address">
|
||||
<?php /* Billing Address */ ?>
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Billing Address')) ?></span>
|
||||
<div class="actions"><?= /* @noEscape */ $block->getAddressEditLink($order->getBillingAddress()); ?></div>
|
||||
</div>
|
||||
<address class="admin__page-section-item-content"><?= $block->escapeHtml($block->getFormattedAddress($order->getBillingAddress()), $allowedAddressHtmlTags); ?></address>
|
||||
</div>
|
||||
<?php if (!$block->getOrder()->getIsVirtual()) : ?>
|
||||
<div class="admin__page-section-item order-shipping-address">
|
||||
<?php /* Shipping Address */ ?>
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Shipping Address')) ?></span>
|
||||
<div class="actions"><?= /* @noEscape */ $block->getAddressEditLink($order->getShippingAddress()); ?></div>
|
||||
</div>
|
||||
<address class="admin__page-section-item-content"><?= $block->escapeHtml($block->getFormattedAddress($order->getShippingAddress()), $allowedAddressHtmlTags); ?></address>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var \Magento\Sales\Block\Adminhtml\Order\View\Items $block
|
||||
*/
|
||||
|
||||
$_order = $block->getOrder() ?>
|
||||
<div class="admin__table-wrapper">
|
||||
<table class="data-table admin__table-primary edit-order-table">
|
||||
<thead>
|
||||
<tr class="headings">
|
||||
<?php $i = 0;
|
||||
$columns = $block->getColumns();
|
||||
$lastItemNumber = count($columns) ?>
|
||||
<?php foreach ($columns as $columnName => $columnTitle) : ?>
|
||||
<?php $i++; ?>
|
||||
<th class="col-<?= $block->escapeHtmlAttr($columnName) ?><?= /* @noEscape */ ($i === $lastItemNumber ? ' last' : '') ?>"><span><?= $block->escapeHtml($columnTitle) ?></span></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php $_items = $block->getItemsCollection();?>
|
||||
<?php $i = 0; foreach ($_items as $_item) : ?>
|
||||
<?php if ($_item->getParentItem()) :
|
||||
continue;
|
||||
else :
|
||||
$i++;
|
||||
endif; ?>
|
||||
<tbody class="<?= /* @noEscape */ $i%2 ? 'even' : 'odd' ?>">
|
||||
<?= $block->getItemHtml($_item) ?>
|
||||
<?= $block->getItemExtraInfoHtml($_item) ?>
|
||||
</tbody>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="reject-order-modal" style="display:none;">
|
||||
<form id="reject_order_form"
|
||||
method="post"
|
||||
action="<?= $block->getUrl('stemcell_sales/order/reject') ?>"
|
||||
enctype="multipart/form-data">
|
||||
|
||||
<?= $block->getBlockHtml('formkey'); ?>
|
||||
|
||||
<label>原因:</label>
|
||||
<textarea name="reason" id="reject_reason" style="width:100%;height:120px;"></textarea>
|
||||
|
||||
<input type="hidden" name="order_id" value="<?= $block->getOrder()->getId(); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
require([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/modal'
|
||||
], function ($, modal) {
|
||||
|
||||
window.orderReject = function () {
|
||||
|
||||
var modalEl = $('#reject-order-modal');
|
||||
|
||||
var options = {
|
||||
type: 'popup',
|
||||
title: '订单驳回',
|
||||
modalClass: 'reject-order-popup',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Submit',
|
||||
class: 'action-primary',
|
||||
click: function () {
|
||||
var reason = $('#reject_reason').val();
|
||||
if (!reason) {
|
||||
alert('请填写驳回的原因');
|
||||
return;
|
||||
}
|
||||
|
||||
$("#reject_order_form").submit();
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
modal(options, modalEl);
|
||||
modalEl.modal('openModal');
|
||||
};
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var $block \Magento\Sales\Block\Adminhtml\Order\View\Tab\Info */
|
||||
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
|
||||
?>
|
||||
<?php $_order = $block->getOrder() ?>
|
||||
|
||||
<div id="order-messages">
|
||||
<?= $block->getChildHtml('order_messages') ?>
|
||||
</div>
|
||||
|
||||
<?= $block->getChildHtml('order_info') ?>
|
||||
<input type="hidden" name="order_id" value="<?= (int) $_order->getId() ?>"/>
|
||||
|
||||
<section class="admin__page-section order-view-billing-shipping">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Payment & Shipping Method')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-content">
|
||||
<div class="admin__page-section-item order-payment-method<?= ($_order->getIsVirtual() ?
|
||||
' order-payment-method-virtual' : '') ?>">
|
||||
<?php /* Payment Method */ ?>
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Payment Information')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-item-content">
|
||||
<div class="order-payment-method-title"><?= $block->getPaymentHtml() ?></div>
|
||||
<div class="order-payment-currency">
|
||||
<?= $block->escapeHtml(__('The order was placed using %1.', $_order->getOrderCurrencyCode())) ?>
|
||||
</div>
|
||||
<div class="order-payment-additional">
|
||||
<?= $block->getChildHtml('order_payment_additional') ?>
|
||||
<?= $block->getChildHtml('payment_additional_info') ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $block->getChildHtml('order_shipping_view') ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?= $block->getChildHtml('order_additional_info') ?>
|
||||
|
||||
<?= $block->getGiftOptionsHtml() ?>
|
||||
|
||||
<section class="admin__page-section">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Items Ordered')) ?></span>
|
||||
</div>
|
||||
<?= $block->getItemsHtml() ?>
|
||||
</section>
|
||||
|
||||
<section class="admin__page-section">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Order Total')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-content" style="display: flex; gap: 30px">
|
||||
|
||||
<div class="admin__page-section-item order-totals" style="float: none">
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Order Totals')) ?></span>
|
||||
</div>
|
||||
<?= $block->getChildHtml('order_totals') ?>
|
||||
</div>
|
||||
<div class="admin__page-section-item order-comments-history" style="float: none">
|
||||
<div class="admin__page-section-item-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Notes for this Order')) ?></span>
|
||||
</div>
|
||||
<?= $block->getChildHtml('order_history') ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?= $block->getChildHtml('popup_window') ?>
|
||||
<style>
|
||||
.page-columns .side-col {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.page-layout-admin-2columns-left .page-columns .main-col {
|
||||
width: 100%;
|
||||
float: none;
|
||||
}
|
||||
.page-layout-admin-2columns-left .page-columns {
|
||||
margin-left: 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<?php $scriptString = <<<script
|
||||
require([
|
||||
"prototype",
|
||||
"Magento_Sales/order/giftoptions_tooltip"
|
||||
], function(){
|
||||
|
||||
//<![CDATA[
|
||||
/**
|
||||
* Retrieve gift options tooltip content
|
||||
*/
|
||||
function getGiftOptionsTooltipContent(itemId) {
|
||||
var contentLines = [];
|
||||
var headerLine = null;
|
||||
var contentLine = null;
|
||||
|
||||
\$$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
|
||||
if (element.down(0)) {
|
||||
headerLine = element.down(0).innerHTML;
|
||||
contentLine = element.down(0).next().innerHTML;
|
||||
if (contentLine.length > 30) {
|
||||
contentLine = contentLine.slice(0,30) + '...';
|
||||
}
|
||||
contentLines.push(headerLine + ' ' + contentLine);
|
||||
}
|
||||
});
|
||||
return contentLines.join('<br/>');
|
||||
}
|
||||
giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
|
||||
window.getGiftOptionsTooltipContent = getGiftOptionsTooltipContent;
|
||||
//]]>
|
||||
|
||||
});
|
||||
script;
|
||||
?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
|
||||
@@ -0,0 +1,305 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<buttons>
|
||||
<button name="add">
|
||||
<url path="sales/order_create/start"/>
|
||||
<class>primary</class>
|
||||
<label translate="true">Create New Order</label>
|
||||
<aclResource>Magento_Sales::create</aclResource>
|
||||
</button>
|
||||
</buttons>
|
||||
<spinner>sales_order_columns</spinner>
|
||||
<deps>
|
||||
<dep>sales_order_grid.sales_order_grid_data_source</dep>
|
||||
</deps>
|
||||
</settings>
|
||||
<dataSource name="sales_order_grid_data_source" component="Magento_Ui/js/grid/provider">
|
||||
<settings>
|
||||
<updateUrl path="mui/index/render"/>
|
||||
</settings>
|
||||
<aclResource>Magento_Sales::sales_order</aclResource>
|
||||
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider" name="sales_order_grid_data_source">
|
||||
<settings>
|
||||
<requestFieldName>id</requestFieldName>
|
||||
<primaryFieldName>main_table.entity_id</primaryFieldName>
|
||||
</settings>
|
||||
</dataProvider>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings>
|
||||
<sticky>true</sticky>
|
||||
</settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<exportButton name="export_button"/>
|
||||
<filterSearch name="fulltext"/>
|
||||
<filters name="listing_filters">
|
||||
<filterSelect name="store_id" provider="${ $.parentName }">
|
||||
<settings>
|
||||
<options class="Magento\Store\Ui\Component\Listing\Column\Store\Options"/>
|
||||
<caption translate="true">All Store Views</caption>
|
||||
<label translate="true">Purchase Point</label>
|
||||
<dataScope>store_id</dataScope>
|
||||
<imports>
|
||||
<link name="visible">ns = ${ $.ns }, index = ${ $.index }:visible</link>
|
||||
</imports>
|
||||
</settings>
|
||||
</filterSelect>
|
||||
</filters>
|
||||
<massaction name="listing_massaction" component="Magento_Ui/js/grid/tree-massactions">
|
||||
<action name="cancel">
|
||||
<settings>
|
||||
<url path="sales/order/massCancel"/>
|
||||
<type>cancel</type>
|
||||
<label translate="true">Cancel</label>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="mass_review">
|
||||
<settings>
|
||||
<url path="stemcell_sales/*/massReview"/>
|
||||
<type>mass_review</type>
|
||||
<label translate="true">批量审核</label>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="hold_order">
|
||||
<settings>
|
||||
<url path="sales/order/massHold"/>
|
||||
<type>hold_order</type>
|
||||
<label translate="true">Hold</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="unhold_order">
|
||||
<settings>
|
||||
<url path="sales/order/massUnhold"/>
|
||||
<type>unhold_order</type>
|
||||
<label translate="true">Unhold</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="pdfinvoices_order">
|
||||
<settings>
|
||||
<url path="sales/order/pdfinvoices"/>
|
||||
<type>pdfinvoices_order</type>
|
||||
<label translate="true">Print Invoices</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="pdfshipments_order">
|
||||
<settings>
|
||||
<url path="sales/order/pdfshipments"/>
|
||||
<type>pdfshipments_order</type>
|
||||
<label translate="true">Print Packing Slips</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="pdfcreditmemos_order">
|
||||
<settings>
|
||||
<url path="sales/order/pdfcreditmemos"/>
|
||||
<type>pdfcreditmemos_order</type>
|
||||
<label translate="true">Print Credit Memos</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="pdfdocs_order">
|
||||
<settings>
|
||||
<url path="sales/order/pdfdocs"/>
|
||||
<type>pdfdocs_order</type>
|
||||
<label translate="true">Print All</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="print_shipping_label">
|
||||
<settings>
|
||||
<url path="adminhtml/order_shipment/massPrintShippingLabel"/>
|
||||
<type>print_shipping_label</type>
|
||||
<label translate="true">Print Shipping Labels</label>
|
||||
<actionDisable>true</actionDisable>
|
||||
</settings>
|
||||
</action>
|
||||
</massaction>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="sales_order_columns">
|
||||
<settings>
|
||||
<childDefaults>
|
||||
<param name="fieldAction" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.actions</item>
|
||||
<item name="target" xsi:type="string">applyAction</item>
|
||||
<item name="params" xsi:type="array">
|
||||
<item name="0" xsi:type="string">view</item>
|
||||
<item name="1" xsi:type="string">${ $.$data.rowIndex }</item>
|
||||
</item>
|
||||
</param>
|
||||
</childDefaults>
|
||||
</settings>
|
||||
<selectionsColumn name="ids" component="Magento_Sales/js/grid/columns/multiselect">
|
||||
<settings>
|
||||
<indexField>entity_id</indexField>
|
||||
</settings>
|
||||
</selectionsColumn>
|
||||
<column name="increment_id">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">ID</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store">
|
||||
<settings>
|
||||
<label translate="true">Purchase Point</label>
|
||||
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
|
||||
<sortable>false</sortable>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
|
||||
<settings>
|
||||
<filter>dateRange</filter>
|
||||
<dataType>date</dataType>
|
||||
<label translate="true">Purchase Date</label>
|
||||
<sorting>desc</sorting>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="billing_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Sold-to Name</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="shipping_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Ship-to Name</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<label translate="true">Grand Total (Base)</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<label translate="true">Grand Total (Purchased)</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="status" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<filter>select</filter>
|
||||
<options class="Magento\Sales\Ui\Component\Listing\Column\Status\Options"/>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Status</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Billing Address</label>
|
||||
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Shipping Address</label>
|
||||
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="shipping_information">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Shipping Information</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="customer_email">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Customer Email</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="customer_group" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<filter>select</filter>
|
||||
<options class="Magento\Customer\Ui\Component\Listing\Column\Group\Options"/>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Customer Group</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<label translate="true">Subtotal</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<label translate="true">Shipping and Handling</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="customer_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Customer Name</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="salesperson_name">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="sortable" xsi:type="boolean">false</item>
|
||||
<item name="filter" xsi:type="string">false</item>
|
||||
<item name="label" xsi:type="string" translate="true">销售</item>
|
||||
</item>
|
||||
</argument>
|
||||
</column>
|
||||
<column name="payment_method" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<filter>select</filter>
|
||||
<options class="Magento\Payment\Ui\Component\Listing\Column\Method\Options"/>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Payment Method</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="total_refunded" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<label translate="true">Total Refunded</label>
|
||||
<visible>false</visible>
|
||||
</settings>
|
||||
</column>
|
||||
<actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="viewUrlPath" xsi:type="string">sales/order/view</item>
|
||||
<item name="urlEntityParamName" xsi:type="string">order_id</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<indexField>entity_id</indexField>
|
||||
</settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
@@ -0,0 +1,49 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<!--@subject {{trans "在线商城-新订单"}} @-->
|
||||
<!--@vars {
|
||||
"var formattedBillingAddress|raw":"Billing Address",
|
||||
"var order_data.email_customer_note|escape|nl2br":"Email Order Note",
|
||||
"var order.increment_id":"Order Id",
|
||||
"layout handle=\"sales_email_order_items\" order=$order area=\"frontend\"":"Order Items Grid",
|
||||
"var payment_html|raw":"Payment Details",
|
||||
"var formattedShippingAddress|raw":"Shipping Address",
|
||||
"var order.shipping_description":"Shipping Description",
|
||||
"var shipping_msg":"Shipping message",
|
||||
"var created_at_formatted":"Order Created At (datetime)",
|
||||
"var store.frontend_name":"Store Frontend Name",
|
||||
"var store_phone":"Store Phone",
|
||||
"var store_email":"Store Email",
|
||||
"var store_hours":"Store Hours",
|
||||
"var this.getUrl($store,'customer/account/',[_nosid:1])":"Customer Account URL",
|
||||
"var order_data.is_not_virtual":"Order Type",
|
||||
"var order":"Order",
|
||||
"var order_id": "Order DB Id",
|
||||
"var order_data.customer_name":"Customer Name"
|
||||
} @-->
|
||||
|
||||
{{template config_path="design/email/header_template"}}
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr class="email-intro">
|
||||
<td>
|
||||
<p>
|
||||
会员名称:{{trans "%customer_name," customer_name=$order_data.customer_name}}
|
||||
</p>
|
||||
<p>
|
||||
{{trans '订单编号: <span class="no-link">#%increment_id</span>' increment_id=$order.increment_id |raw}}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="email-information">
|
||||
<td>
|
||||
{{layout handle="sales_email_order_salesperson_items" order_id=$order_data.order_id order_items=$orderItems salesperson=$salesperson area="frontend"}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{{template config_path="design/email/footer_template"}}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Order Items List" design_abstraction="custom">
|
||||
<update handle="sales_email_order_renderers"/>
|
||||
<update handle="sales_email_item_price"/>
|
||||
<body>
|
||||
<block class="Stemcell\Sales\Block\Order\Email\Items" name="items" template="Magento_Sales::email/items.phtml" cacheable="false">
|
||||
<block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.renderers" as="renderer.list"/>
|
||||
<block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="Magento_Sales::order/totals.phtml">
|
||||
<arguments>
|
||||
<argument name="label_properties" xsi:type="string">colspan="2"</argument>
|
||||
</arguments>
|
||||
<block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="Magento_Tax::order/tax.phtml">
|
||||
<action method="setIsPlaneMode">
|
||||
<argument name="value" xsi:type="string">1</argument>
|
||||
</action>
|
||||
</block>
|
||||
</block>
|
||||
</block>
|
||||
<block class="Magento\Framework\View\Element\Template" name="additional.product.info" template="Magento_Theme::template.phtml"/>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Order Items List" design_abstraction="custom">
|
||||
<update handle="sales_email_order_renderers"/>
|
||||
<update handle="sales_email_item_price"/>
|
||||
<body>
|
||||
<block class="Stemcell\Sales\Block\Order\Email\Salesperson\Items" name="items" template="Magento_Sales::email/salesperson/items.phtml" cacheable="false">
|
||||
<block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.renderers" as="renderer.list"/>
|
||||
<block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="Magento_Sales::order/totals.phtml">
|
||||
<arguments>
|
||||
<argument name="label_properties" xsi:type="string">colspan="2"</argument>
|
||||
</arguments>
|
||||
<block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="Magento_Tax::order/tax.phtml">
|
||||
<action method="setIsPlaneMode">
|
||||
<argument name="value" xsi:type="string">1</argument>
|
||||
</action>
|
||||
</block>
|
||||
</block>
|
||||
</block>
|
||||
<block class="Magento\Framework\View\Element\Template" name="additional.product.info" template="Magento_Theme::template.phtml"/>
|
||||
</body>
|
||||
</page>
|
||||
Reference in New Issue
Block a user