Revision 854
- Date:
- 2026/08/25 21:37:05
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/webshop/lib/webshop/Keeper.pm
705 705 } 706 706 707 707 708 sub user_coupons_to_order { 709 my $self = shift; 710 my ($session) = @_; 711 712 warn "User coupons transfer begins:\n" if $DEBUG; 713 my %dopts; 714 if ( $session->id ) { 715 $dopts{luid} = $session->id; 716 } else { 717 $dopts{lsession} = $session->_session_id; 718 } 719 720 my $now = Contenido::DateTime->new; 721 my @coupons = $keeper->get_documents( 722 class => 'webshop::Coupon', 723 lclass => 'webshop::OrderCouponLink', 724 lsource => 0, 725 status => 1, 726 interval=> [$now->ymd, $now->ymd], 727 %dopts, 728 ); 729 my $user_coupons = $keeper->get_documents( 730 class => 'webshop::Coupon', 731 lclass => 'webshop::ProfileCouponLink', 732 status => 1, 733 %dopts, 734 return_mode => 'hash_ref', 735 ); 736 foreach my $coupon ( @coupons ) { 737 if ( exists $user_coupons->{$coupon->id} ) { 738 delete $user_coupons->{$coupon->id}; 739 } 740 } 741 foreach my $user_coupon ( values %$user_coupons ) { 742 if ( !$user_coupon->is_accessible($session) ) { 743 next; 744 } 745 746 my $coupon_link = webshop::OrderCouponLink->new( $keeper ); 747 $coupon_link->status( 1 ); 748 $coupon_link->dest_id( $user_coupon->id ); 749 $coupon_link->dest_class( $user_coupon->class ); 750 $coupon_link->source_id( 0 ); 751 if ( $session->id ) { 752 $coupon_link->uid( $session->id ); 753 } else { 754 $coupon_link->session( $session->_session_id ); 755 } 756 $coupon_link->store; 757 push @coupons, $user_coupon; 758 } 759 760 return \@coupons; 761 } 762 708 763 ### Метод проверки и регистрации купона по введенному коду. 709 764 # Код не чувствителен к регистру. 710 765 ############################################################# -
utf8/plugins/webshop/lib/webshop/Order.pm
200 200 { 201 201 my $self = shift; 202 202 203 if ( grep { $_ eq 'payments' } split /\s+/, $state->plugins ) { 203 my @plugins = split (/\s+/, $state->{plugins}); 204 if ( grep { $_ eq 'payments' } @plugins ) { 204 205 my $action; 205 206 my ($lastop) = $keeper->get_documents( class => 'payments::Operation', order_id => $self->id, order_by => 'id desc', limit => 1 ); 206 207 if ( ref $lastop ) { … … 236 237 my $op = $keeper->{payments}->add( order => $self, type => $action, ref $user ? (uuid => $user->id) : () ); 237 238 } 238 239 } 240 241 if ( grep { $_ eq 'session' } @plugins && ref $session ) { 242 $keeper->{webshop}->user_coupons_to_order( $session ); 243 } 244 239 245 return 1; 240 246 } 241 247 -
utf8/plugins/webshop/lib/webshop/SQL/CouponsTable.pm
219 219 220 220 # Ограничение по uid 221 221 if ( exists $opts{luid} ) { 222 my ($where, $values) = SQL::Common::_generic_int_filter('l.uid', $opts{luid}); 223 push (@wheres, $where); 224 push (@binds, ref($values) ? @$values:$values) if (defined $values); 222 if ( $lclass eq 'webshop::ProfileCouponLink' ) { 223 $opts{lsource} = $opts{luid}; 224 } else { 225 my ($where, $values) = SQL::Common::_generic_int_filter('l.uid', $opts{luid}); 226 push (@wheres, $where); 227 push (@binds, ref($values) ? @$values:$values) if (defined $values); 228 } 225 229 } 226 230 227 231 # Ограничение по сессии