--- /dev/null
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use yii\web\Response;
+use yii\web\UploadedFile;
+use yii_app\records\MarketplaceOrders;
+use yii_app\services\FileService;
+
+class MarketplaceController
+{
+ public function actionUploadPhoto($id)
+ {
+ Yii::$app->response->format = Response::FORMAT_JSON;
+ if (Yii::$app->request->isPost) {
+ $order = MarketplaceOrders::find()->where(['id`' => $id])->one();
+ $entity = 'marketplace_order/order_phpto';
+ $uploadedFile = UploadedFile::getInstanceByName('file');
+ if ($uploadedFile && $order) {
+ FileService::saveUploadedFile($uploadedFile, $entity, $order->id);
+ }
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+class m250422_141409_add_column_order_photo_to_marketplace_orders_table extends Migration
+{
+ const TABLE_NAME = 'erp24.marketplace_orders';
+ /**
+ * {@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('order_photo')) {
+ $this->addColumn(
+ self::TABLE_NAME,
+ 'order_photo',
+ $this->string()->null()->comment('Ссылка на фото собранного заказа для МП')
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('order_photo')) {
+ $this->dropColumn(self::TABLE_NAME, 'order_photo');
+ }
+ }
+
+ /*
+ // Use up()/down() to run migration code without a transaction.
+ public function up()
+ {
+
+ }
+
+ public function down()
+ {
+ echo "m250422_141409_add_column_order_photo_to_marketplace_orders_table cannot be reverted.\n";
+
+ return false;
+ }
+ */
+}
* @property string|null $telegram_error ошибка телеграмма
* @property string|null $status_processing_1c Статус обработки заказа в 1С
* @property string|null $order_link Ссылка на заказ в МП
+ * @property string|null $order_photo Ссылка на фото собранного заказа для МП
*/
class MarketplaceOrders extends \yii\db\ActiveRecord
{
[['store_id', 'warehouse_guid', 'returned_at', 'return_data', 'raw_data', 'guid'], 'default', 'value' => null],
[['cancel_requested', 'status_telegram'], 'default', 'value' => 0],
[['marketplace_order_id', 'marketplace_id', 'marketplace_name', 'status_id', 'substatus_id', 'creation_date', 'updated_at', 'total', 'delivery_total', 'buyer_total_before_discount', 'tax_system', 'payment_type', 'payment_method'], 'required'],
- [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'status_processing_1c', 'order_link'], 'default', 'value' => null],
+ [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'status_processing_1c', 'order_link', 'order_photo'], 'default', 'value' => null],
[[ 'fake'], 'default', 'value' => 0],
[['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'marketplace_id', 'status_telegram', 'status_processing_1c'], 'integer'],
[['creation_date', 'updated_at', 'returned_at'], 'safe'],
- [['return_data', 'raw_data', 'marketplace_name', 'telegram_error', 'order_link'], 'string'],
+ [['return_data', 'raw_data', 'marketplace_name', 'telegram_error', 'order_link', 'order_photo'], 'string'],
[['total', 'delivery_total', 'buyer_total_before_discount'], 'number'],
[['marketplace_order_id'], 'string', 'max' => 64],
[['number_1c'], 'string', 'max' => 100],
'telegram_error' => 'Ошибка телеграмма',
'status_processing_1c' => 'Статус обработки заказа в 1С',
'order_link' => 'Ссылка на заказ в МП',
+ 'order_photo' => 'Ссылка на фото собранного заказа для МП',
];
}