Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Dec 15, 2016
1 parent a5e6b6e commit 3251fee
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
==============

1.0.12
-----------------
* Доработки

1.0.11
-----------------
* Ответное апи
Expand Down
5 changes: 3 additions & 2 deletions _ide/YiiApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* @date 16.07.2016
*/
namespace yii\web;
use v3toys\skeeks\components\V3toysComponent;
use v3toys\skeeks\components\V3toysSettings;
use v3toys\skeeks\V3toysModule;

/**
* @property V3toysModule $v3toys
* @property V3toysSettings $v3toysSettings
* @property V3toysComponent $v3toys
* @property V3toysSettings $v3toysSettings
*
* Class Application
* @package yii\web
Expand Down
28 changes: 28 additions & 0 deletions components/V3toysComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 16.07.2016
*/
namespace v3toys\skeeks\components;

use yii\base\Component;

/**
* Class V3toysComponent
*
* @package v3toys\skeeks\components
*/
class V3toysComponent extends Component
{
/**
* @param $cmsContentElement
*
* @return int
*/
public function getV3toysIdByCmsElement($cmsContentElement)
{
return (int) $cmsContentElement->relatedPropertiesModel->getAttribute($this->v3toysIdPropertyName);
}
}
1 change: 1 addition & 0 deletions components/V3toysSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,5 @@ public function getCurrentMinPickupPrice()
print_r($response->data);
}
}*/

}
5 changes: 5 additions & 0 deletions config/main-console.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
'class' => 'v3toys\skeeks\components\V3toysSettings'
],

'v3toys' =>
[
'class' => 'v3toys\skeeks\components\V3toysComponent'
],

'i18n' =>
[
'translations' =>
Expand Down
5 changes: 5 additions & 0 deletions config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
'class' => 'v3toys\skeeks\components\V3toysSettings'
],

'v3toys' =>
[
'class' => 'v3toys\skeeks\components\V3toysComponent'
],

'i18n' =>
[
'translations' =>
Expand Down
4 changes: 2 additions & 2 deletions console/controllers/AgentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public function actionMessagesUpdate()
/**
* Отправка новых заказов в v3toys
*/
public function actionSubmitNewOrders()
public function actionSubmitNewOrders($countDay = 3)
{
if ($orders = V3toysOrder::find()->where(['v3toys_order_id' => null])->andWhere(['>=', 'created_at', time() - 3600*24])->all())
if ($orders = V3toysOrder::find()->where(['v3toys_order_id' => null])->andWhere(['>=', 'created_at', time() - 3600*24*$countDay])->all())
{
$totalOrders = count($orders);
$this->stdout("Заказов к отправке в v3toys: {$totalOrders}\n", Console::BOLD);
Expand Down
17 changes: 15 additions & 2 deletions models/V3toysOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace v3toys\skeeks\models;

use skeeks\cms\models\behaviors\HasJsonFieldsBehavior;
use skeeks\cms\models\CmsContentElement;
use skeeks\cms\models\CmsUser;
use skeeks\cms\models\forms\SignupForm;
use skeeks\cms\shop\models\ShopBuyer;
Expand Down Expand Up @@ -317,8 +318,11 @@ static public function createCurrent()
{
if ($shopBasket->product)
{
$v3toys_id = \Yii::$app->v3toys->getV3toysIdByCmsElement($shopBasket->product->cmsContentElement);

$products[] = [
'v3toys_product_id' => (int) $shopBasket->product->cmsContentElement->relatedPropertiesModel->getAttribute(\Yii::$app->v3toysSettings->v3toysIdPropertyName),
'v3toys_product_id' => $v3toys_id,
'purchasing_price' => $shopBasket->product->purchasing_price,
'price' => $shopBasket->price,
'quantity' => $shopBasket->quantity,
'name' => (string) $shopBasket->product->cmsContentElement->name,
Expand Down Expand Up @@ -528,8 +532,17 @@ public function getProductsForApi()
{
foreach ((array) $this->products as $productdata)
{
if (!$v3toys_id = ArrayHelper::getValue($productdata, 'v3toys_product_id'))
{
$productId = ArrayHelper::getValue($productdata, 'product_id');
if ($element = CmsContentElement::findOne($productId))
{
$v3toys_id = \Yii::$app->v3toys->getV3toysIdByCmsElement($element);
}
}

$result[] = [
'product_id' => ArrayHelper::getValue($productdata, 'v3toys_product_id'),
'product_id' => $v3toys_id,
'price' => ArrayHelper::getValue($productdata, 'price'),
'quantity' => ArrayHelper::getValue($productdata, 'quantity'),
];
Expand Down

0 comments on commit 3251fee

Please sign in to comment.