diff --git a/composer.lock b/composer.lock
index 15bf67d..65cdb7b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -11,7 +11,7 @@
"version": "v3.4.1",
"source": {
"type": "git",
- "url": "git@github.com:twbs/bootstrap.git",
+ "url": "https://github.com/twbs/bootstrap.git",
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
},
"dist": {
@@ -32,7 +32,7 @@
"version": "3.3.11",
"source": {
"type": "git",
- "url": "git@github.com:RobinHerbots/Inputmask.git",
+ "url": "https://github.com/RobinHerbots/Inputmask.git",
"reference": "5e670ad62f50c738388d4dcec78d2888505ad77b"
},
"dist": {
@@ -53,7 +53,7 @@
"version": "3.5.1",
"source": {
"type": "git",
- "url": "https://github.com/jquery/jquery-dist.git",
+ "url": "git@github.com:jquery/jquery-dist.git",
"reference": "4c0e4becb8263bb5b3e6dadc448d8e7305ef8215"
},
"dist": {
@@ -876,10 +876,10 @@
},
{
"name": "npm-asset/jquery",
- "version": "3.5.1",
+ "version": "3.6.0",
"dist": {
"type": "tar",
- "url": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz"
+ "url": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz"
},
"type": "npm-asset",
"license": [
@@ -888,16 +888,16 @@
},
{
"name": "phpoffice/phpspreadsheet",
- "version": "1.16.0",
+ "version": "1.17.1",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
- "reference": "76d4323b85129d0c368149c831a07a3e258b2b50"
+ "reference": "c55269cb06911575a126dc225a05c0e4626e5fb4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/76d4323b85129d0c368149c831a07a3e258b2b50",
- "reference": "76d4323b85129d0c368149c831a07a3e258b2b50",
+ "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c55269cb06911575a126dc225a05c0e4626e5fb4",
+ "reference": "c55269cb06911575a126dc225a05c0e4626e5fb4",
"shasum": ""
},
"require": {
@@ -925,7 +925,7 @@
},
"require-dev": {
"dompdf/dompdf": "^0.8.5",
- "friendsofphp/php-cs-fixer": "^2.16",
+ "friendsofphp/php-cs-fixer": "^2.18",
"jpgraph/jpgraph": "^4.0",
"mpdf/mpdf": "^8.0",
"phpcompatibility/php-compatibility": "^9.3",
@@ -983,9 +983,9 @@
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
- "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.16.0"
+ "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.17.1"
},
- "time": "2020-12-31T18:03:49+00:00"
+ "time": "2021-03-02T17:54:11+00:00"
},
{
"name": "psr/http-client",
@@ -1200,16 +1200,16 @@
},
{
"name": "swiftmailer/swiftmailer",
- "version": "v6.2.5",
+ "version": "v6.2.6",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
- "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7"
+ "reference": "d2791ff0b73247cdc2096b14f5580aba40c12bff"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/698a6a9f54d7eb321274de3ad19863802c879fb7",
- "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7",
+ "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/d2791ff0b73247cdc2096b14f5580aba40c12bff",
+ "reference": "d2791ff0b73247cdc2096b14f5580aba40c12bff",
"shasum": ""
},
"require": {
@@ -1259,7 +1259,7 @@
],
"support": {
"issues": "https://github.com/swiftmailer/swiftmailer/issues",
- "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.5"
+ "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.6"
},
"funding": [
{
@@ -1271,7 +1271,7 @@
"type": "tidelift"
}
],
- "time": "2021-01-12T09:35:59+00:00"
+ "time": "2021-03-05T12:08:49+00:00"
},
{
"name": "symfony/polyfill-iconv",
@@ -1804,16 +1804,16 @@
},
{
"name": "yiisoft/yii2",
- "version": "2.0.40",
+ "version": "2.0.41.1",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-framework.git",
- "reference": "debb520c1d72a2c97c09d70a2a2a4f600ef3958e"
+ "reference": "2ad0894a2ccbd3912b33de4419ad1ae3df0595c4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/debb520c1d72a2c97c09d70a2a2a4f600ef3958e",
- "reference": "debb520c1d72a2c97c09d70a2a2a4f600ef3958e",
+ "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/2ad0894a2ccbd3912b33de4419ad1ae3df0595c4",
+ "reference": "2ad0894a2ccbd3912b33de4419ad1ae3df0595c4",
"shasum": ""
},
"require": {
@@ -1921,7 +1921,7 @@
"type": "tidelift"
}
],
- "time": "2020-12-23T15:44:43+00:00"
+ "time": "2021-03-04T15:45:04+00:00"
},
{
"name": "yiisoft/yii2-bootstrap",
@@ -2343,16 +2343,16 @@
},
{
"name": "codeception/lib-innerbrowser",
- "version": "1.4.0",
+ "version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/Codeception/lib-innerbrowser.git",
- "reference": "b7406c710684c255d9b067d7795269a5585a0406"
+ "reference": "693e116f81ef98eae98c43ef785a726faf87394e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/b7406c710684c255d9b067d7795269a5585a0406",
- "reference": "b7406c710684c255d9b067d7795269a5585a0406",
+ "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/693e116f81ef98eae98c43ef785a726faf87394e",
+ "reference": "693e116f81ef98eae98c43ef785a726faf87394e",
"shasum": ""
},
"require": {
@@ -2397,9 +2397,9 @@
],
"support": {
"issues": "https://github.com/Codeception/lib-innerbrowser/issues",
- "source": "https://github.com/Codeception/lib-innerbrowser/tree/1.4.0"
+ "source": "https://github.com/Codeception/lib-innerbrowser/tree/1.4.1"
},
- "time": "2021-01-29T18:17:25+00:00"
+ "time": "2021-03-02T08:01:54+00:00"
},
{
"name": "codeception/module-asserts",
@@ -3284,16 +3284,16 @@
},
{
"name": "php-webdriver/webdriver",
- "version": "1.9.0",
+ "version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/php-webdriver/php-webdriver.git",
- "reference": "e3633154554605274cc9d59837f55a7427d72003"
+ "reference": "cd9290b95b7651d495bd69253d6e3ef469a7f211"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/e3633154554605274cc9d59837f55a7427d72003",
- "reference": "e3633154554605274cc9d59837f55a7427d72003",
+ "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/cd9290b95b7651d495bd69253d6e3ef469a7f211",
+ "reference": "cd9290b95b7651d495bd69253d6e3ef469a7f211",
"shasum": ""
},
"require": {
@@ -3309,7 +3309,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
- "ondram/ci-detector": "^2.1 || ^3.5",
+ "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0",
"php-coveralls/php-coveralls": "^2.4",
"php-mock/php-mock-phpunit": "^1.1 || ^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
@@ -3349,9 +3349,9 @@
],
"support": {
"issues": "https://github.com/php-webdriver/php-webdriver/issues",
- "source": "https://github.com/php-webdriver/php-webdriver/tree/1.9.0"
+ "source": "https://github.com/php-webdriver/php-webdriver/tree/1.10.0"
},
- "time": "2020-11-19T15:21:05+00:00"
+ "time": "2021-02-25T13:38:09+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@@ -4042,27 +4042,22 @@
},
{
"name": "psr/container",
- "version": "1.0.0",
+ "version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": ""
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=7.2.0"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@@ -4075,7 +4070,7 @@
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
@@ -4089,9 +4084,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/master"
+ "source": "https://github.com/php-fig/container/tree/1.1.1"
},
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2021-03-05T17:36:06+00:00"
},
{
"name": "psr/event-dispatcher",
@@ -5153,16 +5148,16 @@
},
{
"name": "symfony/browser-kit",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
- "reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd"
+ "reference": "3ca3a57ce9860318b20a924fec5daf5c6db44d93"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/browser-kit/zipball/b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
- "reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
+ "url": "https://api.github.com/repos/symfony/browser-kit/zipball/3ca3a57ce9860318b20a924fec5daf5c6db44d93",
+ "reference": "3ca3a57ce9860318b20a924fec5daf5c6db44d93",
"shasum": ""
},
"require": {
@@ -5204,7 +5199,7 @@
"description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/browser-kit/tree/v5.2.3"
+ "source": "https://github.com/symfony/browser-kit/tree/v5.2.4"
},
"funding": [
{
@@ -5220,20 +5215,20 @@
"type": "tidelift"
}
],
- "time": "2021-01-27T12:56:27+00:00"
+ "time": "2021-02-22T06:48:33+00:00"
},
{
"name": "symfony/console",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a"
+ "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a",
- "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a",
+ "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
+ "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"shasum": ""
},
"require": {
@@ -5301,7 +5296,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.2.3"
+ "source": "https://github.com/symfony/console/tree/v5.2.4"
},
"funding": [
{
@@ -5317,11 +5312,11 @@
"type": "tidelift"
}
],
- "time": "2021-01-28T22:06:19+00:00"
+ "time": "2021-02-23T10:08:49+00:00"
},
{
"name": "symfony/css-selector",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@@ -5366,7 +5361,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/css-selector/tree/v5.2.3"
+ "source": "https://github.com/symfony/css-selector/tree/v5.2.4"
},
"funding": [
{
@@ -5453,16 +5448,16 @@
},
{
"name": "symfony/dom-crawler",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
- "reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384"
+ "reference": "400e265163f65aceee7e904ef532e15228de674b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5d89ceb53ec65e1973a555072fac8ed5ecad3384",
- "reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384",
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/400e265163f65aceee7e904ef532e15228de674b",
+ "reference": "400e265163f65aceee7e904ef532e15228de674b",
"shasum": ""
},
"require": {
@@ -5507,7 +5502,7 @@
"description": "Eases DOM navigation for HTML and XML documents",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/dom-crawler/tree/v5.2.3"
+ "source": "https://github.com/symfony/dom-crawler/tree/v5.2.4"
},
"funding": [
{
@@ -5523,20 +5518,20 @@
"type": "tidelift"
}
],
- "time": "2021-01-27T10:01:46+00:00"
+ "time": "2021-02-15T18:55:04+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367"
+ "reference": "d08d6ec121a425897951900ab692b612a61d6240"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4f9760f8074978ad82e2ce854dff79a71fe45367",
- "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d08d6ec121a425897951900ab692b612a61d6240",
+ "reference": "d08d6ec121a425897951900ab692b612a61d6240",
"shasum": ""
},
"require": {
@@ -5592,7 +5587,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.3"
+ "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.4"
},
"funding": [
{
@@ -5608,7 +5603,7 @@
"type": "tidelift"
}
],
- "time": "2021-01-27T10:36:42+00:00"
+ "time": "2021-02-18T17:12:37+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@@ -5691,16 +5686,16 @@
},
{
"name": "symfony/finder",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "4adc8d172d602008c204c2e16956f99257248e03"
+ "reference": "0d639a0943822626290d169965804f79400e6a04"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03",
- "reference": "4adc8d172d602008c204c2e16956f99257248e03",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04",
+ "reference": "0d639a0943822626290d169965804f79400e6a04",
"shasum": ""
},
"require": {
@@ -5732,7 +5727,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/finder/tree/v5.2.3"
+ "source": "https://github.com/symfony/finder/tree/v5.2.4"
},
"funding": [
{
@@ -5748,7 +5743,7 @@
"type": "tidelift"
}
],
- "time": "2021-01-28T22:06:19+00:00"
+ "time": "2021-02-15T18:55:04+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -6074,7 +6069,7 @@
},
{
"name": "symfony/process",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
@@ -6116,7 +6111,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/process/tree/v5.2.3"
+ "source": "https://github.com/symfony/process/tree/v5.2.4"
},
"funding": [
{
@@ -6215,16 +6210,16 @@
},
{
"name": "symfony/string",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "c95468897f408dd0aca2ff582074423dd0455122"
+ "reference": "4e78d7d47061fa183639927ec40d607973699609"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122",
- "reference": "c95468897f408dd0aca2ff582074423dd0455122",
+ "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609",
+ "reference": "4e78d7d47061fa183639927ec40d607973699609",
"shasum": ""
},
"require": {
@@ -6278,7 +6273,7 @@
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v5.2.3"
+ "source": "https://github.com/symfony/string/tree/v5.2.4"
},
"funding": [
{
@@ -6294,20 +6289,20 @@
"type": "tidelift"
}
],
- "time": "2021-01-25T15:14:59+00:00"
+ "time": "2021-02-16T10:20:28+00:00"
},
{
"name": "symfony/yaml",
- "version": "v5.2.3",
+ "version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
- "reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0"
+ "reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/338cddc6d74929f6adf19ca5682ac4b8e109cdb0",
- "reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/7d6ae0cce3c33965af681a4355f1c4de326ed277",
+ "reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277",
"shasum": ""
},
"require": {
@@ -6353,7 +6348,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/yaml/tree/v5.2.3"
+ "source": "https://github.com/symfony/yaml/tree/v5.2.4"
},
"funding": [
{
@@ -6369,7 +6364,7 @@
"type": "tidelift"
}
],
- "time": "2021-02-03T04:42:09+00:00"
+ "time": "2021-02-22T15:48:39+00:00"
},
{
"name": "theseer/tokenizer",
diff --git a/mirzaev/skillparts/system/controllers/CartController.php b/mirzaev/skillparts/system/controllers/CartController.php
index ed7de6e..9e86b7e 100644
--- a/mirzaev/skillparts/system/controllers/CartController.php
+++ b/mirzaev/skillparts/system/controllers/CartController.php
@@ -4,14 +4,12 @@ declare(strict_types=1);
namespace app\controllers;
-use app\models\AccountEdgeNotification;
use yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use app\models\Order;
-use app\models\AccountEdgeOrder;
use Exception;
@@ -40,72 +38,40 @@ class CartController extends Controller
*/
public function actionIndex(): string|array|null
{
- // Инициализация настроек страницы
- $page = yii::$app->request->get('page') ?? 1;
+ // Инициализация
+ $page = yii::$app->request->get('page') ?? yii::$app->request->post('page') ?? 1;
+ $account = yii::$app->user;
- // Инициализация корзина
+ // Поиск корзины (текущего заказа)
$model = Order::search();
+ if (empty($model)) {
+ // Корзина не инициализирована
+
+ // Инициализация
+ $model = new Order();
+ $model->save() or throw new Exception('Не удалось инициализировать заказ');
+
+ // Подключение
+ $model->connect($account);
+ }
+
// Инициализация содержимого корзины
$supplies = $model->content(10, $page);
- // Инициализация реестра дубликатов
- $registry = [];
-
- // Подсчёт и перестройка массива
- foreach ($supplies as $key => &$supply) {
- // Перебор поставок
-
- if (in_array($supply->catn, $registry)) {
- // Если данная поставка найдена в реестре
-
- // Удаление
- unset($supplies[$key]);
-
- // Пропуск итерации
- continue;
- }
-
- $amount = 0;
-
- // Повторный перебор для поиска дубликатов
- foreach ($supplies as &$supply4check) {
- if ($supply == $supply4check) {
- // Найден дубликат
-
- // Постинкрементация счётчика
- $amount++;
-
- // Запись в реестр
- $registry []= $supply4check->catn;
- }
- }
-
- // Запись количества
- $supply->amnt = $amount;
- }
-
- // Инициализация возврата по умолчанию
- $return = [
- '_csrf' => yii::$app->request->getCsrfToken()
- ];
-
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
- $return = array_merge($return, [
+ return [
'main' => $this->renderPartial('index', compact('model', 'supplies')),
'title' => 'Корзина',
- 'redirect' => '/cart'
- ]);
- } else {
- // GET-запрос (подразумевается)
-
- return $this->render('index', compact('model', 'supplies'));
+ 'redirect' => '/cart',
+ '_csrf' => yii::$app->request->getCsrfToken()
+ ];
}
- return $return;
+ return $this->render('index', compact('model', 'supplies'));
}
}
diff --git a/mirzaev/skillparts/system/controllers/NotificationController.php b/mirzaev/skillparts/system/controllers/NotificationController.php
index 9ecbf98..f12e68f 100644
--- a/mirzaev/skillparts/system/controllers/NotificationController.php
+++ b/mirzaev/skillparts/system/controllers/NotificationController.php
@@ -81,7 +81,7 @@ class NotificationController extends Controller
$type = 'checked';
}
- // Генерация подзапроса по перебору ядра
+ // Генерация
$let = $let->createCommand();
/**
@@ -134,7 +134,7 @@ class NotificationController extends Controller
if (empty($notifications)) {
// Уведомления не найдены
- yii::$app->response->statusCode = 100;
+ yii::$app->response->statusCode = 404;
goto end;
}
diff --git a/mirzaev/skillparts/system/controllers/OrderController.php b/mirzaev/skillparts/system/controllers/OrderController.php
index 86d6ec1..5ef5fdc 100644
--- a/mirzaev/skillparts/system/controllers/OrderController.php
+++ b/mirzaev/skillparts/system/controllers/OrderController.php
@@ -10,9 +10,10 @@ use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
+use app\models\Supply;
use app\models\Order;
use app\models\AccountEdgeOrder;
-
+use app\models\OrderEdgeSupply;
use Exception;
class OrderController extends Controller
@@ -35,10 +36,30 @@ class OrderController extends Controller
public function actionIndex()
{
+ // Инициализация
+ $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}');
+ if (yii::$app->request->isPost) {
+ // POST-запрос
+
+ yii::$app->response->format = Response::FORMAT_JSON;
+
+ return [
+ 'main' => $this->renderPartial('/orders/index', compact('orders')),
+ 'title' => 'Заказы',
+ 'redirect' => '/orders',
+ '_csrf' => yii::$app->request->getCsrfToken()
+ ];
+ }
+
+ return $this->render('/orders/index', compact('orders'));
}
- public function actionWrite(): string|array|null {
+ /**
+ * Запись
+ */
+ public function actionWrite(): string|array|null
+ {
if (yii::$app->request->isPost) {
// POST-запрос
@@ -68,7 +89,7 @@ class OrderController extends Controller
$model = new Order();
$model->save() or throw new Exception('Не удалось инициализировать заказ');
- // Запись в аккаунт
+ // Запись ребра: АККАУНТ -> ЗАКАЗ
AccountEdgeOrder::write($account->id, $model->readId(), 'current') or $model->addError('errors', 'Не удалось инициализировать ребро: АККАУНТ -> ЗАКАЗ');
}
@@ -91,4 +112,96 @@ class OrderController extends Controller
return null;
}
+
+ /**
+ * Удаление
+ */
+ public function actionDelete(): string|array|null
+ {
+ // Инициализация
+ $targets = yii::$app->request->post('targets') ?? yii::$app->request->get('targets');
+ $page = yii::$app->request->get('page') ?? yii::$app->request->post('page') ?? 1;
+ $account = yii::$app->user;
+
+ if ($targets) {
+ // Удаление выбранных целей (удаление из заказа)
+
+ foreach ($targets as $target) {
+
+ // Инициализация
+ $model = Order::search();
+
+ // Удаление
+ $model->deleteEdge($target);
+ }
+ } else {
+ // Целью подразумевается сам заказ (удаление заказа)
+
+ // Инициализация корзины (текущего заказа)
+ $model = Order::search();
+
+ // Поиск
+ $edge = AccountEdgeOrder::searchByVertex($account->id, $model->readId(), 'current');
+
+ // Запись
+ $edge->type = 'reserved';
+
+ // Отправка
+ $edge->update();
+ }
+
+ // Инициализация содержимого корзины
+ $supplies = $model->content(10, $page);
+
+ if (yii::$app->request->isPost) {
+ // POST-запрос
+
+ yii::$app->response->format = Response::FORMAT_JSON;
+
+ return [
+ 'main' => $this->renderPartial('/cart/index', compact('model', 'supplies')),
+ 'title' => 'Корзина',
+ 'redirect' => '/cart',
+ '_csrf' => yii::$app->request->getCsrfToken()
+ ];
+ }
+
+ return $this->render('/cart/index', compact('model', 'supplies'));
+ }
+
+ /**
+ * Оплата
+ */
+ public function actionPay(): string|array|null
+ {
+ // Инициализация
+ $model = Order::search();
+
+ // Поиск ребра
+ $edge = AccountEdgeOrder::searchByVertex(yii::$app->user->id, $model->readId(), 'current');
+
+ // Запись
+ $edge->type = 'accepted';
+
+ // Отправка изменений
+ $edge->update();
+
+ // Инициализация
+ $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}');
+
+ if (yii::$app->request->isPost) {
+ // POST-запрос
+
+ yii::$app->response->format = Response::FORMAT_JSON;
+
+ return [
+ 'main' => $this->renderPartial('/orders/index', compact('orders')),
+ 'title' => 'Заказы',
+ 'redirect' => '/orders',
+ '_csrf' => yii::$app->request->getCsrfToken()
+ ];
+ }
+
+ return $this->render('/orders/index', compact('orders'));
+ }
}
diff --git a/mirzaev/skillparts/system/controllers/ProfileController.php b/mirzaev/skillparts/system/controllers/ProfileController.php
index fc468cb..5760303 100644
--- a/mirzaev/skillparts/system/controllers/ProfileController.php
+++ b/mirzaev/skillparts/system/controllers/ProfileController.php
@@ -265,7 +265,19 @@ class ProfileController extends Controller
// Генерация
$sidebar = $this->renderPartial('sidebar');
- $search_history = Search::searchByAccount(yii::$app->user->id, $rows_amount, ((int) $page_search_history ?? 0) * $rows_amount);
+ $search_history = Search::SearchByEdge(
+ from: 'account',
+ to: 'search',
+ subquery_where: [
+ [
+ 'account._id' => yii::$app->user->id
+ ]
+ ],
+ foreach: ['edge' => 'account_edge_search'],
+ where: 'edge._to == search._id',
+ limit: $rows_amount,
+ offset: ((int) $page_search_history ?? 0) * $rows_amount
+ );
if (yii::$app->request->isPost) {
// AJAX-POST-запрос
diff --git a/mirzaev/skillparts/system/controllers/SearchController.php b/mirzaev/skillparts/system/controllers/SearchController.php
index 142ae43..d89e4ff 100644
--- a/mirzaev/skillparts/system/controllers/SearchController.php
+++ b/mirzaev/skillparts/system/controllers/SearchController.php
@@ -60,8 +60,8 @@ class SearchController extends Controller
$timer = 0;
// Период пропуска запросов (в секундах)
- $period = 1;
- $keep_connect = true;
+ $period = 5;
+ $keep_connect = false;
$sanction = false;
$sanction_condition = ($session['last_request'] + $period - time()) < $period;
$sanction_time = 2;
diff --git a/mirzaev/skillparts/system/models/Edge.php b/mirzaev/skillparts/system/models/Edge.php
index ea2e017..eda7fe2 100644
--- a/mirzaev/skillparts/system/models/Edge.php
+++ b/mirzaev/skillparts/system/models/Edge.php
@@ -87,7 +87,7 @@ abstract class Edge extends Document
*/
public static function writeSafe(string $_from, string $_to, string $type = '', array $data = []): ?static
{
- if ($edge = self::searchByVertex($_from, $_to, 1)) {
+ if ($edge = self::searchByVertex($_from, $_to, limit: 1)) {
// Найдено в базе данных
return $edge;
@@ -128,11 +128,29 @@ abstract class Edge extends Document
/**
* Поиск ребра по его вершинам
*/
- public static function searchByVertex(string $_from, string $_to, int $limit = 1): static|array|null
+ public static function searchByVertex(string $_from, string $_to, string $type = '', int $limit = 1): static|array|null
{
- $query = self::find()->where(['_from' => $_from, '_to' => $_to]);
+ $query = self::find()->where(['_from' => $_from, '_to' => $_to, 'type' => $type]);
- if ($limit <= 1) {
+ if ($limit < 2) {
+ return $query->one();
+ } else {
+ return $query->limit($limit)->all();
+ }
+ }
+
+ /**
+ * Поиск рёбер
+ */
+ public static function search(string $target, string $direction = 'OUTBOUND', string $type = '', int $limit = 1): static|array|null
+ {
+ if ($direction === 'OUTBOUND') {
+ $query = self::find()->where(['_from' => $target, 'type' => $type]);
+ } else if ($direction === 'INBOUND') {
+ $query = self::find()->where(['_to' => $target, 'type' => $type]);
+ }
+
+ if ($limit < 2) {
return $query->one();
} else {
return $query->limit($limit)->all();
diff --git a/mirzaev/skillparts/system/models/Order.php b/mirzaev/skillparts/system/models/Order.php
index fff408a..45f166e 100644
--- a/mirzaev/skillparts/system/models/Order.php
+++ b/mirzaev/skillparts/system/models/Order.php
@@ -83,7 +83,7 @@ class Order extends Document
$trgt ?? $trgt = yii::$app->user ?? throw new Exception('Не удалось инициализировать заказчика');
if ($supply instanceof Supply) {
- // Передана инстанция класса поставки
+ // Передана инстанция класса поставки или второй элемент массива не является числом
// Унификация входных данных
$supply = [$supply, 1];
@@ -107,15 +107,15 @@ class Order extends Document
}
}
- foreach ($supply as $supply_raw) {
+ foreach (is_array($supply[0]) ? $supply : [$supply] as $supply_raw) {
// Перебор поставок
for ($i = 0; $i < $supply_raw[1]; $i++) {
// Создание рёбер соразмерно запросу (добавление нескольких продуктов в корзину)
- // Инициализация ребра: ЗАКАЗ -> ПОСТАВКА
- if (!$supply = Supply::searchByCatn($supply_raw[0]) or !OrderEdgeSupply::write($this->readId(), $supply->readId(), 'add')) {
- // Поставка не найдена или инициализация ребра не удалась
+ // Запись ребра: ЗАКАЗ -> ПОСТАВКА
+ if (!$supply = Supply::searchByCatn($supply_raw[0]) or !OrderEdgeSupply::write($this->readId(), $supply->readId(), 'write')) {
+ // Поставка не найдена или запись ребра не удалась
continue;
}
@@ -126,13 +126,44 @@ class Order extends Document
return $this->save() ? $this : null;
}
+ /**
+ * Подключение к аккаунту
+ */
+ public function connect(Account $account): ?AccountEdgeOrder {
+ // Запись ребра: АККАУНТ -> ЗАКАЗ
+ return AccountEdgeOrder::write($account->id, $this->readId(), 'current') ?? throw new Exception('Не удалось инициализировать ребро: АККАУНТ -> ЗАКАЗ');
+ }
+
+ /**
+ * Удаление
+ */
+ public function deleteEdge(string|array $catn): ?OrderEdgeSupply
+ {
+ // Запись ребра: ЗАКАЗ -> ПОСТАВКА
+ return OrderEdgeSupply::write($this->readId(), Supply::searchByCatn($catn)->readId(), 'delete');
+ }
+
/**
* Поиск заказа
*/
- public static function search(Account $account = null, string $type = 'current', int $limit = 1): self|array
+ public static function search(Account $account = null, string $type = 'current', int $limit = 1, int $page = 1, string $select = null): self|array|null
{
+ // Инициализация
$account or $account = yii::$app->user ?? throw new Exception('Не удалось инициализировать пользователя');
+ // Генерация сдвига по запрашиваемым данным (пагинация)
+ $offset = $limit * ($page - 1);
+
+ if (strcasecmp($type, 'all') !== 0) {
+ // Если не указан параметр поиска всех заказов
+
+ $where_type = [
+ 'account_edge_order.type' => $type
+ ];
+ } else {
+ $where_type = [];
+ }
+
$return = self::searchByEdge(
from: 'account',
to: 'order',
@@ -140,16 +171,18 @@ class Order extends Document
[
'account._id' => $account->id
],
- [
- 'account_edge_order.type' => $type
- ]
+ $where_type
],
+ foreach: ['edge' => 'account_edge_order'],
+ where: 'edge._to == order._id',
limit: $limit,
+ offset: $offset,
sort: ['DESC'],
+ select: $select,
direction: 'INBOUND'
);
- return $limit === 1 ? $return[0] : $return;
+ return $limit === 1 ? $return[0] ?? null : $return;
}
/**
@@ -157,13 +190,33 @@ class Order extends Document
*
* @todo В будущем возможно заказ не только поставок реализовать
*/
- public function content(int $limit = 1, int $page = 1): Supply|array
+ public function content(int $limit = 1, int $page = 1): Supply|array|null
{
// Генерация сдвига по запрашиваемым данным (пагинация)
$offset = $limit * ($page - 1);
+
+ // Подзапрос для проверки статуса уведомления относительно пользователя
+ // Поиск рёбер: ПОЛЬЗОВАТЕЛЬ -> УВЕДОМЛЕНИЕ
+ $let = Supply::find()
+ ->for(['order', 'order_edge_supply_deleted'])
+ ->traversal('supply', 'INBOUND')
+ ->in('order_edge_supply')
+ ->where([
+ [
+ 'order._id' => $this->readId()
+ ],
+ [
+ 'order_edge_supply_deleted.type' => 'delete'
+ ]
+ ])
+ ->select('order_edge_supply_deleted');
+
+ // Генерация
+ $let = $let->createCommand();
+
// Поиск рёбер: ЗАКАЗ -> ПОСТАВКА
- $return = Supply::searchByEdge(
+ $supplies = Supply::searchByEdge(
from: 'order',
to: 'supply',
edge: 'order_edge_supply',
@@ -172,15 +225,80 @@ class Order extends Document
'order._id' => $this->readId()
],
[
- 'order_edge_supply.type' => 'add'
+ 'order_edge_supply.type' => 'write'
]
],
+ params: $let->getBindVars(),
+ let: [
+ 'order_edge_supply_deleted',
+ '(' . (string) $let . ')'
+ ],
foreach: ['edge' => 'order_edge_supply'],
- where: 'edge._to == supply._id',
+ where: 'edge._to == supply._id && edge._to != order_edge_supply_deleted[0]._to',
limit: $limit,
- offset: $offset
+ offset: $offset,
+ direction: 'INBOUND'
);
- return $limit === 1 ? $return[0] : $return;
+ // Инициализация реестра дубликатов
+ $registry = [];
+
+ // Подсчёт и перестройка массива для очистки от дубликатов
+ foreach ($supplies as $key => &$supply) {
+ // Перебор поставок
+
+ if (in_array($supply->catn, $registry)) {
+ // Если данная поставка найдена в реестре
+
+ // Удаление
+ unset($supplies[$key]);
+
+ // Пропуск итерации
+ continue;
+ }
+
+ $amount = 0;
+
+ // Повторный перебор для поиска дубликатов
+ foreach ($supplies as &$supply4check) {
+ if ($supply == $supply4check) {
+ // Найден дубликат
+
+ // Постинкрементация счётчика
+ $amount++;
+
+ // Запись в реестр
+ $registry[] = $supply4check->catn;
+ }
+ }
+
+ // Запись количества для заказа
+ $supply->amnt = $amount;
+ }
+
+ // Поиск стоимости для каждой поставки
+ foreach ($supplies as $key => &$supply) {
+ // Перебор поставок
+
+ // Чтение стоимости
+ $cost = $supply->readCost();
+
+ if ($cost < 1) {
+ // Если стоимость равна нулю (явная ошибка)
+
+ $this->deleteEdge($supply->readId());
+
+ // Удаление
+ unset($supplies[$key]);
+
+ // Пропуск итерации
+ continue;
+ }
+
+ // Запись цены
+ $supply->cost = $cost['ЦенаЗаЕдиницу'] . ' ' . $cost['Валюта'];
+ }
+
+ return $supplies;
}
}
diff --git a/mirzaev/skillparts/system/models/Supply.php b/mirzaev/skillparts/system/models/Supply.php
index dd7ba0d..09b9fb0 100644
--- a/mirzaev/skillparts/system/models/Supply.php
+++ b/mirzaev/skillparts/system/models/Supply.php
@@ -432,4 +432,16 @@ class Supply extends Product implements ProductInterface
{
return [];
}
+
+ /**
+ * Прочитать стоимость
+ */
+ public function readCost(Product $product = null): array
+ {
+ if (isset($product)) {
+ return SupplyEdgeProduct::searchByVertex($this->readId(), $product->readId(), type: 'connect', limit: 1)['onec']['Цены']['Цена'];
+ }
+
+ return SupplyEdgeProduct::search($this->readId(), type: 'connect', limit: 1)['onec']['Цены']['Цена'];
+ }
}
diff --git a/mirzaev/skillparts/system/models/traits/SearchByEdge.php b/mirzaev/skillparts/system/models/traits/SearchByEdge.php
index fbd6214..3d39f89 100644
--- a/mirzaev/skillparts/system/models/traits/SearchByEdge.php
+++ b/mirzaev/skillparts/system/models/traits/SearchByEdge.php
@@ -32,9 +32,10 @@ trait SearchByEdge
array $let = [],
string|array $select = null,
callable $handle = null,
- array &$params = []
+ array $params = []
): ?array {
$subquery = static::find()
+ ->params($params)
->for([$from, $edge ?? $from . '_edge_' . $to])
->traversal($to, $direction)
->in($edge ?? $from . '_edge_' . $to)
@@ -44,7 +45,7 @@ trait SearchByEdge
->createCommand();
$query = static::find()
- ->params($params, $subquery->getBindVars())
+ ->params($subquery->getBindVars())
->let($edge ?? $from . '_edge_' . $to, '(' . (string) $subquery . ')')
->limit($limit)
->offset($offset)
diff --git a/mirzaev/skillparts/system/views/account/deauthentication.php b/mirzaev/skillparts/system/views/account/deauthentication.php
index d159314..f11d2fa 100644
--- a/mirzaev/skillparts/system/views/account/deauthentication.php
+++ b/mirzaev/skillparts/system/views/account/deauthentication.php
@@ -8,10 +8,10 @@ if (!yii::$app->user->isGuest) {
$popup = yii::$app->controller->renderPartial('/notification/panel');
echo <<
+
-