use yii\console\ExitCode;
use yii\helpers\ArrayHelper;
use yii\helpers\BaseConsole;
+use yii_app\records\MarketplaceOrders;
use yii_app\records\MarketplaceStore;
use yii_app\records\MatrixErp;
use yii_app\records\Products1c;
return $options;
}
+ // php yii marketplace/fix-json-encoding
+ public function actionFixJsonEncoding() {
+ $yandexOrders = MarketplaceOrders::find()
+ ->where(['marketplace_id' => 2])
+ ->all();
+ foreach ($yandexOrders as $yandexOrder) {
+ $rawJsonString = $yandexOrder->raw_data;
+ $decoded = json_decode($rawJsonString, true);
+
+ if (json_last_error() !== JSON_ERROR_NONE) {
+ Yii::error(json_last_error_msg());
+ $this->stdout(
+ "Ошибка декодирования.\n",
+ BaseConsole::FG_RED
+ );
+ continue;
+ }
+
+ $encoded = json_encode($decoded, JSON_UNESCAPED_UNICODE);
+ $yandexOrder->raw_data = $encoded;
+ $yandexOrder->save();
+ if($yandexOrder->getErrors()) {
+ Yii::error(json_encode($yandexOrder->getErrors(), JSON_UNESCAPED_UNICODE));
+ $this->stdout(
+ "Ошибка сохранения.\n",
+ BaseConsole::FG_RED
+ );
+ }
+ }
+ return ExitCode::OK;
+ }
+
}
\ No newline at end of file
$substatusId = $statuses[$substatusCode];
}
- $newRawData = json_encode($order);
+ $newRawData = json_encode($order, JSON_UNESCAPED_UNICODE);
$marketplaceOrder = MarketplaceOrders::find()
->where(['marketplace_order_id' => (string)$order->getId()])
->one();
$orderItem->shop_sku = $item->getShopSku();
$orderItem->subsidy = $item->getSubsidy();
$orderItem->partner_warehouse_id = $item->getPartnerWarehouseId();
- $orderItem->promos = json_encode($item->getPromos());
- $orderItem->subsidies = json_encode($item->getSubsidies());
+ $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
+ $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
if (!$orderItem->save()) {
Yii::error(
$orderItem->shop_sku = $item->getShopSku();
$orderItem->subsidy = $item->getSubsidy();
$orderItem->partner_warehouse_id = $item->getPartnerWarehouseId();
- $orderItem->promos = json_encode($item->getPromos());
- $orderItem->subsidies = json_encode($item->getSubsidies());
+ $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
+ $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
if (!$orderItem->save()) {
Yii::error(
'shop_sku' => $item->getShopSku(),
'subsidy' => $item->getSubsidy(),
'partner_warehouse_id' => $item->getPartnerWarehouseId(),
- 'promos' => json_encode($item->getPromos()),
- 'subsidies' => json_encode($item->getSubsidies()),
+ 'promos' => json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE),
+ 'subsidies' => json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE),
];
foreach ($fields as $attr => $value) {
$orderItem->shop_sku = $item->getShopSku();
$orderItem->subsidy = $item->getSubsidy();
$orderItem->partner_warehouse_id = $item->getPartnerWarehouseId();
- $orderItem->promos = json_encode($item->getPromos());
- $orderItem->subsidies = json_encode($item->getSubsidies());
+ $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
+ $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
if (!$orderItem->save()) {
Yii::error(
list($returnResponse) = $returnsApi->getReturnWithHttpInfo($campaignId, $orderId, $returnId, $contentType);
$returnResult = $returnResponse->getResult();
$returnedAt = $returnResult->getCreationDate();
- $rawReturnData = json_encode($returnResponse);
+ $rawReturnData = json_encode($returnResponse , JSON_UNESCAPED_UNICODE);
return [
'returnedAt' => $returnedAt,
'rawReturnData' => $rawReturnData,
if ($email->save()) {
return $email;
} else {
- Yii::error('Письмо не сохранено' . json_encode($email->errors), __METHOD__);
+ Yii::error('Письмо не сохранено' . json_encode($email->errors, JSON_UNESCAPED_UNICODE), __METHOD__);
return null;
}
}