From 82d6747425bded3129caae16eae32cc10c8cc3c1 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Thu, 10 Mar 2022 09:00:12 +1000 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=88=D0=B5=D0=BB=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=85=D1=83=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/invoices/18234637/invoice.xlsx | Bin 8204 -> 0 bytes .../skillparts/system/config/web.php.example | 2 +- .../system/controllers/AccountController.php | 57 ++++++++- .../system/controllers/OrderController.php | 116 ++++++++++-------- .../system/controllers/ProfileController.php | 3 + .../system/controllers/SearchController.php | 1 + mirzaev/skillparts/system/models/Order.php | 8 +- mirzaev/skillparts/system/models/Search.php | 10 +- mirzaev/skillparts/system/models/Supply.php | 10 +- .../skillparts/system/views/cart/index.php | 2 - .../system/views/invoice/order/pattern.php | 4 +- .../system/views/profile/supplies.php | 2 +- mirzaev/skillparts/system/web/js/cart.js | 26 ++-- 13 files changed, 154 insertions(+), 87 deletions(-) delete mode 100644 mirzaev/skillparts/system/assets/invoices/18234637/invoice.xlsx diff --git a/mirzaev/skillparts/system/assets/invoices/18234637/invoice.xlsx b/mirzaev/skillparts/system/assets/invoices/18234637/invoice.xlsx deleted file mode 100644 index cdf3a5e18f05957e568d8dd577d9c096bcb9529c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8204 zcmZ`;1yozxwxu`$N^o}y1a~Ma~Q zy6@cVj2*O@T&=B&zYfZFvH-;{J;gQ|rIIUz5IGP1Ixy%I1oX;iB9wb;tS-+lrK4iw zri5Z_48%^GP3_-ooI0u=82Jm(S^~HR>|@i>Rp=@i<`&mM&4zD-^{C7&%k(@@ta$4Q zm@i(6fDJGKD&4zBuhB9(2*4)91UHHrx*}Pst(z~q0I_|xXLqs4mK2HcJw5(1J0f*S>=06VD=2BkN~KpBXh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6V)Ed3**}^MF9iE#j61a!^p+1v}UQHH-kdCFw zn^--SdVaB)+yq3Ae=#~JnsBR_fxWSJp(TD_4|3uT`}mTR+(=OstS3ze;{rI4ZUPofd9EX60K- zSAAoFaqf#iW#!8Zn8p@|(nbA!eTr1$8hY#OrGhLT63Afx23`UWb zRC{?Tt4!xib9E0|W}hR&q(o*KA~ufBZVIZ9=KSQ>S69~^FUh{(Em|P$+<#C=6=Euv z8L+)`els)EO7p(Hv@m94)a{MU5c7QPn?Zpzb)AU$F2fn$@O7g`Fzai)Mlf@4m-bHPR#YgdGKUOI? zD;BA(Cs0&YzU~FI`6_ zob@F%IS|T2SGeX<2-$Gx{p>YVCfb}GJy4&Vf%V1%#7GmJ;C8>6wLC?IQ)3s8LTjK} z)3@BQ@nI=V_^re;3pO>fE{0m%l4s^eFAfX?Y))zh9PsgZMs=MKzA;^lYrLsB{%zZ~ zlh`F#?#68BZS5n%?iPYP+I=25`5qr+_Tq^p*)ACgFJ{OLjqo0ctf6$>%CnWzt|F2Z>9RB?1{12S| zsrdRY2kFlVo}b73A;5iVSpVDU%yWk4J?' => 'account/index', '<_key:[0-9]+>//' => 'account/', '<_key:[0-9]+>/files/' => 'account/file', - '<_key:[0-9]+>/' => 'account/', + '<_key:[0-9]+>/' => 'account/', 'product/' => 'product/index', 'product//' => 'product/', '///' => '
/-', diff --git a/mirzaev/skillparts/system/controllers/AccountController.php b/mirzaev/skillparts/system/controllers/AccountController.php index ffbe8f4..29534a4 100644 --- a/mirzaev/skillparts/system/controllers/AccountController.php +++ b/mirzaev/skillparts/system/controllers/AccountController.php @@ -23,7 +23,8 @@ class AccountController extends Controller [ 'allow' => true, 'actions' => [ - 'file' + 'file', + 'data' ] ], [ @@ -258,8 +259,9 @@ class AccountController extends Controller /** * Регенерация параметра * - * @param int $_key + * @param int $_key Идентификатор * @param string $target + * * @return void */ public function actionRegenerate(int $_key, string $target) @@ -299,4 +301,55 @@ class AccountController extends Controller return false; } + + /** + * Информация + * + * @param int $_key Идентификатор + */ + public function actionData(int $_key) + { + if (yii::$app->request->isPost) { + // AJAX-POST-запрос + + // Инициализация аккаунта (тот кто выполняет запрос) + $account = account::initAccount(); + + // Поиск данных об аккаунта (запрашиваемом) + $data = account::initAccount($_key)->getAttributes(); + + if ($account->isAdmin() || $account->isModer()) { + // Авторизован как работник + } else if ((int) $account->_key === $_key) { + // Авторизован как владелец аккаунта + + unset( + $data['vrfy'], + $data['geol'], + $data['auth'], + $data['jrnl'], + $data['acpt'], + $data['pswd'] + ); + } else { + // Не авторизован + + // Очистка от защищенных свойств + $data = [ + '_key' => $data['_key'], + 'indx' => $data['indx'], + 'agnt' => $data['agnt'], + 'type' => $data['type'] + ]; + } + + // Настройка формата ответа + yii::$app->response->format = Response::FORMAT_JSON; + + return [ + 'data' => $data, + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } } diff --git a/mirzaev/skillparts/system/controllers/OrderController.php b/mirzaev/skillparts/system/controllers/OrderController.php index 2ccf0fd..8707a87 100644 --- a/mirzaev/skillparts/system/controllers/OrderController.php +++ b/mirzaev/skillparts/system/controllers/OrderController.php @@ -588,67 +588,77 @@ class OrderController extends Controller // Инициализация $model = Order::searchByType(supplies: true); - // Поиск ребра - $account_edge_order = AccountEdgeOrder::searchByVertex(yii::$app->user->id, $model->readId(), 'current')[0]; + if (($account_edge_order = AccountEdgeOrder::searchByVertex(yii::$app->user->id, $model->readId(), 'current')[0]) ?? false) { + // Найдено ребро: АККАУНТ -> ЗАКАЗ - if ($supplies = OrderEdgeSupply::searchByDirection($account_edge_order->to)) { - // Поставки найдены - // Добавить проверку на то, что товары активны + if ($order_edge_supply = OrderEdgeSupply::searchByDirection($account_edge_order->_to, type: 'write', limit: 500)) { + // Найдены рёбра: ЗАКАЗ -> ПОСТАВКА - } + foreach ($order_edge_supply as $edge) { + // Перебор рёбер: ЗАКАЗ -> ПОСТАВКА - var_dump($supplies); die; + if ($product = Product::searchBySupplyId($edge->_to)) { + // Найден товар - if (count($account_edge_order) > 1) { - // Найден более чем 1 заказ - - return null; - } - - // Запись - $account_edge_order->type = 'requested'; - - if ($account_edge_order->update()) { - // Удалось сохранить изменения - - // Запись в журнал - $model->journal('requested'); - - // Инициализация буфера поставок - $supplies = []; - - foreach ($model['supplies'] as $supply) { - // Перебор поставок - - $supplies[] = [ - 'title' => $supply['supply']['catn'], - 'amount' => [ - 'value' => $supply['amount'] ?? 0, - 'unit' => 'шт' - ], - 'cost' => [ - 'value' => $supply['cost'] ?? 0, - 'unit' => 'руб' - ], - 'type' => 'supply' - ]; + // Проверка на активность товара + if ($product['stts'] === 'active'); + else $edge->delete(); + } + } } - Invoice::generate($model->_key, $this->renderPartial('/invoice/order/pattern', [ - 'buyer' => [ - 'id' => yii::$app->user->identity->_key, - 'info' => 'Неизвестно' - ], - 'order' => [ - 'id' => $model->_key, - 'date' => $account_edge_order->date ?? time(), - 'entries' => $supplies - ] - ])); + // Реиницилазация + $model = Order::searchByType(supplies: true); - // Отправка уведомлений модераторам - Notification::_write($this->renderPartial('/notification/system/orders/new', ['id' => $account_edge_order->_key]), true, '@auth', Notification::TYPE_MODERATOR_ORDER_NEW); + // Запись + $account_edge_order->type = 'requested'; + + if ($account_edge_order->update()) { + // Удалось сохранить изменения + + // Запись в журнал + $model->journal('requested'); + + // Инициализация буфера поставок + $supplies = []; + + foreach ($model['supplies'] as $supply) { + // Перебор поставок + + $supplies[] = [ + 'title' => $supply['supply']['catn'], + 'delivery' => 0, + 'amount' => [ + // 'value' => $supply['amount'][$supply['order_edge_supply'][]] ?? 0, + // 'value' => $supply['amount'] ?? 0, + 'value' => 0, + 'unit' => 'шт' + ], + 'cost' => [ + // 'value' => $supply['cost'] ?? 0, + 'value' => 0, + 'unit' => 'руб' + ], + 'type' => 'supply' + ]; + } + + Invoice::generate($model->_key, $this->renderPartial('/invoice/order/pattern', [ + 'buyer' => [ + 'id' => yii::$app->user->identity->_key, + 'info' => 'Неизвестно' + ], + 'order' => [ + 'id' => $model->_key, + 'date' => $account_edge_order->date ?? time(), + 'entries' => $supplies + ] + ])); + + // Отправка уведомлений модераторам + Notification::_write($this->renderPartial('/notification/system/orders/new', ['id' => $account_edge_order->_key]), true, '@auth', Notification::TYPE_MODERATOR_ORDER_NEW); + } } return $this->actionIndex(); diff --git a/mirzaev/skillparts/system/controllers/ProfileController.php b/mirzaev/skillparts/system/controllers/ProfileController.php index a54923f..b4f1052 100644 --- a/mirzaev/skillparts/system/controllers/ProfileController.php +++ b/mirzaev/skillparts/system/controllers/ProfileController.php @@ -877,6 +877,9 @@ class ProfileController extends Controller return false; } + /** + * Поиск заявок на регистрацию + */ public function actionPanelSuppliersRequestsSearch() { if (Yii::$app->request->isPost) { diff --git a/mirzaev/skillparts/system/controllers/SearchController.php b/mirzaev/skillparts/system/controllers/SearchController.php index f70e2ae..75cef95 100644 --- a/mirzaev/skillparts/system/controllers/SearchController.php +++ b/mirzaev/skillparts/system/controllers/SearchController.php @@ -31,6 +31,7 @@ class SearchController extends Controller if ($auth_only && yii::$app->user->isGuest) { // Если активирован режим "Поиск только аутентифицированным" и запрос пришел не от аутентифицированного + // Запись кода ответа: 401 (необходима авторизация) yii::$app->response->statusCode = 401; diff --git a/mirzaev/skillparts/system/models/Order.php b/mirzaev/skillparts/system/models/Order.php index 31041d9..e7fbbd5 100644 --- a/mirzaev/skillparts/system/models/Order.php +++ b/mirzaev/skillparts/system/models/Order.php @@ -549,7 +549,7 @@ class Order extends Document implements DocumentInterface // Чтение стоимости $cost = Supply::readCostById($connection['supply']['_id']); - if (empty($cost) || $cost['ЦенаЗаЕдиницу'] < 1) { + if (empty($cost) || $cost < 1) { // Если стоимость не найдена или равна нулю (явная ошибка) // Удаление из базы данных @@ -633,7 +633,7 @@ class Order extends Document implements DocumentInterface } // Запись цены (цена поставки + цена доставки + наша наценка) - $connection['cost']['auto'] = ($cost['ЦенаЗаЕдиницу'] ?? $connection['supply']->onec['Цены']['Цена']['ЦенаЗаЕдиницу']) + ($connection['delivery']['auto']['price']['all'] ?? $connection['delivery']['auto']['price']['one'] ?? 0) + ($settings['increase'] ?? 0) ?? 0; + $connection['cost']['auto'] = ($cost ?? $connection['supply']->onec['Цены']['Цена']['ЦенаЗаЕдиницу']) + ($connection['delivery']['auto']['price']['all'] ?? $connection['delivery']['auto']['price']['one'] ?? 0) + ($settings['increase'] ?? 0) ?? 0; // } else { // Доставка самолётом @@ -696,11 +696,11 @@ class Order extends Document implements DocumentInterface } // Запись цены (цена поставки + цена доставки + наша наценка) - $connection['cost']['avia'] = ($cost['ЦенаЗаЕдиницу'] ?? $connection['supply']->onec['Цены']['Цена']['ЦенаЗаЕдиницу']) + ($connection['delivery']['avia']['price']['all'] ?? $connection['delivery']['avia']['price']['one'] ?? 0) + ($settings['increase'] ?? 0) ?? 0; + $connection['cost']['avia'] = ($cost ?? $connection['supply']->onec['Цены']['Цена']['ЦенаЗаЕдиницу']) + ($connection['delivery']['avia']['price']['all'] ?? $connection['delivery']['avia']['price']['one'] ?? 0) + ($settings['increase'] ?? 0) ?? 0; // } // Запись валюты - $connection['currency'] = $cost['Валюта']; + $connection['currency'] = 'руб'; } return $connections; diff --git a/mirzaev/skillparts/system/models/Search.php b/mirzaev/skillparts/system/models/Search.php index bda29d2..155a1fd 100644 --- a/mirzaev/skillparts/system/models/Search.php +++ b/mirzaev/skillparts/system/models/Search.php @@ -255,12 +255,12 @@ class Search extends Document } catch (Exception $e) { $connection['delivery']['error'] = true; - var_dump($e->getMessage()); - var_dump($e->getTrace()); - var_dump($e->getFile()); + // var_dump($e->getMessage()); + // var_dump($e->getTrace()); + // var_dump($e->getFile()); - var_dump(json_decode($e->getMessage(), true)['errors']); - die; + // var_dump(json_decode($e->getMessage(), true)['errors']); + // die; } finally { // echo $connection['delivery']['price']['all']; // Инициализация цены (цена поставки + цена доставки + наша наценка) diff --git a/mirzaev/skillparts/system/models/Supply.php b/mirzaev/skillparts/system/models/Supply.php index e6bf367..cebb1f6 100644 --- a/mirzaev/skillparts/system/models/Supply.php +++ b/mirzaev/skillparts/system/models/Supply.php @@ -895,15 +895,11 @@ class Supply extends Product implements ProductInterface, OfferInterface * @param string $_id Идентификатор поставки * @param Product|null $product Товар для поиска по вершинам * - * @return array|null Данные о ценах + * @return int|null Стоимость (руб) */ - public static function readCostById(string $_id, Product $product = null): ?array + public static function readCostById(string $_id, Product $product = null): ?int { - if (isset($product)) { - return SupplyEdgeProduct::searchByVertex($_id, $product->readId(), type: 'connect', limit: 1)['onec']['Цены']['Цена']; - } - - return SupplyEdgeProduct::searchByDirection($_id, type: 'connect', limit: 1)['onec']['Цены']['Цена']; + return Supply::searchById($_id)->cost ?? null; } /** diff --git a/mirzaev/skillparts/system/views/cart/index.php b/mirzaev/skillparts/system/views/cart/index.php index d7991e9..a28fa97 100644 --- a/mirzaev/skillparts/system/views/cart/index.php +++ b/mirzaev/skillparts/system/views/cart/index.php @@ -25,7 +25,6 @@ use DateTime; Артикул
- Описание
Количество @@ -104,7 +103,6 @@ use DateTime; {$supply['catn']}
- {$supply['dscr']}
diff --git a/mirzaev/skillparts/system/views/invoice/order/pattern.php b/mirzaev/skillparts/system/views/invoice/order/pattern.php index 6bd10dc..1b88f16 100644 --- a/mirzaev/skillparts/system/views/invoice/order/pattern.php +++ b/mirzaev/skillparts/system/views/invoice/order/pattern.php @@ -156,9 +156,7 @@ use app\models\Settings; - - - + diff --git a/mirzaev/skillparts/system/views/profile/supplies.php b/mirzaev/skillparts/system/views/profile/supplies.php index bf43ec8..2c9c7d6 100644 --- a/mirzaev/skillparts/system/views/profile/supplies.php +++ b/mirzaev/skillparts/system/views/profile/supplies.php @@ -216,7 +216,7 @@ $panel ?? $panel = 'profile_panel_supplies_input_import'; - + Создать склад
diff --git a/mirzaev/skillparts/system/web/js/cart.js b/mirzaev/skillparts/system/web/js/cart.js index 0daf049..0266378 100644 --- a/mirzaev/skillparts/system/web/js/cart.js +++ b/mirzaev/skillparts/system/web/js/cart.js @@ -348,7 +348,7 @@ function cart_registration_entity_init(_key, wrap = 'cart_registration_entity_bo wrap = document.getElementById(wrap); $.ajax({ - url: '/profile/panel/suppliers/requests/search', + url: '/' + _key + '/data', type: 'post', dataType: 'json', data: { @@ -361,13 +361,13 @@ function cart_registration_entity_init(_key, wrap = 'cart_registration_entity_bo if (data !== undefined) { // Получены данные с сервера - if (data.suppliers !== undefined && data.suppliers !== null) { + if (data.data !== undefined && data.data !== null) { // Найдены данные поставщиков // Удаление данных в оболочке wrap.innerHTML = null; - for (let html of cart_registration_entity_generate(data.suppliers[0])) { + for (let html of cart_registration_entity_generate(data.data)) { // Перебор сгенерированных HTML-элементов // Запись в документ @@ -438,7 +438,7 @@ function cart_registration_entity_generate(account) { input_boss.setAttribute('type', 'text'); input_boss.setAttribute('placeholder', 'Иванов Иван Иванович'); input_boss.setAttribute('onchange', 'return cart_registration_block_edit(' + account._key + ', "boss", this.value);'); - input_boss.value = account.boss ?? '';; + input_boss.value = account.boss ?? ''; // Инициализация ярлыка "SIMC" (телефон) let label_simc = document.createElement('label'); @@ -451,7 +451,7 @@ function cart_registration_entity_generate(account) { input_simc.setAttribute('class', 'form-control button_clean mb-3'); input_simc.setAttribute('type', 'number'); input_simc.setAttribute('onchange', 'return cart_registration_block_edit(' + account._key + ', "simc", this.value);'); - input_simc.value = ''; + input_simc.value = account.simc ?? ''; // Инициализация ярлыка "MAIL" let label_mail = document.createElement('label'); @@ -607,13 +607,21 @@ function cart_registration_entity_generate(account) { }; function cart_registration_choose(button = 'cart_registration_entity', account) { + // Инициализация элементов + let entity = document.getElementById('cart_registration_entity'); + let entity_button = document.getElementById('cart_registration_entity_button'); + let individual = document.getElementById('cart_registration_individual'); + let individual_button = document.getElementById('cart_registration_individual_button'); + // Деинициализация всех вкладок - document.getElementById('cart_registration_entity').checked = - document.getElementById('cart_registration_individual').checked = false; + entity.checked = false; + individual.checked = false; - document.getElementById('cart_registration_entity').setAttribute('onclick', 'page_profile_panel_choose(\'cart_registration_entity\')'); - document.getElementById('cart_registration_individual').setAttribute('onclick', 'page_profile_panel_choose(\'cart_registration_individual\'); cart_registration_entity_init(' + account + ')'); + // Запись скриптов + entity_button.setAttribute('onclick', 'cart_registration_choose(\'cart_registration_entity\', ' + account + '); cart_registration_entity_init(' + account + ')'); + individual_button.setAttribute('onclick', 'cart_registration_choose(\'cart_registration_individual\', ' + account + ')'); + // Удаление активного статуса document.querySelector('[for="cart_registration_entity"]').classList.remove('active'); document.querySelector('[for="cart_registration_individual"]').classList.remove('active');