From b58587415e2df0b4a7645f214b36425dbdbf12bc Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 20 Feb 2025 15:35:17 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D0=B2=D0=B8=D0=B4=D0=B0=20=D1=82=D0=B0=D0=B1=D0=BB?= =?utf8?q?=D0=B8=D1=86=20=D0=B8=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/YandexMarketController.php | 1 - erp24/records/MarketplaceOrders.php | 18 ++++- erp24/records/MarketplaceOrdersSearch.php | 26 +++++-- .../marketplace-order-delivery/index.php | 42 +++++++----- .../views/marketplace-order-delivery/view.php | 25 ++++--- erp24/views/marketplace-order-items/index.php | 23 +++++-- erp24/views/marketplace-order-items/view.php | 24 +++---- .../index.php | 28 +++++--- .../marketplace-order-status-history/view.php | 15 +---- .../marketplace-order-status-types/index.php | 7 +- erp24/views/marketplace-orders/index.php | 67 ++++++++++++++----- erp24/views/marketplace-orders/view.php | 45 ++++++++----- 12 files changed, 213 insertions(+), 108 deletions(-) diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php index 760c0796..0e8a5143 100644 --- a/erp24/api2/controllers/YandexMarketController.php +++ b/erp24/api2/controllers/YandexMarketController.php @@ -530,5 +530,4 @@ class YandexMarketController extends Controller } return json_encode(["response" => "OK"]); } - } diff --git a/erp24/records/MarketplaceOrders.php b/erp24/records/MarketplaceOrders.php index eda6edf3..fed84a3a 100644 --- a/erp24/records/MarketplaceOrders.php +++ b/erp24/records/MarketplaceOrders.php @@ -2,6 +2,7 @@ namespace yii_app\records; +use app\controllers\MarketplaceOrderStatusTypesController; use Yii; /** @@ -28,7 +29,9 @@ use Yii; */ class MarketplaceOrders extends \yii\db\ActiveRecord { - + const STATUSES_1C = [ + 1 => 'Создан в ЕРП' + ]; /** * {@inheritdoc} @@ -87,4 +90,17 @@ class MarketplaceOrders extends \yii\db\ActiveRecord ]; } + public function getStore() + { + return $this->hasOne(CityStore::class, ['id' => 'store_id']); + } + + public function getStatus() + { + return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'status_id']); + } + public function getSubstatus() + { + return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'substatus_id']); + } } diff --git a/erp24/records/MarketplaceOrdersSearch.php b/erp24/records/MarketplaceOrdersSearch.php index c1fa088d..b5b1a819 100644 --- a/erp24/records/MarketplaceOrdersSearch.php +++ b/erp24/records/MarketplaceOrdersSearch.php @@ -11,6 +11,11 @@ use yii_app\records\MarketplaceOrders; */ class MarketplaceOrdersSearch extends MarketplaceOrders { + + public $store_name; // Добавляем свойство для поиска по названию магазина + public $status_code; // Добавляем свойство для поиска по коду статуса + public $substatus_code; // Добавляем свойство для поиска по коду подстатуса + /** * {@inheritdoc} */ @@ -18,7 +23,7 @@ class MarketplaceOrdersSearch extends MarketplaceOrders { return [ [['id', 'store_id', 'status_id', 'substatus_id', 'cancel_requested', 'status_1c'], 'integer'], - [['marketplace_order_id', 'warehouse_guid', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid'], 'safe'], + [['marketplace_order_id', 'warehouse_guid', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid','store_name', 'status_code', 'substatus_code'], 'safe'], [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'], ]; } @@ -42,9 +47,8 @@ class MarketplaceOrdersSearch extends MarketplaceOrders */ public function search($params, $formName = null) { - $query = MarketplaceOrders::find(); - - // add conditions that should always apply here + $query = MarketplaceOrders::find() + ->joinWith(['store', 'status statusAlias', 'substatus substatusAlias']); $dataProvider = new ActiveDataProvider([ 'query' => $query, @@ -53,12 +57,10 @@ class MarketplaceOrdersSearch extends MarketplaceOrders $this->load($params, $formName); if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); return $dataProvider; } - // grid filtering conditions + // Фильтрация по ID и числовым полям $query->andFilterWhere([ 'id' => $this->id, 'store_id' => $this->store_id, @@ -73,6 +75,7 @@ class MarketplaceOrdersSearch extends MarketplaceOrders 'status_1c' => $this->status_1c, ]); + // Фильтрация по строковым полям $query->andFilterWhere(['ilike', 'marketplace_order_id', $this->marketplace_order_id]) ->andFilterWhere(['ilike', 'warehouse_guid', $this->warehouse_guid]) ->andFilterWhere(['ilike', 'tax_system', $this->tax_system]) @@ -81,6 +84,15 @@ class MarketplaceOrdersSearch extends MarketplaceOrders ->andFilterWhere(['ilike', 'raw_data', $this->raw_data]) ->andFilterWhere(['ilike', 'guid', $this->guid]); + // Поиск по названию магазина + $query->andFilterWhere(['ilike', 'marketplace_store.name', $this->store_name]); + + // Фильтр по коду статуса (с псевдонимом) + $query->andFilterWhere(['ilike', 'statusAlias.code', $this->status_code]); + + // Фильтр по коду подстатуса (с псевдонимом) + $query->andFilterWhere(['ilike', 'substatusAlias.code', $this->substatus_code]); + return $dataProvider; } } diff --git a/erp24/views/marketplace-order-delivery/index.php b/erp24/views/marketplace-order-delivery/index.php index 600faef4..a9c43e18 100644 --- a/erp24/views/marketplace-order-delivery/index.php +++ b/erp24/views/marketplace-order-delivery/index.php @@ -10,15 +10,18 @@ use yii\grid\GridView; /** @var yii_app\records\MarketplaceOrderDeliverySearch $searchModel */ /** @var yii\data\ActiveDataProvider $dataProvider */ -$this->title = 'Marketplace Order Deliveries'; +$this->title = 'Доставки с заказов'; $this->params['breadcrumbs'][] = $this->title; ?> -
+

title) ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?>

render('_search', ['model' => $searchModel]); ?> @@ -29,28 +32,37 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', - 'order_id', + // 'id', + [ + 'attribute' => 'order_id', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [ + 'target' => '_blank', + 'title' => 'Просмотреть заказ' + ]); + } + ], 'type', 'service_name', 'partner_type', //'country', //'postcode', - //'city', - //'street', - //'house', - //'apartment', + 'city', + 'street', + 'house', + 'apartment', //'latitude', //'longitude', - //'delivery_start', - //'delivery_end', - //'courier_full_name', - //'courier_phone', + 'delivery_start', + 'delivery_end', + 'courier_full_name', + 'courier_phone', //'courier_extension', //'courier_vehicle_number', //'courier_vehicle_description', - [ - 'class' => ActionColumn::className(), + ['template' => '{view}', + 'class' => ActionColumn::class, 'urlCreator' => function ($action, MarketplaceOrderDelivery $model, $key, $index, $column) { return Url::toRoute([$action, 'id' => $model->id]); } diff --git a/erp24/views/marketplace-order-delivery/view.php b/erp24/views/marketplace-order-delivery/view.php index 91a90ae6..94c39a17 100644 --- a/erp24/views/marketplace-order-delivery/view.php +++ b/erp24/views/marketplace-order-delivery/view.php @@ -11,26 +11,25 @@ $this->params['breadcrumbs'][] = ['label' => 'Marketplace Order Deliveries', 'ur $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> -
- +
+ 'btn btn-primary my-4']) ?>

