Files
crm.clientright.ru/income.bak
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

89 lines
5.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include_once 'modules/Users/Users.php';
require_once('include/Webservices/Utils.php');
require_once 'include/Webservices/Create.php';
require_once 'include/Webservices/Revise.php';
require_once 'includes/Loader.php';
require_once 'include/utils/WhatsApp.php';
vimport ('includes.runtime.Globals');
vimport ('includes.runtime.BaseModel');
vimport ('includes.runtime.LanguageHandler');
$str = file_get_contents('php://input'); //Вынимаем пришедшие данные вот таким оригинальным образом
// $str = '{"operationId":"a76cae4c-a9d7-0009-99ac-01dae5bce157","typeOfOperation":"Credit","accountNumber":"40703810900000742816","accountAmount":"5575.39","accountCurrencyDigitalCode":"643","status":"Active","operationStatus":"transaction","bic":"044525974","category":"incomePeople","documentNumber":"984","operationAmount":"5575.39","operationCurrencyDigitalCode":"643","rubleAmount":"5575.39","counterParty":{"account":"40702810010000891412","bankBic":"044525974","corrAccount":"30101810145250000974","inn":"7726381870","kpp":"771401001","name":"ООО \"ГИКБРЕИНС\""},"description":"Взыскание на основании ИЛ ФС №046844960 от 2024-08-20, выданного на основании суд. решения №2-1263/2024 органа Правобережный районный суд г. Магнитогорска от 2024-07-11","authorizationDate":"2024-09-09T07:38:08Z","trxnPostDate":"2024-09-09T07:39:31Z","payVo":"collection-order","cardNumber":"518901******3270","ucid":"1309555210","mcc":"0001","merch":{"id":"SMENOLIM","city":"MOSCOW","country":"RUS"},"acquirerId":"999999","rrn":"007382945495","payPurpose":"Взыскание на основании ИЛ ФС №046844960 от 2024-08-20, выданного на основании суд. решения №2-1263/2024 органа Правобережный районный суд г. Магнитогорска от 2024-07-11","chargeDate":"2024-09-08T21:00:00Z","drawDate":"2024-09-09T07:38:34Z","receiver":{"account":"40703810900000742816","name":"Межрегиональная общественная организация потребителей \"Клуб защиты покупателей \"Клиентправ\"","inn":"9728036753","kpp":"772801001","bic":"044525974","corrAccount":"30101810145250000974","bankName":"АО \"ТБанк\""},"payer":{"account":"40702810010000891412","name":"ООО \"ГИКБРЕИНС\"","inn":"7726381870","kpp":"771401001","bic":"044525974","corrAccount":"30101810145250000974","bankName":"АО \"ТБанк\""},"docDate":"2024-09-08T21:00:00Z","VO":"06"}';
$logstring = date('Y-m-d H:i:s').' '.print_r($str, true).PHP_EOL; // Пишем в лог то, что будем обрабатывать
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
$data = json_decode($str, true); // Формируем массив
$amount = $data['accountAmount'];
$description = $data['description'];
$inn = $data['payer']['inn'];
global $adb;
// Сначала поищем плательщика-контрагента по ИНН
$query = "select a.accountid
from vtiger_account a
left join vtiger_crmentity e on e.crmid = a.accountid
where e.deleted = '0' and a.inn = '".$inn."'";
$qresult = $adb->pquery($query);
if($adb->num_rows($qresult) == 0) {
// Не нашелся Контрагент - поищем Контакт. Причем с извращением - в базе ИННы почему-то хранятся с пробелами
$query = "select c.contactid
from vtiger_contactscf c
left join vtiger_crmentity e on e.crmid = c.contactid
where e.deleted = '0' and replace(c.cf_1257, ' ', '') = '".$inn."'";
$qresult = $adb->pquery($query);
if($adb->num_rows($qresult) == 0) {
// И Контакт по ИНН не найден - Платеж будет без привязки
$logstring = date('Y-m-d H:i:s').' с ИНН '.$inn.' не найден ни Контакт, ни Контрагент - Платеж будет без привязки'.PHP_EOL;
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
} else {
$contactid = $adb->query_result($qresult, 0, 'contactid');
$payer = '12x'.$contactid;
$logstring = date('Y-m-d H:i:s').' Найден Контакт с id = '.$contactid.PHP_EOL;
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
}
} else {
$accountid = $adb->query_result($qresult, 0, 'accountid');
$payer = '11x'.$accountid;
$logstring = date('Y-m-d H:i:s').' Найден Контрагент с id = '.$accountid.PHP_EOL;
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
}
$user = Users::getActiveAdminUser(); // Получаем пользователя, под которым будем создавать платеж
$params = array (
'pay_date' => date('Y-m-d'),
'pay_type' => 'Receipt',
'pay_details' => $description,
'type_payment' => 'Cashless Transfer',
'amount' => $amount,
'spstatus' => 'Executed',
'spcompany' => 'МОО "Клиентправ"',
'assigned_user_id' => '19x1'
);
if (isset($payer)) {
$params['payer'] = $payer;
}
$logstring = date("Y-m-d H:i:s").' Подготовлен массив для создания Платежа: '.json_encode($params).PHP_EOL;
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
try {
$payment = vtws_create('SPPayments', $params, $user);
$output = 'Платеж создан: '.$payment['id'];
} catch (WebServiceException $ex) {
$output = $ex->getMessage();
}
$logstring = date("Y-m-d H:i:s").' '.$output.PHP_EOL;
file_put_contents('logs/income.log', $logstring, FILE_APPEND);
echo "OK";
?>