ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Cron Schedule List for Magento 2 (System)
*/
namespace Amasty\CronScheduleList\Model;
use Magento\Framework\Stdlib\DateTime as DateTimeFormat;
use Magento\Framework\Stdlib\DateTime\DateTime;
class DateTimeBuilder
{
/**
* @var DateTime
*/
private $dateTime;
/**
* @var DateTimeFormat
*/
private $dateTimeFormat;
public function __construct(
DateTime $dateTime,
DateTimeFormat $dateTimeFormat
) {
$this->dateTime = $dateTime;
$this->dateTimeFormat = $dateTimeFormat;
}
public function formatDate($datetime)
{
$now = new \DateTime();
$ago = new \DateTime($datetime);
$diff = $now->diff($ago);
$string = [
'h' => 'hour',
'i' => 'minute',
's' => 'second',
];
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
$hours = isset($string['h']) ? $string['h'] : '';
$minutes = isset($string['i']) ? $string['i'] : '';
$seconds = isset($string['s']) && !isset($string['h']) ? $string['s'] : '';
return __('%1 ago', $hours . ' ' . $minutes . ' ' . $seconds);
}
}
@@ -0,0 +1,57 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Cron Schedule List for Magento 2 (System)
*/
namespace Amasty\CronScheduleList\Model\OptionSource;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Framework\Escaper;
use Magento\Cron\Model\Schedule;
class Status implements OptionSourceInterface
{
/**
* @var Escaper
*/
private $escaper;
public function __construct(
Escaper $escaper
) {
$this->escaper = $escaper;
}
public function toOptionArray()
{
return [
[
'value' => Schedule::STATUS_SUCCESS, 'label' => '<span class="grid-severity-notice">'
. $this->escaper->escapeHtml(__("Success"))
. '</span>'
],
[
'value' => Schedule::STATUS_PENDING, 'label' => '<span class="grid-severity-minor">'
. $this->escaper->escapeHtml(__("Pending"))
. '</span>'
],
[
'value' => Schedule::STATUS_RUNNING, 'label' => '<span class="grid-severity-minor">'
. $this->escaper->escapeHtml(__("Running"))
. '</span>'
],
[
'value' => Schedule::STATUS_ERROR, 'label' => '<span class="grid-severity-critical">'
. $this->escaper->escapeHtml(__("Error"))
. '</span>'
],
[
'value' => Schedule::STATUS_MISSED, 'label' => '<span class="grid-severity-critical">'
. $this->escaper->escapeHtml(__("Missed"))
. '</span>'
]
];
}
}
@@ -0,0 +1,27 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Cron Schedule List for Magento 2 (System)
*/
namespace Amasty\CronScheduleList\Model\OptionSource;
use Magento\Framework\Option\ArrayInterface;
use Magento\Cron\Model\Schedule;
class StatusFilter implements ArrayInterface
{
public function toOptionArray()
{
$statuses = [
['value' => Schedule::STATUS_SUCCESS, 'label' => __('Success')],
['value' => Schedule::STATUS_PENDING, 'label' => __('Pending')],
['value' => Schedule::STATUS_RUNNING, 'label' => __('Running')],
['value' => Schedule::STATUS_ERROR, 'label' => __('Error')],
['value' => Schedule::STATUS_MISSED, 'label' => __('Missed')]
];
return $statuses;
}
}
@@ -0,0 +1,47 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Cron Schedule List for Magento 2 (System)
*/
namespace Amasty\CronScheduleList\Model;
use Magento\Cron\Model\Schedule;
class ScheduleCollection extends \Magento\Cron\Model\ResourceModel\Schedule\Collection
{
public function getLastActivity()
{
$this->addFieldToFilter('job_code', 'amasty_cron_activity')
->getSelect()->where('finished_at IS NOT NULL')->order('finished_at');
return $this->getLastItem();
}
public function removeActivitySchedule()
{
$this->getSelect()->where('job_code != "amasty_cron_activity"');
return $this;
}
public function getFailedScheduleByJobCode($jobCode)
{
return $this->addFieldToFilter('job_code', $jobCode)
->addFieldToFilter('status', Schedule::STATUS_ERROR)
->getLastItem();
}
public function getLastFailedJobs()
{
$lastFailedJobs = [];
$items = $this->addFieldToFilter('status', Schedule::STATUS_ERROR)->getItems();
foreach ($items as $item) {
$lastFailedJobs[$item->getJobCode()] = $item;
}
return $lastFailedJobs;
}
}