title) ?>

-

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

$model, 'attributes' => [ 'id', - 'order_id', + [ + 'attribute' => 'order_id', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [ + 'target' => '_blank', + 'title' => 'Просмотреть заказ' + ]); + } + ], 'type', 'service_name', 'partner_type', diff --git a/erp24/views/marketplace-order-items/index.php b/erp24/views/marketplace-order-items/index.php index 94731453..e08a043f 100644 --- a/erp24/views/marketplace-order-items/index.php +++ b/erp24/views/marketplace-order-items/index.php @@ -10,15 +10,18 @@ use yii\grid\GridView; /** @var yii_app\records\MarketplaceOrderItemsSearch $searchModel */ /** @var yii\data\ActiveDataProvider $dataProvider */ -$this->title = 'Marketplace Order Items'; +$this->title = 'Элементы заказа'; $this->params['breadcrumbs'][] = $this->title; ?> -
+

title) ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?>

render('_search', ['model' => $searchModel]); ?> @@ -30,7 +33,16 @@ $this->params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\SerialColumn'], 'id', - 'order_id', + [ + 'attribute' => 'order_id', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [ + 'target' => '_blank', + 'title' => 'Просмотреть заказ' + ]); + } + ], 'external_item_id', 'offer_id', 'offer_name', @@ -46,7 +58,8 @@ $this->params['breadcrumbs'][] = $this->title; //'promos:ntext', //'subsidies:ntext', [ - 'class' => ActionColumn::className(), + 'template' => '{view}', + 'class' => ActionColumn::class, 'urlCreator' => function ($action, MarketplaceOrderItems $model, $key, $index, $column) { return Url::toRoute([$action, 'id' => $model->id]); } diff --git a/erp24/views/marketplace-order-items/view.php b/erp24/views/marketplace-order-items/view.php index fc19e381..a1920a79 100644 --- a/erp24/views/marketplace-order-items/view.php +++ b/erp24/views/marketplace-order-items/view.php @@ -12,25 +12,25 @@ $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?>
- + 'btn btn-primary my-4']) ?>

