From: Alexander Smirnov Date: Thu, 27 Feb 2025 12:06:52 +0000 (+0300) Subject: [ERP-327] new orders for 1c X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=e1495efcf0ed8ad425f1755a9713fe5e0d105d7d;p=erp24_rep%2Fyii-erp24%2F.git [ERP-327] new orders for 1c --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 60e821c4..56dd6587 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -24,6 +24,7 @@ use yii_app\records\EqualizationRemains; use yii_app\records\ExportImportTable; use yii_app\records\Incoming; use yii_app\records\IncomingItems; +use yii_app\records\MarketplaceOrders; use yii_app\records\OrdersAmo; use yii_app\records\PaymentTypes; use yii_app\records\Prices; @@ -171,6 +172,11 @@ class DataController extends BaseController $mess['create_resortings'] = $replacementInvoiceResult; } + $onlyNewOrdersArray = $this->getMarketplaceNewOrders(); + if (!empty($onlyNewOrdersArray)) { + $mess['create_new_orders'] = $onlyNewOrdersArray; + } + // $mess['delete_employee'] = [ // ['id' => '06202309-2808-0427-d4c9-100030128795'], // ['id' => '06202309-2855-0215-4f5d-100043236389'] @@ -676,6 +682,47 @@ class DataController extends BaseController return $result; } + private function getMarketplaceNewOrders(): array { + $marketplaceOrders = MarketplaceOrders::find() + ->where([ + 'status_1c' => 1, + 'status_id' => 1, + ])->andWhere([ + 'between', + 'creation_date', + date('Y-m-d 00:00:00', strtotime('-3 days', time())), + date('Y-m-d 23:59:59', time()) + ]) + ->all(); + $result = []; + foreach ($marketplaceOrders as $marketplaceOrder) { + /* @var MarketplaceOrders $marketplaceOrder */ + $result[] = [ + 'id' => $marketplaceOrder->guid, + 'marketplace_order_id' => $marketplaceOrder->marketplace_order_id, + 'store_id' => $marketplaceOrder->store_id, + 'status_id' => $marketplaceOrder->status_id, + 'substatus_id' => $marketplaceOrder->substatus_id, + 'warehouse_guid' => $marketplaceOrder->warehouse_guid, + 'creation_date' => $marketplaceOrder->creation_date, + 'updated_at' => $marketplaceOrder->updated_at, + 'returned_at' => $marketplaceOrder->returned_at, + 'return_data' => $marketplaceOrder->return_data, + 'fake' => $marketplaceOrder->fake, + 'total' => $marketplaceOrder->total, + 'delivery_total' => $marketplaceOrder->delivery_total, + 'buyer_total_before_discount' => $marketplaceOrder->buyer_total_before_discount, + 'tax_system' => $marketplaceOrder->tax_system, + 'payment_type' => $marketplaceOrder->payment_type, + 'payment_method' => $marketplaceOrder->payment_method, + 'cancel_requested' => $marketplaceOrder->cancel_requested, + 'raw_data' => $marketplaceOrder->raw_data, + ]; + } + return $result; + } + + public function actionUpload() { set_time_limit(600); @@ -2089,6 +2136,12 @@ class DataController extends BaseController } } + if (!empty($result['created_new_orders'])) { + foreach ($result['created_new_orders'] as $arr) { + MarketplaceOrders::updateAll(['status_1c' => 2], ['guid' => $arr['id']]); + } + } + } catch (Exception $e) { file_put_contents(self::OUT_DIR . '/log_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . " " . $e->getLine(), FILE_APPEND); } finally {