From 83295650c974e51a1629fc3100093dae7b086273 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Tue, 29 Jun 2021 09:08:01 +1000 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D1=81=D0=B0=D0=B9=D1=82=D0=BE=D0=BC=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controllers/OrderController.php | 11 +-- .../system/controllers/SearchController.php | 12 ++- mirzaev/skillparts/system/models/Order.php | 74 +++++++++---------- mirzaev/skillparts/system/models/Product.php | 2 +- .../skillparts/system/views/cart/index.php | 2 +- mirzaev/skillparts/system/views/index.php | 26 +++---- .../skillparts/system/views/layouts/main.php | 30 ++------ .../skillparts/system/views/orders/index.php | 9 +-- mirzaev/skillparts/system/web/css/main.css | 5 ++ mirzaev/skillparts/system/web/js/account.js | 2 +- mirzaev/skillparts/system/web/js/cart.js | 4 +- mirzaev/skillparts/system/web/js/main.js | 20 +++++ 12 files changed, 105 insertions(+), 92 deletions(-) create mode 100644 mirzaev/skillparts/system/web/js/main.js diff --git a/mirzaev/skillparts/system/controllers/OrderController.php b/mirzaev/skillparts/system/controllers/OrderController.php index 0b93a1f..010c0a7 100644 --- a/mirzaev/skillparts/system/controllers/OrderController.php +++ b/mirzaev/skillparts/system/controllers/OrderController.php @@ -137,7 +137,7 @@ class OrderController extends Controller Order::searchById($account_edge_order->_to)->journal('accepted'); // Инициализация - $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}'); + $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}', supplies: true); $moderator_orders = self::genOrdersForModeration(); // Запись в буфер вывода @@ -320,6 +320,7 @@ class OrderController extends Controller if ($connection['supply']['catn'] === $catn) { // Цель найдена + if ($connection['amount'] > $amount) { // Запрошено уменьшение количества @@ -329,7 +330,7 @@ class OrderController extends Controller // Запрошено увеличение количества // Запись - $order->writeSupply([$connection['supply']['catn'] => $amount - $connection['amount']]); + $order->writeSupply('supply/' . $connection['supply']['_key'], $connection['order_edge_supply']['dlvr'] ?? 'auto', $amount - $connection['amount']); } } } @@ -384,7 +385,7 @@ class OrderController extends Controller // Инициализация буфера поставок $supplies = []; - foreach($model['supplies'] as $supply) { + foreach ($model['supplies'] as $supply) { $supplies[] = [ 'title' => $supply['supply']['catn'], 'amount' => [ @@ -419,8 +420,8 @@ class OrderController extends Controller } // Инициализация - $orders = Order::search(type: 'all', limit: 30, page: 1, select: '{account_edge_order, order}'); - $moderator_orders = Order::search(account: '@all', type: 'requested', limit: 10, page: 1, select: '{account_edge_order, order}'); + $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}', supplies: true); + $moderator_orders = self::genOrdersForModeration(); if (yii::$app->request->isPost) { // POST-запрос diff --git a/mirzaev/skillparts/system/controllers/SearchController.php b/mirzaev/skillparts/system/controllers/SearchController.php index 09866f9..fddc09f 100644 --- a/mirzaev/skillparts/system/controllers/SearchController.php +++ b/mirzaev/skillparts/system/controllers/SearchController.php @@ -184,18 +184,23 @@ class SearchController extends Controller try { // Инициализация доставки (автоматическая) $connection['delivery'] = Dellin::calcDeliveryAdvanced( - $buffer['account']['opts']['delivery_from_terminal'], + $connection['account']['opts']['delivery_from_terminal'], yii::$app->user->identity->opts['delivery_to_terminal'], (int) ($connection['product']['wght'] ?? 0), (int) ($connection['product']['dmns']['x'] ?? 0), (int) ($connection['product']['dmns']['y'] ?? 0), (int) ($connection['product']['dmns']['z'] ?? 0) ); - $buffer['delivery']['type'] = 'auto'; + $connection['delivery']['type'] = 'auto'; } catch (Exception $e) { $connection['delivery']['error'] = true; - // var_dump(json_decode($e->getMessage(), true)['errors']); die; + // var_dump($e->getMessage()); + // var_dump($e->getTrace()); + // var_dump($e->getFile()); + + // var_dump(json_decode($e->getMessage(), true)['errors']); + // die; } // Инициализация цены (цена поставки + цена доставки + наша наценка) @@ -222,7 +227,6 @@ class SearchController extends Controller // var_dump($e->getMessage()); // var_dump($e->getTrace()); // var_dump($e->getFile()); - // die; // var_dump(json_decode($e->getMessage(), true)['errors']); // die; diff --git a/mirzaev/skillparts/system/models/Order.php b/mirzaev/skillparts/system/models/Order.php index 55d4c29..95184f1 100644 --- a/mirzaev/skillparts/system/models/Order.php +++ b/mirzaev/skillparts/system/models/Order.php @@ -354,47 +354,47 @@ class Order extends Document implements DocumentInterface $buffer_global = []; // Разделение поставок по типам доставки - foreach ($connections as &$connection) { - // Перебор поставок + // foreach ($connections as &$connection) { + // // Перебор поставок - if (count($connection['order_edge_supply'] ?? []) > 1) { - // Поставок более чем одна + // if (count($connection['order_edge_supply'] ?? []) > 1) { + // // Поставок более чем одна - // Инициализация (выбор значения для фильтрации) - $target_dlvr_type = reset($connection['order_edge_supply'])['dlvr']['type'] ?? 'auto'; + // // Инициализация (выбор значения для фильтрации) + // $target_dlvr_type = reset($connection['order_edge_supply'])['dlvr']['type'] ?? 'auto'; - // Инициализация буфера поставок - $buffer = $connection; - unset($buffer['order_edge_supply']); + // // Инициализация буфера поставок + // $buffer = $connection; + // unset($buffer['order_edge_supply']); - foreach ($connection['order_edge_supply'] as $key => &$order_edge_supply) { - // Перебор рёбер: ЗАКАЗ -> ПОСТАВКА + // foreach ($connection['order_edge_supply'] as $key => &$order_edge_supply) { + // // Перебор рёбер: ЗАКАЗ -> ПОСТАВКА - // if ((empty($order_edge_supply['dlvr']['type']) && $target_dlvr_type === 'auto') - // || (isset($order_edge_supply['dlvr']['type']) && $order_edge_supply['dlvr']['type'] !== $target_dlvr_type) - // ) { - if ((isset($order_edge_supply['dlvr']['type']) && $order_edge_supply['dlvr']['type'] === $target_dlvr_type) - || (empty($order_edge_supply['dlvr']['type']) && $target_dlvr_type === 'auto') - ) { - // Тип доставки для одной поставки отличается + // // if ((empty($order_edge_supply['dlvr']['type']) && $target_dlvr_type === 'auto') + // // || (isset($order_edge_supply['dlvr']['type']) && $order_edge_supply['dlvr']['type'] !== $target_dlvr_type) + // // ) { + // if ((isset($order_edge_supply['dlvr']['type']) && $order_edge_supply['dlvr']['type'] === $target_dlvr_type) + // || (empty($order_edge_supply['dlvr']['type']) && $target_dlvr_type === 'auto') + // ) { + // // Тип доставки для одной поставки отличается - // Запись в буфер - $buffer['order_edge_supply'][$key] = $order_edge_supply; + // // Запись в буфер + // $buffer['order_edge_supply'][$key] = $order_edge_supply; - // Удаление из списка - unset($connection['order_edge_supply'][$key]); + // // Удаление из списка + // unset($connection['order_edge_supply'][$key]); - // Перезапись статуса - $changed = true; - } - } + // // Перезапись статуса + // $changed = true; + // } + // } - // Запись из буфера в глобальный буфер - $buffer_global[] = $buffer; - } - } + // // Запись из буфера в глобальный буфер + // $buffer_global[] = $buffer; + // } + // } - $connections = array_merge($connections, $buffer_global); + // $connections = array_merge($connections, $buffer_global); // if ($changed) goto recursive_connections_filtration; @@ -478,9 +478,9 @@ class Order extends Document implements DocumentInterface } catch (Exception $e) { $connection['delivery']['error'] = true; - // var_dump($e->getMessage()); - // var_dump($e->getTrace()); - // var_dump($e->getFile()); die; + var_dump($e->getMessage()); + var_dump($e->getTrace()); + var_dump($e->getFile()); die; // var_dump(json_decode($e->getMessage(), true)['errors']); die; } @@ -505,9 +505,9 @@ class Order extends Document implements DocumentInterface } catch (Exception $e) { $connection['delivery']['error'] = true; - // var_dump($e->getMessage()); - // var_dump($e->getTrace()); - // var_dump($e->getFile()); die; + var_dump($e->getMessage()); + var_dump($e->getTrace()); + var_dump($e->getFile()); die; // var_dump(json_decode($e->getMessage(), true)['errors']); die; } diff --git a/mirzaev/skillparts/system/models/Product.php b/mirzaev/skillparts/system/models/Product.php index 4325a12..62edebb 100644 --- a/mirzaev/skillparts/system/models/Product.php +++ b/mirzaev/skillparts/system/models/Product.php @@ -441,7 +441,7 @@ class Product extends Document $query = self::find() ->for('product') ->in('product_search') - ->search(['catn' => $catn]) + ->filter(['catn' => $catn], 'START_SENSETIVE') ->limit($limit) ->select($select) ->createCommand() diff --git a/mirzaev/skillparts/system/views/cart/index.php b/mirzaev/skillparts/system/views/cart/index.php index 680c02e..fa07984 100644 --- a/mirzaev/skillparts/system/views/cart/index.php +++ b/mirzaev/skillparts/system/views/cart/index.php @@ -113,7 +113,7 @@ use DateTime; } } else { echo << +
Корзина пуста
diff --git a/mirzaev/skillparts/system/views/index.php b/mirzaev/skillparts/system/views/index.php index c895610..39dbba1 100644 --- a/mirzaev/skillparts/system/views/index.php +++ b/mirzaev/skillparts/system/views/index.php @@ -10,7 +10,7 @@ $this->title = 'SkillParts';
-
+