title) ?>

-

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

+ $model, 'attributes' => [ 'id', - 'order_id', + [ + 'attribute' => 'order_id', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [ + 'target' => '_blank', + 'title' => 'Просмотреть заказ' + ]); + } + ], 'external_item_id', 'offer_id', 'offer_name', diff --git a/erp24/views/marketplace-order-status-history/index.php b/erp24/views/marketplace-order-status-history/index.php index 9be5c4dd..bff79ec2 100644 --- a/erp24/views/marketplace-order-status-history/index.php +++ b/erp24/views/marketplace-order-status-history/index.php @@ -13,14 +13,16 @@ use yii\grid\GridView; $this->title = 'Marketplace Order Status Histories'; $this->params['breadcrumbs'][] = $this->title; ?> -
+

title) ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?>

- render('_search', ['model' => $searchModel]); ?> params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\SerialColumn'], 'id', - 'order_id', + [ + 'attribute' => 'order_id', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [ + 'target' => '_blank', + 'title' => 'Просмотреть заказ' + ]); + } + ], 'status_id', 'substatus_id', 'active', - //'date_from', - //'date_end', - //'initiator:ntext', + 'date_from', + 'date_end', + 'initiator:ntext', [ - 'class' => ActionColumn::className(), + 'template' => '{view}', + 'class' => ActionColumn::class, 'urlCreator' => function ($action, MarketplaceOrderStatusHistory $model, $key, $index, $column) { return Url::toRoute([$action, 'id' => $model->id]); } diff --git a/erp24/views/marketplace-order-status-history/view.php b/erp24/views/marketplace-order-status-history/view.php index 77911149..a606771f 100644 --- a/erp24/views/marketplace-order-status-history/view.php +++ b/erp24/views/marketplace-order-status-history/view.php @@ -11,20 +11,11 @@ $this->params['breadcrumbs'][] = ['label' => 'Marketplace Order Status Histories $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> -
- +
+ 'btn btn-primary my-4']) ?>

title) ?>

-

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

+ $model, diff --git a/erp24/views/marketplace-order-status-types/index.php b/erp24/views/marketplace-order-status-types/index.php index e52728e0..00637982 100644 --- a/erp24/views/marketplace-order-status-types/index.php +++ b/erp24/views/marketplace-order-status-types/index.php @@ -14,7 +14,12 @@ $this->title = 'Статусы заказов Яндекс Маркет'; $this->params['breadcrumbs'][] = $this->title; ?>
- +

+ 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> +

title) ?>

diff --git a/erp24/views/marketplace-orders/index.php b/erp24/views/marketplace-orders/index.php index c842bdf4..e2afb514 100644 --- a/erp24/views/marketplace-orders/index.php +++ b/erp24/views/marketplace-orders/index.php @@ -10,15 +10,18 @@ use yii\grid\GridView; /** @var yii_app\records\MarketplaceOrdersSearch $searchModel */ /** @var yii\data\ActiveDataProvider $dataProvider */ -$this->title = 'Marketplace Orders'; +$this->title = 'Заказы с маркетплейсов (Яндекс Маркет)'; $this->params['breadcrumbs'][] = $this->title; ?> -

