From 4683cf51dbe49227d5f5ba70d398eb245dc4ec65 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Thu, 17 Feb 2022 09:49:55 +1000 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=83=D0=BB=D1=8C=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=82=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mirzaev/skillparts/system/models/Account.php | 1 + .../skillparts/system/models/AccountForm.php | 3 ++ mirzaev/skillparts/system/models/Edge.php | 2 +- mirzaev/skillparts/system/models/Product.php | 2 +- mirzaev/skillparts/system/models/Search.php | 19 ++++--- mirzaev/skillparts/system/models/Supply.php | 20 ++++---- .../system/views/profile/supplies.php | 49 +++++++++---------- 7 files changed, 52 insertions(+), 44 deletions(-) diff --git a/mirzaev/skillparts/system/models/Account.php b/mirzaev/skillparts/system/models/Account.php index 3451df7..7c3ee36 100644 --- a/mirzaev/skillparts/system/models/Account.php +++ b/mirzaev/skillparts/system/models/Account.php @@ -202,6 +202,7 @@ class Account extends Document implements IdentityInterface, PartnerInterface { if (parent::beforeSave($data)) { if ($this->isNewRecord) { + $this->mail = mb_strtolower($this->mail); $this->auth = yii::$app->security->generateRandomString(); $this->vrfy = yii::$app->security->generateRandomString(); } diff --git a/mirzaev/skillparts/system/models/AccountForm.php b/mirzaev/skillparts/system/models/AccountForm.php index 9ca10dd..c8e84c4 100644 --- a/mirzaev/skillparts/system/models/AccountForm.php +++ b/mirzaev/skillparts/system/models/AccountForm.php @@ -162,6 +162,9 @@ class AccountForm extends Model $this->pswd = $pswd; } + // Регистронезависимая почта + $this->mail = mb_strtolower($this->mail); + if (isset($this->mail, $this->pswd) && $this->validate()) { // Проверка пройдена diff --git a/mirzaev/skillparts/system/models/Edge.php b/mirzaev/skillparts/system/models/Edge.php index 7e849d8..8bc59d7 100644 --- a/mirzaev/skillparts/system/models/Edge.php +++ b/mirzaev/skillparts/system/models/Edge.php @@ -95,7 +95,7 @@ abstract class Edge extends Document if ($edge = self::searchByVertex($_from, $_to, limit: 1)) { // Найдено в базе данных - return $edge; + return $edge[0]; } return self::write($_from, $_to, $type, $data); diff --git a/mirzaev/skillparts/system/models/Product.php b/mirzaev/skillparts/system/models/Product.php index 32d5c33..5718156 100644 --- a/mirzaev/skillparts/system/models/Product.php +++ b/mirzaev/skillparts/system/models/Product.php @@ -405,7 +405,7 @@ class Product extends Document * * @param string|null $_id Идентификатор поставки * - * @return self|null Привязанный продукт + * @return array|null Товар (Product) */ public static function searchBySupplyId(string $_id): ?array { diff --git a/mirzaev/skillparts/system/models/Search.php b/mirzaev/skillparts/system/models/Search.php index 9774e77..585c5d6 100644 --- a/mirzaev/skillparts/system/models/Search.php +++ b/mirzaev/skillparts/system/models/Search.php @@ -176,10 +176,11 @@ class Search extends Document foreach ($connections as $key => &$connection) { // Перебор поставок - if (($cost = $cost['ЦенаЗаЕдиницу'] ?? $connection['supply_edge_product'][0]['onec']['Цены']['Цена']['ЦенаЗаЕдиницу']) < 1 - || ($amount = $connection['supply']['amnt'] ?? $connection['supply_edge_product'][0]['onec']['Количество']) < 1 - ) { - // Цена меньше единицы (подразумевается как ошибка) или количество меньше единицы + // if (($cost = $connection['cost'] ?? $cost['ЦенаЗаЕдиницу'] ?? $connection['supply_edge_product'][0]['onec']['Цены']['Цена']['ЦенаЗаЕдиницу']) < 1 + // || ($amount = $connection['supply']['amnt'] ?? $connection['supply_edge_product'][0]['onec']['Количество']) < 1 + // ) { + if ($cost = $connection['supply']['cost'] < 1) { + // Цена меньше единицы (подразумевается как ошибка) // Скрыть из выдачи unset($connections[$key]); @@ -425,11 +426,15 @@ class Search extends Document } // Инициализация цены - $price_raw = $cost; - $price = $price_raw . ' ' . $supply_edge_product[0]['onec']['Цены']['Цена']['Валюта'] ?? 'руб'; + $price_raw = $supply['cost']; + // $price = $price_raw . ' ' . $supply_edge_product[0]['onec']['Цены']['Цена']['Валюта'] ?? 'руб'; + $price = $price_raw . ' руб'; // Инициализация количества - $amount_raw = $amount = $supply['amnt'] ?? $supply_edge_product[0]['onec']['Количество']; + // $amount_raw = $amount = $supply['amnt'] ?? $supply_edge_product[0]['onec']['Количество'] ?? 0; + + $amount_raw = $amount = count(@SupplyEdgeProduct::searchByVertex(@Supply::collectionName() . '/' . $supply['_key'], @Product::searchByCatn($supply['catn'])->readId(), limit: 999)) ?? 1; + if (empty($amount_raw) || $amount_raw < 1) { // Уже не используется $amount = 'Под заказ'; diff --git a/mirzaev/skillparts/system/models/Supply.php b/mirzaev/skillparts/system/models/Supply.php index 427fa9d..ede21d4 100644 --- a/mirzaev/skillparts/system/models/Supply.php +++ b/mirzaev/skillparts/system/models/Supply.php @@ -496,14 +496,14 @@ class Supply extends Product implements ProductInterface, OfferInterface // Перебор создаваемых рёбер (так работает обозначение количества товаров в наличии) // Поиск ребёр - $edges = SupplyEdgeProduct::searchByVertex($supply->readId(), $product->readId(), limit: 50); + $edges = SupplyEdgeProduct::searchByVertex($supply->readId(), $product->readId(), limit: 999); - if ($amount === $edges) { + if ($amount === count($edges)) { // Количество товаров в поставке не изменилось // Раз изменений нет, то обновлять ничего не нужно continue; - } else if ($amount < $edges) { + } else if ($amount < count($edges)) { // Количество товаров в поставке стало МЕНЬШЕ // Расчёт разницы @@ -614,16 +614,16 @@ class Supply extends Product implements ProductInterface, OfferInterface } } - if (isset($product->prod) && $product->prod === $supply->prod) { - // Производитель совпадает с тем, что указан в товаре + // if (isset($product->prod) && $product->prod === $supply->prod) { + // // Производитель совпадает с тем, что указан в товаре - for ($i = 0; $i++ < $amount;) { - // Перебор создаваемых рёбер (так работает обозначение количества товаров в наличии) + for ($i = 0; $i++ < $amount;) { + // Перебор создаваемых рёбер (так работает обозначение количества товаров в наличии) - // Запись ребра (с проверкой на дубликат) - SupplyEdgeProduct::writeSafe($supply->readId(), $product->readId(), data: ['type' => 'connect']); - } + // Запись ребра + SupplyEdgeProduct::write($supply->readId(), $product->readId(), data: ['type' => 'connect']); } + // } } else { // Проверка не пройдена diff --git a/mirzaev/skillparts/system/views/profile/supplies.php b/mirzaev/skillparts/system/views/profile/supplies.php index 17e1676..5e4027b 100644 --- a/mirzaev/skillparts/system/views/profile/supplies.php +++ b/mirzaev/skillparts/system/views/profile/supplies.php @@ -137,34 +137,33 @@ $panel ?? $panel = 'profile_panel_supplies_input_import'; ?>
-
- name ?? 'Без названия' ?> - - -
+

+ name ?? 'Без названия' ?> + 'form_warehouse_settings', + 'action' => false, + 'fieldConfig' => [ + 'template' => '{label}{input}', + ], + 'options' => [ + 'onsubmit' => 'return false;', + 'class' => 'ml-auto' + ] + ]); - 'form_warehouse_settings', - 'action' => false, - 'fieldConfig' => [ - 'template' => '{label}{input}', - ], - 'options' => [ - 'onsubmit' => 'return false;' - ] - ]); + $list = array_unique($warehouse->genListTerminalsFrom()); + ?> - $list = $warehouse->genListTerminalsFrom(); - ?> - - field($warehouse, 'trmn', ['options' => ['class' => "mb-3"]]) - ->dropDownList($list, [ - 'onChange' => 'page_supplies_settings(this.parentElement.parentElement, ' . $warehouse->_key . ', \'profile_panel_supplies\')', - 'disabled' => count($list) <= 1 - ])->label(false); ?> - - + field($warehouse, 'trmn', ['options' => ['class' => ""]]) + ->dropDownList($list, [ + 'onChange' => 'page_supplies_settings(this.parentElement.parentElement, ' . $warehouse->_key . ', \'profile_panel_supplies\')', + 'disabled' => count($list) <= 1 + ])->label(false); ?> + + + +