Revision 492
- Date:
- 2015/05/06 12:26:37
- Files:
-
- /utf8/plugins/payments/lib/payments/Card.pm (Diff) (Checkout)
- /utf8/plugins/payments/lib/payments/CardSection.pm (Diff) (Checkout)
- /utf8/plugins/payments/lib/payments/Init.pm (Diff) (Checkout)
- /utf8/plugins/payments/lib/payments/SQL/CardsTable.pm (Diff) (Checkout)
- /utf8/plugins/payments/sql/TOAST/cards.sql (Diff) (Checkout)
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/payments/lib/payments/Card.pm
1 package payments::Card; 2 3 use base "Contenido::Document"; 4 sub extra_properties 5 { 6 return ( 7 { 'attr' => 'status', 'type' => 'status', 'rusname' => 'Статус карты оплаты', 8 'cases' => [ 9 [0, 'Карта не активна'], 10 [1, 'Карта активна'], 11 [2, 'Истек срок действия карты'], 12 [3, 'Карта заблокирована'], 13 ], 14 }, 15 { 'attr' => 'type', 'type' => 'status', 'rusname' => 'Тип карты оплаты', 16 'cases' => [ 17 [0, 'MasterCard'], 18 [1, 'Visa'], 19 ], 20 }, 21 ) 22 } 23 24 sub class_name 25 { 26 return 'Payments: Банковская карта'; 27 } 28 29 sub class_description 30 { 31 return 'Payments: Карта'; 32 } 33 34 sub class_table 35 { 36 return 'payments::SQL::CardsTable'; 37 } 38 39 1; -
utf8/plugins/payments/lib/payments/CardSection.pm
1 package payments::CardSection; 2 3 use base 'Contenido::Section'; 4 5 sub extra_properties 6 { 7 return ( 8 { 'attr' => 'brief', 'type' => 'text', 'rusname' => 'Описание секции' }, 9 { 'attr' => 'default_document_class', 'default' => 'payments::Card' }, 10 { 'attr' => '_sorted', 'hidden' => 1 }, 11 { 'attr' => 'order_by', 'hidden' => 1 }, 12 ) 13 } 14 15 sub class_name 16 { 17 return 'Payments: Секция карт'; 18 } 19 20 sub class_description 21 { 22 return 'Payments: Секция карт'; 23 } 24 25 1; -
utf8/plugins/payments/lib/payments/Init.pm
1 package payments::Init; 2 3 use strict; 4 use warnings 'all'; 5 6 use Contenido::Globals; 7 use payments::Apache; 8 use payments::Keeper; 9 10 # загрузка всех необходимых плагину классов 11 # payments::SQL::SomeTable 12 # payments::SomeClass 13 Contenido::Init::load_classes(qw( 14 payments::SQL::TransactionsTable 15 payments::Transaction 16 17 payments::SQL::OperationsTable 18 payments::Operation 19 20 payments::TransactionSection 21 22 payments::Provider::Base 23 payments::Provider::Moneta 24 payments::Provider::Xsolla 25 )); 26 27 sub init { 28 push @{ $state->{'available_documents'} }, qw( payments::Transaction payments::Operation ); 29 push @{ $state->{'available_sections'} }, qw( payments::TransactionSection ); 30 0; 31 } 32 33 1; 1 package payments::Init; 2 3 use strict; 4 use warnings 'all'; 5 6 use Contenido::Globals; 7 use payments::Apache; 8 use payments::Keeper; 9 10 # загрузка всех необходимых плагину классов 11 # payments::SQL::SomeTable 12 # payments::SomeClass 13 Contenido::Init::load_classes(qw( 14 payments::SQL::TransactionsTable 15 payments::Transaction 16 17 payments::SQL::OperationsTable 18 payments::Operation 19 20 payments::SQL::CardsTable 21 payments::Card 22 23 payments::TransactionSection 24 25 payments::CardSection 26 27 payments::Provider::Base 28 payments::Provider::Moneta 29 payments::Provider::Xsolla 30 )); 31 32 sub init { 33 push @{ $state->{'available_documents'} }, qw( payments::Transaction payments::Operation payments::Card ); 34 push @{ $state->{'available_sections'} }, qw( payments::TransactionSection payments::CardSection ); 35 0; 36 } 37 38 1; -
utf8/plugins/payments/lib/payments/SQL/CardsTable.pm
1 package payments::SQL::CardsTable; 2 3 use base 'SQL::DocumentTable'; 4 5 sub db_table 6 { 7 return 'payments_cards'; 8 } 9 10 11 sub available_filters { 12 my @available_filters = qw( 13 14 _class_filter 15 _status_filter 16 _in_id_filter 17 _id_filter 18 _name_filter 19 _class_excludes_filter 20 _sfilter_filter 21 _excludes_filter 22 _s_filter 23 24 _uid_filter 25 _number_filter 26 ); 27 28 return \@available_filters; 29 } 30 31 # ---------------------------------------------------------------------------- 32 # Свойства храним в массивах, потому что порядок важен! 33 # Это общие свойства - одинаковые для всех документов. 34 # 35 # attr - обязательный параметр, название атрибута; 36 # type - тип аттрибута, требуется для отображдения; 37 # rusname - русское название, опять же требуется для отображения; 38 # hidden - равен 1, когда 39 # readonly - инициализации при записи только без изменения в дальнейшем 40 # db_field - поле в таблице 41 # default - значение по умолчанию (поле всегда имеет это значение) 42 # ---------------------------------------------------------------------------- 43 sub required_properties 44 { 45 my $self = shift; 46 47 my @parent_properties = grep { $_->{attr} ne 'sections' } $self->SUPER::required_properties; 48 return ( 49 @parent_properties, 50 { 51 'attr' => 'uid', 52 'type' => 'integer', 53 'rusname' => 'Уник профиля пользователя', 54 'db_field' => 'uid', 55 'db_type' => 'integer', 56 'db_opts' => "not null", 57 }, 58 { 59 'attr' => 'number', 60 'type' => 'string', 61 'rusname' => 'Номер карты', 62 'db_field' => 'number', 63 'db_type' => 'text', 64 }, 65 { 66 'attr' => 'month', 67 'type' => 'integer', 68 'rusname' => 'Месяц окончания действия карты', 69 'db_field' => 'month', 70 'db_type' => 'integer', 71 'db_opts' => "not null", 72 }, 73 { 74 'attr' => 'year', 75 'type' => 'integer', 76 'rusname' => 'Год окончания действия карты', 77 'db_field' => 'year', 78 'db_type' => 'integer', 79 'db_opts' => "not null", 80 }, 81 { 82 'attr' => 'cvv_cvc', 83 'type' => 'string', 84 'rusname' => 'Код проверки', 85 'db_field' => 'cvv_cvc', 86 'db_type' => 'text', 87 }, 88 { 89 'attr' => 'type', 90 'type' => 'integer', 91 'rusname' => 'Тип платежной системы', 92 'db_field' => 'type', 93 'db_type' => 'integer', 94 'db_opts' => "not null", 95 }, 96 { 97 'attr' => 'sections', 98 'type' => 'sections_list', 99 'rusname' => 'Секции', 100 'hidden' => 1, 101 'db_field' => 'sections', 102 'db_type' => 'integer', 103 }, 104 ); 105 } 106 107 108 ########### FILTERS DESCRIPTION ############################################################################### 109 sub _s_filter { 110 my ($self,%opts)=@_; 111 return undef unless ( exists $opts{s} ); 112 return &SQL::Common::_generic_int_filter('d.sections', $opts{s}); 113 } 114 115 sub _uid_filter { 116 my ($self,%opts)=@_; 117 return undef unless ( exists $opts{uid} ); 118 return &SQL::Common::_generic_int_filter('d.uid', $opts{uid}); 119 } 120 121 sub _number_filter { 122 my ($self,%opts)=@_; 123 return undef unless ( exists $opts{number} ); 124 return &SQL::Common::_generic_text_filter('d.number', $opts{number}); 125 } 126 127 1; -
utf8/plugins/payments/sql/TOAST/cards.sql
1 create table payments_cards 2 ( 3 id integer not null primary key default nextval('public.documents_id_seq'::text), 4 class text not null, 5 ctime timestamp not null default now(), 6 mtime timestamp not null default now(), 7 status smallint not null default 0, 8 uid integer not null, 9 type integer not null, 10 number text, 11 name text, 12 month integer not null, 13 year integer not null, 14 cvv_cvc text, 15 sections integer not null, 16 data text 17 ); 18 CREATE INDEX payments_cards_number ON payments_cards USING btree (number);