--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+class m250910_130353_add_created_at_field_to_marketplace_order_status_types_table extends Migration
+{
+ const TABLE_NAME = 'erp24.marketplace_order_status_types';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
+ if ($table === null) {
+ return;
+ }
+
+ if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('created_at')) {
+ $this->addColumn(
+ self::TABLE_NAME,
+ 'created_at',
+ $this->dateTime()->notNull()->defaultExpression('NOW()'),
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('created_at')) {
+ $this->dropColumn(self::TABLE_NAME, 'created_at');
+ }
+ }
+
+
+ /*
+ // Use up()/down() to run migration code without a transaction.
+ public function up()
+ {
+
+ }
+
+ public function down()
+ {
+ echo "m250910_130353_add_created_at_field_to_marketplace_order_status_types_table cannot be reverted.\n";
+
+ return false;
+ }
+ */
+}
namespace yii_app\records;
use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
/**
* This is the model class for table "marketplace_order_status_types".
* @property string $code Код статуса
* @property string|null $name Название статуса
* @property string|null $description Описание статуса
+ * @property string|null $created_at Время создания
*/
class MarketplaceOrderStatusTypes extends \yii\db\ActiveRecord
{
const CANSELLED_CODE = 'CANCELLED';
const READY_CODE = 'READY_TO_SHIP';
+
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => TimestampBehavior::class,
+ 'createdAtAttribute' => 'created_at',
+ 'value' => new Expression('NOW()'),
+ ],
+ ];
+ }
+
/**
* {@inheritdoc}
*/
{
return [
[['name', 'description'], 'default', 'value' => null],
+ [['created_at'], 'safe'],
[['code'], 'required'],
[['code'], 'string', 'max' => 64],
[['name', 'description'], 'string', 'max' => 255],
'code' => 'Код статуса',
'name' => 'Название статуса',
'description' => 'Описание статуса',
+ 'created_at' => 'Время создания'
];
}
}
->indexBy('code')
->asArray()
->all();
+ if (empty($statuses)) {
+ return 0;
+ }
$statuses = ArrayHelper::map($statuses, 'code', 'id');
$statusCodes = array_unique(array_keys($statuses));
$newOrdersCount = 0;
if (!$marketplaceOrder) {
if ($index == self::SUBJECT_INDEX[self::SUBJECT_NEW]) {
- $marketplaceOrder = self::createOrder($orderDetails, $campaignId, $statusId, $substatusId);
+ $marketplaceOrder = self::createOrderFlowwow($orderDetails, $campaignId, $statusId, $substatusId);
if ($marketplaceOrder->save()) {
self::sendMessageToTelegram($marketplaceOrder->guid, "Новый заказ Флаувау");
$newOrdersCount += 1;
return $statuses[$statusCode];
}
- private static function createOrder($order, $campaignId, $statusId, $substatusId)
+ private static function createOrderFlowwow($order, $campaignId, $statusId, $substatusId)
{
$store = MarketplaceStore::find()
->where(['warehouse_guid' => (string)$campaignId])