+

title) ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + 'btn btn-success']) ?>

render('_search', ['model' => $searchModel]); ?> @@ -29,29 +32,61 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', + //'id', 'marketplace_order_id', - 'store_id', - 'status_id', - 'substatus_id', + [ + 'attribute' => 'store_id', + 'value' => function ($model) { + return $model->store->name ?? '-'; + }, + 'filter' => Html::input('text', 'MarketplaceOrdersSearch[store_name]', $searchModel->store_name, ['class' => 'form-control']), + ], + [ + 'attribute' => 'status_id', + 'format' => 'raw', + 'value' => function ($model) { + $status = $model->status->code ?? ''; + $class = ''; + if ($status === 'DELIVERED') { + $class = 'bg-success text-white'; + } elseif ($status === 'CANCELLED') { + $class = 'bg-danger text-white'; + } + return Html::tag('span', $status, ['class' => "badge $class"]); + }, + 'filter' => Html::input('text', 'MarketplaceOrdersSearch[status_code]', $searchModel->status_code, ['class' => 'form-control']), + ], + [ + 'attribute' => 'substatus_id', + 'value' => function ($model) { + return $model->substatus->code ?? '-'; + }, + 'filter' => Html::input('text', 'MarketplaceOrdersSearch[substatus_code]', $searchModel->substatus_code, ['class' => 'form-control']), + ], //'warehouse_guid', - //'creation_date', - //'updated_at', - //'total', - //'delivery_total', - //'buyer_total_before_discount', + 'creation_date', + 'updated_at', + 'total', + 'delivery_total', + 'buyer_total_before_discount', //'tax_system', //'payment_type', //'payment_method', //'cancel_requested', //'raw_data:ntext', - //'guid', - //'status_1c', + 'guid', + [ + 'attribute' => 'status_1c', + 'value' => function ($model) { + return MarketplaceOrders::STATUSES_1C[$model->status_1c]; + } + ], [ - 'class' => ActionColumn::className(), + 'template' => '{view}', + 'class' => ActionColumn::class, 'urlCreator' => function ($action, MarketplaceOrders $model, $key, $index, $column) { return Url::toRoute([$action, 'id' => $model->id]); - } + } ], ], ]); ?> diff --git a/erp24/views/marketplace-orders/view.php b/erp24/views/marketplace-orders/view.php index 9afbae35..2f4ea5ab 100644 --- a/erp24/views/marketplace-orders/view.php +++ b/erp24/views/marketplace-orders/view.php @@ -2,38 +2,44 @@ use yii\helpers\Html; use yii\widgets\DetailView; +use yii_app\records\MarketplaceOrders; /** @var yii\web\View $this */ /** @var yii_app\records\MarketplaceOrders $model */ -$this->title = $model->id; +$this->title = 'Заказ магазина ' . $model->store->name . ' от ' . $model->creation_date; $this->params['breadcrumbs'][] = ['label' => 'Marketplace Orders', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); ?> -
- +
+ 'btn btn-primary my-4']) ?>

title) ?>

-

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

$model, 'attributes' => [ 'id', 'marketplace_order_id', - 'store_id', - 'status_id', - 'substatus_id', + [ + 'attribute' => 'store_id', + 'value' => function ($model) { + return $model->store->name; + } + ], + [ + 'attribute' => 'status_id', + 'value' => function ($model) { + return $model->status->code; + } + ], + [ + 'attribute' => 'substatus_id', + 'value' => function ($model) { + return $model->substatus->code; + } + ], 'warehouse_guid', 'creation_date', 'updated_at', @@ -46,7 +52,12 @@ $this->params['breadcrumbs'][] = $this->title; 'cancel_requested', 'raw_data:ntext', 'guid', - 'status_1c', + [ + 'attribute' => 'status_1c', + 'value' => function ($model) { + return MarketplaceOrders::STATUSES_1C[$model->status_1c]; + } + ], ], ]) ?> -- 2.39.5