Revision 517
- Date:
- 2015/10/08 22:41:38
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/webshop/lib/webshop/Keeper.pm
115 115 warn "Merge begin: ".Dumper(\%opts)."\n" if $DEBUG; 116 116 return unless $opts{uid} && $opts{session}; 117 117 118 my @items = $keeper->get_documents ( 118 my @items_session = $keeper->get_documents ( 119 119 class => 'webshop::Basket', 120 120 status => [1,0], 121 order_id=> 0, 122 121 session => $opts{session}, 122 order_id => 0, 123 123 ); 124 foreach my $item ( @items ) { 125 $item->session(undef); 126 $item->uid( $opts{uid} ); 127 $item->store; 128 } 129 @items = $keeper->get_documents ( 124 my @items_user = $keeper->get_documents ( 130 125 class => 'webshop::Basket', 131 126 status => [1,0], 132 127 order_id=> 0, 133 128 uid => $opts{uid}, 134 129 ); 135 130 my ($basket_total, $basket_sum, $wishlist_total, $wishlist_sum) = (0,0,0,0); 136 foreach my $item ( @items ) { 131 foreach my $item ( @items_user ) { 132 my ($item_from_session) = grep { 133 $_->item_id == $item->item_id 134 && $_->status == $item->status 135 && ($_->color_id || 0) == ($item->color_id || 0) 136 && ($_->size_id || 0) == ($item->size_id || 0) 137 && ($_->colour || '') eq ($item->colour || '') 138 && ($_->size || '') eq ($item->size || '') 139 } @items_session; 140 if ( ref $item_from_session ) { 141 warn "Merge basket: Found identical item id=".$item_from_session->id."\n" if $DEBUG; 142 $item->number( $item->number + $item_from_session->number ); 143 $item->price( $item_from_session->price ); 144 $item->store; 145 $item_from_session->status(-1); 146 $item_from_session->delete; 147 } 137 148 if ( $item->status == 1 ) { 138 149 $basket_total += $item->number; 139 150 $basket_sum += $item->number * $item->price; … … 142 153 $wishlist_sum += $item->number * $item->price; 143 154 } 144 155 } 156 foreach my $item ( @items_session ) { 157 if ( $item->status > 0 ) { 158 $item->session(undef); 159 $item->uid( $opts{uid} ); 160 $item->store; 161 if ( $item->status == 1 ) { 162 $basket_total += $item->number; 163 $basket_sum += $item->number * $item->price; 164 } else { 165 $wishlist_total += $item->number; 166 $wishlist_sum += $item->number * $item->price; 167 } 168 } 169 } 145 170 warn "Merge end\n" if $DEBUG; 146 171 return ($basket_total, $basket_sum, $wishlist_total, $wishlist_sum); 147 172 } -
utf8/plugins/webshop/lib/webshop/SQL/AddressTable.pm
47 47 { 48 48 my $self = shift; 49 49 50 my @parent_properties = $self->SUPER::required_properties; 50 my @parent_properties = grep { $_->{attr} ne 'sections' } $self->SUPER::required_properties; 51 51 return ( 52 52 @parent_properties, 53 53 { # User ID … … 60 60 'db_opts' => "not null default 0", 61 61 'default' => 0, 62 62 }, 63 { 64 'attr' => 'sections', 65 'type' => 'sections_list', 66 'rusname' => 'Секции', 67 'hidden' => 1, 68 'db_field' => 'sections', 69 'db_type' => 'integer', 70 }, 63 71 ); 64 72 } 65 73 … … 70 78 return &SQL::Common::_generic_int_filter('d.uid', $opts{uid}); 71 79 } 72 80 81 sub _s_filter { 82 my ($self,%opts)=@_; 83 return undef unless ( exists $opts{s} ); 84 return &SQL::Common::_generic_int_filter('d.sections', $opts{s}); 85 } 86 73 87 1;