class NotificationController extends Controller
{
+ const OUT_DIR =
+ //"/www/media/notification";
+ "/var/www/erp24/media/notification";
public function actionTest()
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
*/
$rawBody = Yii::$app->request->getRawBody();
+ file_put_contents(
+ self::OUT_DIR . '/notifications.json',
+ PHP_EOL . date('Y-m-d H:i:s') . ' ' . $rawBody,
+ FILE_APPEND
+ );
try {
$data = Json::decode($rawBody);
} catch (\Exception $e) {
Yii::error("Ошибка декодирования JSON: " . $e->getMessage());
Yii::$app->response->statusCode = 400;
+ file_put_contents(
+ self::OUT_DIR . '/notification_error.txt',
+ PHP_EOL . date("d.m.Y H:i:s", time()) . " " . $e->getMessage() . $e->getLine(),
+ FILE_APPEND
+ );
return $this->asJson([
'error' => [
'type' => 'WRONG_EVENT_FORMAT',
$returnedAt = $orderReturnData['returnedAt'];
} catch (\Exception $e) {
Yii::$app->response->statusCode = 400;
+ file_put_contents(
+ self::OUT_DIR . '/notification_error.txt',
+ PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(),
+ FILE_APPEND
+ );
return $this->asJson([
'error' => [
'type' => 'WRONG_EVENT_FORMAT',
default:
Yii::info("Неизвестный тип события: {$eventType}");
+ file_put_contents(
+ self::OUT_DIR . '/notification_error.txt',
+ PHP_EOL . date("d.m.Y H:i:s", time()) . " Неизвестный тип события: {$eventType}",
+ FILE_APPEND
+ );
return $this->asJson([
'success' => true,
'message' => 'Unknown event ignored'
}
} catch (\Exception $e) {
Yii::error("Error processing event {$eventType}: " . $e->getMessage());
+ file_put_contents(
+ self::OUT_DIR . '/notification_error.txt',
+ PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(),
+ FILE_APPEND
+ );
Yii::$app->response->statusCode = 500;
return $this->asJson([
'error' => [