Интеграция с СОРМ 3 Январь компании МФИ СОРМ

Ключ
Эта строка удалена.
Это слово было удалено. Это слово было добавлено.
Эта строка добавлена.

Изменения (1)

просмотр истории страницы
{code}

h2. Структура отчёта PAYMENT
{code}select
--fo.op_id || ';' || fo.abonent_id || ';' || -- для дебага
a.operator_id || ';' || --region_id
case
when (fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) not like '%OSMP%') then '80' --80 - через банковский перевод
when (fo.descr like 'Карта оплаты %') then '81' --81 - через карты экспресс-оплаты
when (fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) like '%OSMP%') then '82' --82 - через терминалы моментальных платежей
when (fo.is_cash=1 and fo.descr containing 'Вебкасса. Пользователь: ') then '83' --83 - через центры обслуживания клиентов
when fo.descr like 'Перевод от другого абонента через ЛК%' then '84' --84 - посредством снятия денег со счета другого абонента
else '86' --86 - если невозможно определить тип платежа, но является пополнением баланса
end || ';' || -- payment_type
'1' || ';' || -- pay_type_id - для связи с отчетом pay_type
left(cast(fo.system_date as varchar(32)),19) || ';' || --payment_date
cast(fo.op_summa/10000000000.00 as varchar(32)) || ';' || --amount
cast((fo.op_summa*fo.curs)/10000000000.00 as varchar(32)) || ';' || --amount_CURRENCY
coalesce(a.sms,'') || ';' || --phone_number
fo.account_id || ';' || --account
fo.abonent_id || ';;' || --internal_id1 internal_id2 (пустой)
iif(fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) not like '%OSMP%',coalesce(b_acc.attribute_value,''),'') || ';' || --bank_account
iif(fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) not like '%OSMP%',coalesce(b_name.attribute_value,''),'') || ';' ||--bank_name
iif(fo.descr like 'Карта оплаты %', substring(fo.descr from 14 for (position('.', fo.descr)-14)),'') || ';' || --express_card_number
';;;;;' || --terminal_id--terminal_number --latitude --longitude --projection_type
a.operator_id || ';' || --center_id идентификатор центра обслуживания клиентов
coalesce(a_don.sms,'') || ';' || --donated_phone_number
coalesce(a_don.account_id,'') || ';' || --donated_account
coalesce(a_don.id,'') || ';;' || --donated_internal_id1 --donated_internal_id2
';;;;;' || --card_number --pay_params --person_recieved --bank_division_name --bank_card_id
iif(
(fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) not like '%OSMP%')
or (fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) like '%OSMP%')
or (fo.is_cash=1 and fo.descr containing 'Вебкасса. Пользователь: '),
'0;0',
';'
) || ';' || --address_type_id --address_type если --payment_type in (80,82,83)
coalesce(h.zip_code,'') || ';' || --zip
coalesce(h.country,'') || ';' ||--country
coalesce(h.region,'') || ';' ||--region
coalesce(h.district,'') || ';' ||--zone
coalesce(h.city,'') || ';' ||--city
coalesce(h.street,'') || ';' ||--street
coalesce(h.s_number,'') || ';' ||--building
coalesce(h.s_liter,'') || ';' ||--build_sect
coalesce(a.a_home_number,'') || ';' || --apartment
'' --unstruct_info
from finance_operations fo
join abonents a on fo.abonent_id=a.id -- чтобы узнать абонента
left join homes h on a.home_id=h.id -- получаем адрес абонента для --address_type_id --address_type
left join attribute_values b_acc on b_acc.attribute_id=6 and b_acc.abonent_id=fo.abonent_id -- банковский счет абонента
left join attribute_values b_name on b_acc.attribute_id=7 and b_acc.abonent_id=fo.abonent_id -- наименование банка абонента
--left join abonents a_perevod on a_perevod.contract_number=substring(fo.descr from 39 for (position(' (', fo.descr))-39) and fo.descr like '%Перевод от другого абонента через ЛК%'
left join finance_operations fo_don on fo.related_fin_op_id=fo_don.op_id and fo.descr like '%Перевод от другого абонента через ЛК%' -- для --payment_type=86 (переводов денег между абонентами)
left join abonents a_don on fo_don.abonent_id=a_don.id -- для payment_type=86 (переводов денег между абонентами)
where
fo.op_type=2{code}

h2. Структура отчета BANK_TRANSFER
{code}select
--fo.op_id || ';' || fo.abonent_id || ';' || -- для дебага
'80;' ||--PAYMENT_TYPE Код вида платежа пополнений банковским переводом
'1;' || --PAY_TYPE_ID
left(cast(fo.system_date as varchar(32)),19) || ';' ||--PAYMENT_DATE
cast(fo.op_summa/10000000000.00 as varchar(32)) || ';' || --AMOUNT
cast((fo.op_summa*fo.curs)/10000000000.00 as varchar(32)) || ';' || --AMOUNT _CURRENCY
coalesce(a.sms,'') || ';' ||--PHONE_NUMBER
fo.account_id || ';' || --ACCOUNT
fo.abonent_id || ';;' || --INTERNAL_ID1 --INTERNAL_ID2 (пустой)
coalesce(b_acc.attribute_value,'') || ';' ||--BANK_ACCOUNT
coalesce(b_name.attribute_value,'') || ';' || --BANK_NAME
';;' || --PAY_PARAMS
'0;0;' || --ADDRESS_TYPE_ID --ADDRESS_TYPE
coalesce(h.zip_code,'') || ';' || --zip
coalesce(h.country,'') || ';' ||--country
coalesce(h.region,'') || ';' ||--region
coalesce(h.district,'') || ';' ||--zone
coalesce(h.city,'') || ';' ||--city
coalesce(h.street,'') || ';' ||--street
coalesce(h.s_number,'') || ';' ||--building
coalesce(h.s_liter,'') || ';' ||--build_sect
coalesce(a.a_home_number,'') || ';' || --apartment
';;' || --ADDRESS_UNSTRUCT
a.operator_id --REGION_ID
from finance_operations fo
join abonents a on fo.abonent_id=a.id -- чтобы узнать абонента
left join homes h on a.home_id=h.id -- получаем адрес абонента для --address_type_id --address_type
left join attribute_values b_acc on b_acc.attribute_id=6 and b_acc.abonent_id=fo.abonent_id -- банковский счет абонента
left join attribute_values b_name on b_acc.attribute_id=7 and b_acc.abonent_id=fo.abonent_id -- наименование банка абонента
where
fo.op_type=2 and
(fo.operator_id is not null and fo.operator_id<>'' and upper(fo.operator_id) not like '%OSMP%'){code}

h1. Автоматическая выгрузка
{info}Для автоматического выполнения скрипта должна быть создана структура каталогов в контейнере asr_billing следующего формата: /cfg/sorm3/data/done/{info}