use yii_app\records\CreateChecks2;
use yii_app\records\CreateChecksBags;
use yii_app\records\EmployeeOnShift;
+use yii_app\records\EqualizationRemains;
use yii_app\records\ExportImportTable;
use yii_app\records\Incoming;
use yii_app\records\IncomingItems;
use yii_app\records\Products1cPropType;
use yii_app\records\Products1c;
use yii_app\records\Products1cAdditionalCharacteristics;
+use yii_app\records\ReplacementInvoice;
+use yii_app\records\ReplacementInvoiceProducts;
use yii_app\records\Sales;
use yii_app\records\SalesItems;
use yii_app\records\SalesProducts;
use yii_app\records\SelfCostProduct;
+
//use yii_app\records\SalesProductsUpdate;
use yii_app\records\SalesUpdate;
use yii_app\records\Terminals;
use yii_app\services\InfoLogService;
use yii_app\services\LogService;
-class DataController extends BaseController {
+class DataController extends BaseController
+{
const OUT_DIR =
// __DIR__ . "/../json";
- // "/www/api2/json";
- "/var/www/erp24/api2/json";
+ // "/www/api2/json";
+ "/var/www/erp24/api2/json";
+
// "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
- public function actionRequest() {
+ public function actionRequest()
+ {
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$request = Yii::$app->request->getRawBody();
$mess['create_employee'] = $createEmployeeArray;
}
+ $replacementInvoiceArray = $this->getResortingDoc();
+ $replacementInvoice = $replacementInvoiceArray['replacementInvoice'];
+ $replacementInvoiceResult = $replacementInvoiceArray['replacementInvoiceResult'];
+ $replacementInvoiceIds = $replacementInvoiceArray['replacementInvoiceIds'];
+
+ if (!empty($replacementInvoiceResult)) {
+ $mess['create_write_ons'] = $replacementInvoiceResult;
+ }
+
// $mess['delete_employee'] = [
// ['id' => '06202309-2808-0427-d4c9-100030128795'],
// ['id' => '06202309-2855-0215-4f5d-100043236389']
// ];
} catch (Exception $e) {
- file_put_contents(self::OUT_DIR . '/request_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e->getMessage(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/request_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage(), FILE_APPEND);
} finally {
$jsonArray = [];
$apiCron = ApiCron::find()->where(['status' => 0])->orderBy(['date' => SORT_ASC])->one();
if (!empty($waybillIncomingIds) && !empty($waybillIncoming)) {
$this->getWaybillIncomingSetStatusSend($waybillIncomingIds);
}
+ if (!empty($replacementInvoiceIds) && !empty($replacementInvoice)) {
+ $this->getReplacementInvoiceSetStatusSend($replacementInvoiceIds);
+ }
$json = json_encode($mess, JSON_UNESCAPED_UNICODE);
}
//
return $this->asJson(json_decode($json, true));
}
- private function getWriteOffsSetStatusSend($writeOffIds) {
+ private function getWriteOffsSetStatusSend($writeOffIds)
+ {
try {
$writeOffsErp = WriteOffsErp::find()->where(['in', 'id', $writeOffIds])->all();
foreach ($writeOffsErp as $writeOffsErpElem) {
}
}
} catch (Exception $e3) {
- file_put_contents(self::OUT_DIR . '/log_created_write_offs_erp_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e3->getMessage(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/log_created_write_offs_erp_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage(), FILE_APPEND);
}
}
- private function getWaybillIncomingSetStatusSend($waybillIncomingIds) {
+ private function getWaybillIncomingSetStatusSend($waybillIncomingIds)
+ {
try {
$waybillIncoming = WaybillIncoming::find()->where(['in', 'id', $waybillIncomingIds])->all();
foreach ($waybillIncoming as $waybillIncomingElem) {
}
}
} catch (Exception $e3) {
- file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e3->getMessage(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage(), FILE_APPEND);
+ }
+ }
+
+ private function getReplacementInvoiceSetStatusSend($replacementInvoiceIds)
+ {
+ try {
+ $replacementInvoice = ReplacementInvoice::find()->where(['in', 'id', $replacementInvoiceIds])->all();
+ foreach ($replacementInvoice as $replacementInvoiceElem) {
+ $replacementInvoiceElem->status = WriteOffsErp::STATUS_SEND;
+ $replacementInvoiceElem->send_at = date('Y-m-d H:i:s');
+ $replacementInvoiceElem->save();
+ if ($replacementInvoiceElem->getErrors()) {
+ LogService::apiErrorLog(json_encode(["error_id" => 2.5, "error" => $replacementInvoiceElem->getErrors()], JSON_UNESCAPED_UNICODE));
+ }
+ }
+ } catch (Exception $e3) {
+ file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage(), FILE_APPEND);
}
}
- private function getWriteOffsDoc() : array
+ private function getWriteOffsDoc(): array
{
$writeOff = [];
$writeOffIds = [];
$writeOffProducts[$product['write_offs_erp_id']][] = [
'product_id' => $product['product_id'],
// 'color' => '',
- 'quantity' => (string) $product['quantity'],
+ 'quantity' => (string)$product['quantity'],
'price' => $product['price'],
];
}
}
} catch (Exception $e3) {
- file_put_contents(self::OUT_DIR . '/log_created_write_offs_erp_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e3->getMessage(). ' file: '. $e3->getFile() . ' line: '. $e3->getLine(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/log_created_write_offs_erp_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage() . ' file: ' . $e3->getFile() . ' line: ' . $e3->getLine(), FILE_APPEND);
}
return [
];
}
- private function getWaybillIncomingDoc() : array {
+ private function getWaybillIncomingDoc(): array
+ {
$waybillIncoming = [];
$waybillIncomingIds = [];
$waybillIncomingResult = [];
foreach ($products as $product) {
$waybillIncomingProducts[$product['waybill_incoming_id']][] = [
'product_id' => $product['product_id'],
- 'quantity' => (string) $product['product_count'],
+ 'quantity' => (string)$product['product_count'],
'price' => $product['product_price'],
];
}
}
} catch (Exception $e3) {
- file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e3->getMessage(). ' file: '. $e3->getFile() . ' line: '. $e3->getLine(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage() . ' file: ' . $e3->getFile() . ' line: ' . $e3->getLine(), FILE_APPEND);
}
return compact('waybillIncoming', 'waybillIncomingIds');
}
- private function getCreateEmployee() : array {
+
+ private function getResortingDoc(): array
+ {
+ $replacementInvoice = [];
+ $replacementInvoicesIds = [];
+ $replacementInvoiceResult = [];
+
+ try {
+ $replacementInvoice = ReplacementInvoice::find()
+ ->select(['id', 'guid', 'shift_transfer_id', 'store_guid', 'number', 'date', 'comment', 'quantity', 'summ'])
+ ->andWhere(['status' => WriteOffsErp::STATUS_CONFIRM])
+ ->indexBy('id')
+ ->asArray()
+ ->all();
+
+ if (!empty($replacementInvoice)) {
+ $replacementInvoicesIds = array_column($replacementInvoice, 'id');
+ $shiftTransferIds = array_column($replacementInvoice, 'shift_transfer_id');
+
+ $products = EqualizationRemains::find()
+ ->where(['in', 'shift_transfer_id', $shiftTransferIds])
+ ->asArray()
+ ->all();
+
+ $replacementInvoiceProducts = [];
+
+ foreach ($products as $product) {
+ $replacementInvoiceProducts[$product['']][] = [
+ 'product_id' => $product->product_id,
+ 'color' => Products1cAdditionalCharacteristics::findOne([
+ 'property_id' => '5880b25c-809f-11ef-84ea-ac1f6b1b7573',
+ 'product_id' => $product->product_id])->value ?? '',
+ 'price' => $product->product_price,
+ 'new_product_id' => $product->product_replacement_id,
+ 'new_color' => Products1cAdditionalCharacteristics::findOne([
+ 'property_id' => '5880b25c-809f-11ef-84ea-ac1f6b1b7573',
+ 'product_id' => $product->product_replacement_id])->value ?? '',
+ 'new_price' => $product->product_replacement_price,
+ 'quantity' => $product->product_replacement_count,
+ ];
+ }
+
+ $replacementInvoiceTemp = $replacementInvoice;
+ foreach ($replacementInvoiceTemp as $key => $row) {
+ $replacementInvoiceProductsRow = [];
+ if (!isset($replacementInvoice[$key]['items'])) {
+ $replacementInvoice[$key]['items'] = [];
+ }
+ if (array_key_exists($row['id'], $replacementInvoiceProducts)) {
+ $replacementInvoiceProductsRow = $replacementInvoiceProducts[$row['id']];
+ }
+ if (!empty($replacementInvoiceProductsRow)) {
+ $replacementInvoice[$key]['items'][] = $replacementInvoiceProductsRow;
+ }
+ }
+
+ foreach ($replacementInvoice as $row) {
+ $replacementInvoiceResult[] = [
+ 'id' => $row['guid'],
+ 'store_id' => $row['store_guid'],
+ 'type' => 'ревизия при передаче смены',
+ 'cause' => 'Документ пересортицы при передаче смены в ERP ' . $row['number'],
+ 'items' => $row['items'],
+ 'summ' => $row['summ'],
+ 'comment' => $row['comment'],
+ ];
+ }
+ }
+
+ } catch (Exception $e3) {
+ file_put_contents(self::OUT_DIR . '/log_created_replacement_invoice_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage() . ' file: ' . $e3->getFile() . ' line: ' . $e3->getLine(), FILE_APPEND);
+ }
+
+ return compact('replacementInvoice', 'replacementInvoicesIds', 'replacementInvoiceResult');
+ }
+
+
+ private function getCreateEmployee(): array
+ {
$employeeOnShiftArray = EmployeeOnShift::find()
->where([
'status' => EmployeeOnShift::STATUS_ACCEPT,
return $result;
}
- public function actionUpload() {
+ public function actionUpload()
+ {
set_time_limit(600);
file_put_contents(self::OUT_DIR . '/a2_upload_in.json', PHP_EOL . date('Y-m-d H:i:s') . ' ', FILE_APPEND | LOCK_EX);
$mess = [];
if (!empty($result['error'])) {
file_put_contents(self::OUT_DIR . '/error_upload.txt',
- PHP_EOL . json_encode($result["error"],JSON_UNESCAPED_UNICODE), FILE_APPEND);
+ PHP_EOL . json_encode($result["error"], JSON_UNESCAPED_UNICODE), FILE_APPEND);
}
$mess["result"] = true;
$checks_dell = "";
// if (!empty($arr["name"]) && in_array($arr["name"][0], ['ь', 'Ь', 'ъ', 'Ъ'])) { // Не вносим номенклатуру, помеченную на удаление
// continue;
// }
- $components = !empty($arr["components"]) ? json_encode($arr["components"],JSON_UNESCAPED_UNICODE) : ""; // Пустые компоненты не надо разворачивать в json объект
+ $components = !empty($arr["components"]) ? json_encode($arr["components"], JSON_UNESCAPED_UNICODE) : ""; // Пустые компоненты не надо разворачивать в json объект
$products1c6 = Products1c::find()->where(['id' => $arr["id"]])->one();
if (!$products1c6) {
$products1c6 = new Products1c;
$propertyType->name = $characteristic["name"];
if (!$propertyType->save()) {
LogService::apiErrorLog(json_encode(["error_id" => 8.1,
- "error" => $propertyType->getErrors()],
- JSON_UNESCAPED_UNICODE));
+ "error" => $propertyType->getErrors()],
+ JSON_UNESCAPED_UNICODE));
continue;
}
}
if ($paymentTypes->getErrors()) {
LogService::apiErrorLog(json_encode(
["error_id" => 9,
- "error" => $paymentTypes->getErrors()],
+ "error" => $paymentTypes->getErrors()],
JSON_UNESCAPED_UNICODE
));
}
self::OUT_DIR . '/created_write_offs_upload_'
. date("Y_m_d") . '.json',
PHP_EOL
- . json_encode($result["created_write_offs"],JSON_UNESCAPED_UNICODE),
+ . json_encode($result["created_write_offs"], JSON_UNESCAPED_UNICODE),
FILE_APPEND
);
foreach ($result["created_write_offs"] as $arr) {
LogService::apiErrorLog(
json_encode(
["error_id" => 11,
- "error" => $writeOffsErp->getErrors()],
+ "error" => $writeOffsErp->getErrors()],
JSON_UNESCAPED_UNICODE
)
);
}
}
- if (!empty($result['write_offs'])) {
- if (!empty($start_time) and !empty($end_time)) {
+ if (!empty($result['write_offs'])) {
+ if (!empty($start_time) and !empty($end_time)) {
if ($update) {
WriteOffs::deleteAll(['and', ['>=', 'date', $start_time], ['<=', 'date', $end_time]]);
}
}
}
- file_put_contents(self::OUT_DIR . '/write_offs.json', PHP_EOL . json_encode($result["write_offs"],JSON_UNESCAPED_UNICODE));
+ file_put_contents(self::OUT_DIR . '/write_offs.json', PHP_EOL . json_encode($result["write_offs"], JSON_UNESCAPED_UNICODE));
$writeOffs = WriteOffs::find()->where(['id' => $arr["id"]])->one();
if ($writeOffs) {
$writeOffs2->type = $arr["type"];
$writeOffs2->cause = $arr["cause"] ?? "";
$writeOffs2->comment = $arr["comment"] ?? "";
- $writeOffs2->items = json_encode($arr["items"],JSON_UNESCAPED_UNICODE);
+ $writeOffs2->items = json_encode($arr["items"], JSON_UNESCAPED_UNICODE);
$writeOffs2->summ = $arr["summ"];
$writeOffs2->save();
if ($writeOffs2->getErrors()) {
LogService::apiErrorLog(json_encode(["error_id" => 12, "error" => $writeOffs2->getErrors()], JSON_UNESCAPED_UNICODE));
}
- foreach ($arr["items"] as $j2 => $mass2) {
+ foreach ($arr["items"] as $j2 => $mass2) {
$writeOffsProducts = WriteOffsProducts::findOne([
'write_offs_id' => $arr["id"],
'product_id' => $mass2['product_id'],
}
}
- if (!empty($checks_dell) and !empty($start_time) and !empty($end_time)) {
+ if (!empty($checks_dell) and !empty($start_time) and !empty($end_time)) {
if ($update) {
Sales::updateAll(['operation' => 'Удален'], ['and', ['>=', 'date', $start_time], ['<=', 'date', $end_time]]);
}
// SalesUpdate::updateAll(['operation' => 'Удален'], ['and', ['>=', 'date', $start_time], ['<=', 'date', $end_time]]);
- file_put_contents(self::OUT_DIR . '/check_dell.txt', PHP_EOL . date("d.m.Y H:i:s",time()). " regquest_id=$requestId Удаление $start_time - $end_time ", FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/check_dell.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . " regquest_id=$requestId Удаление $start_time - $end_time ", FILE_APPEND);
}
$matrixProductsIds = [];
$matrixProductsIds = SalaryHelper::getMatrixProductsIds();
}
- if (!empty($result['checks']) && count($result['checks']) < 1000) {
+ if (!empty($result['checks']) && count($result['checks']) < 1000) {
foreach ($result["checks"] as $arr) {
$sales2->terminal_id = $arr["terminal_id"] ?? '';
$sales2->date_up = date('Y-m-d H:i:s');
$sales2->skidka = $arr["discount"] ?? '0';
- $sales2->delivery_date = date('Y-m-d',strtotime($arr['delivery_date'] ?? ''));
+ $sales2->delivery_date = date('Y-m-d', strtotime($arr['delivery_date'] ?? ''));
$sales2->pickup = $arr['pickup'] ?? false;
$sales2->save();
if ($sales2->getErrors()) {
}
} elseif (!empty($result['checks'])) {
file_put_contents(self::OUT_DIR . '/error_upload.txt',
- PHP_EOL . "elseif" , FILE_APPEND);
+ PHP_EOL . "elseif", FILE_APPEND);
$dataArrayValues = $this->getSalesDate($result["checks"], $update);
foreach ($dataArrayValues as $keyMethodName => $rowValue) {
file_put_contents(self::OUT_DIR . '/error_upload.txt',
- PHP_EOL . $keyMethodName , FILE_APPEND);
+ PHP_EOL . $keyMethodName, FILE_APPEND);
try {
$this->$keyMethodName($rowValue, $update);
} catch (Exception $e) {
$errorString = substr($e->getMessage(), 0, 2000);
- InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString , 'error_id_25_m_st');
+ InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString, 'error_id_25_m_st');
}
}
}
}
try {
$pricesDynamic = PricesDynamic::find()->where(['product_id' => $idp])->andWhere(['active' => '1'])->orderBy(['id' => SORT_DESC])->one();
- $price = round($price,2);
+ $price = round($price, 2);
// если нет записи или цена изменилась то вносим запись в БД
if ($pricesDynamic and $pricesDynamic->price != $price) {
$pricesDynamic->active = 0;
LogService::apiErrorLog(json_encode(["error_id" => 28, "error" => $pricesDynamic->getErrors()], JSON_UNESCAPED_UNICODE));
}
}
- if (!$pricesDynamic or ($pricesDynamic and $pricesDynamic->price != $price)) {
+ if (!$pricesDynamic or ($pricesDynamic and $pricesDynamic->price != $price)) {
$pricesDynamic2 = new PricesDynamic;
$pricesDynamic2->product_id = $idp;
$pricesDynamic2->price = $price;
}
}
} catch (Exception $e) {
- file_put_contents(self::OUT_DIR . '/log_prices_dinamics.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e->getMessage(), FILE_APPEND);
+ file_put_contents(self::OUT_DIR . '/log_prices_dinamics.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage(), FILE_APPEND);
}
}
}
if ($priceZakup->getErrors()) {
LogService::apiErrorLog(json_encode(["error_id" => 30, "error" => $priceZakup->getErrors()], JSON_UNESCAPED_UNICODE));
}
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
}
if (!empty($price) and $type_price == "Себестоимость") {
- try{
- file_put_contents(self::OUT_DIR . '/price_purchese.txt', PHP_EOL . "$idp=".$price, FILE_APPEND);
- } catch (Exception $e) { }
+ try {
+ file_put_contents(self::OUT_DIR . '/price_purchese.txt', PHP_EOL . "$idp=" . $price, FILE_APPEND);
+ } catch (Exception $e) {
+ }
}
}
}
if (!empty($result['created_checks'])) {
foreach ($result["created_checks"] as $idp => $arr2) {
if (!empty($arr2["error"])) { // Если есть ошибки
- // // обновляем GUID на новый
+ // // обновляем GUID на новый
// try {
// $createChecks = CreateChecks::find()->select(['order_id'])->where(['check_id' => $arr2["id"]])->one();
// if ($createChecks) {
// file_put_contents(self::OUT_DIR . '/log_created_check_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e->getMessage(), FILE_APPEND);
// }
- $txt= date("d.m.Y H:i:s",time()) . " $idp СОЗДАНИЕ ЧЕКА ОШИБКА id=" . $arr2["id"] . " " . $arr2["error"];
+ $txt = date("d.m.Y H:i:s", time()) . " $idp СОЗДАНИЕ ЧЕКА ОШИБКА id=" . $arr2["id"] . " " . $arr2["error"];
file_put_contents(self::OUT_DIR . '/log_created_check_error.txt', PHP_EOL . $txt, FILE_APPEND);
} else { // Если ошибок нет
if (/* $arr2["held"] == true and */ !empty($arr2["name"]) and !empty($arr2["id"])) { // Если заполнен name b 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);
+ 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 {
LogService::apiDataLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE), $requestIdText);
}
return $pay_arr;
}
- private function getSalesDate($checks, $update): array
+ private function getSalesDate($checks, $update): array
{
$admins = $this->getEntityByType('admin');
return $result;
}
- private function getEntityByType($entity = 'city_store') {
+ private function getEntityByType($entity = 'city_store')
+ {
return ExportImportTable::find()->select(['entity_id', 'export_val'])->where(['entity' => $entity])
->andWhere(['export_id' => 1])->andWhere(['!=', 'export_val', ''])->asArray()->all();
}
- private function deleteSales($ids, $update) {
+ private function deleteSales($ids, $update)
+ {
if (!empty($ids)) {
SalesUpdate::deleteAll(['in', 'id', $ids]);
// SalesProductsUpdate::deleteAll(['in', 'check_id', $ids]);
}
}
- private function setSales($values) {
+ private function setSales($values)
+ {
$columns = [
'phone',
'id',
$this->insertDataSales($values, 'sales', $columns);
}
- private function setSalesProducts($values) {
+ private function setSalesProducts($values)
+ {
$columns = [
'type_id',
'check_id',
$this->insertDataSales($values, 'sales_products', $columns);
}
- private function setSalesProductsComponents($values) {
+ private function setSalesProductsComponents($values)
+ {
$columns = [
'type_id',
'check_id',
// }
- private function setSelfCostUpdate($values) {
+ private function setSelfCostUpdate($values)
+ {
$columns = [
'date',
];
-
$this->insertDataSales($values, 'self_cost_product', $columns, 4000);
}
+ private function insertDataSales($values, $tableName, $columns, $chunks = 1000)
+ {
+ $chunkValues = array_chunk($values, $chunks);
- private function insertDataSales($values, $tableName, $columns, $chunks = 1000 ) {
- $chunkValues = array_chunk($values, $chunks);
-
- foreach ($chunkValues as $key => $rows) {
+ foreach ($chunkValues as $key => $rows) {
- try {
- $transaction = \Yii::$app->db->beginTransaction();
- Yii::$app->db->createCommand()->batchInsert($tableName, $columns, $rows)->execute();
- $transaction->commit();
- } catch (Exception $e) {
- $errorString = substr($e->getMessage(), 0, 2000);
- file_put_contents(self::OUT_DIR . '/error_upload.txt',
- PHP_EOL . $errorString, FILE_APPEND);
- $transaction->rollBack();
- InfoLogService::setInfoLog(__FILE__, __LINE__, $tableName , 'error_id_25');
- InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString , 'error_id_25_22');
- LogService::apiErrorLog(json_encode(["error_id" => 25, "error" => $errorString], JSON_UNESCAPED_UNICODE));
+ try {
+ $transaction = \Yii::$app->db->beginTransaction();
+ Yii::$app->db->createCommand()->batchInsert($tableName, $columns, $rows)->execute();
+ $transaction->commit();
+ } catch (Exception $e) {
+ $errorString = substr($e->getMessage(), 0, 2000);
+ file_put_contents(self::OUT_DIR . '/error_upload.txt',
+ PHP_EOL . $errorString, FILE_APPEND);
+ $transaction->rollBack();
+ InfoLogService::setInfoLog(__FILE__, __LINE__, $tableName, 'error_id_25');
+ InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString, 'error_id_25_22');
+ LogService::apiErrorLog(json_encode(["error_id" => 25, "error" => $errorString], JSON_UNESCAPED_UNICODE));
+ }
}
}
- }
}