Проблема с подбором запчастей?

@@ -23,7 +23,7 @@ $this->title = 'SkillParts';

-
+
Cummins Iveco Komatsu @@ -42,20 +42,17 @@ $this->title = 'SkillParts';
- -
+

Масла, смазки

-
Масла моторные
-
Масла трансмиссионные
-
Масла гидравлические
-
Смазки
+
Масла моторные
+
Масла трансмиссионные
+
Масла гидравлические
+
Смазки
@@ -65,7 +62,7 @@ $this->title = 'SkillParts';
-
Фары и свет
+
Фары и свет
@@ -75,9 +72,9 @@ $this->title = 'SkillParts';
-
Шприцы для смазки
-
Ключи, съёмники
-
Наборы инструментов
+
Шприцы для смазки
+
Ключи, съёмники
+
Наборы инструментов
@@ -86,3 +83,4 @@ $this->title = 'SkillParts'; + diff --git a/mirzaev/skillparts/system/views/layouts/main.php b/mirzaev/skillparts/system/views/layouts/main.php index 98c8987..e33b78c 100644 --- a/mirzaev/skillparts/system/views/layouts/main.php +++ b/mirzaev/skillparts/system/views/layouts/main.php @@ -48,7 +48,7 @@ AppAsset::register($this);
-
+
-
- // HTML; - // } + + HTML; ?>
@@ -121,13 +107,13 @@ AppAsset::register($this);