-
Order.pm
564 565 112 112 113 113 # my $query = $self->{keeper}->SQL->prepare("delete from basket where order_id = ? and uid = ?"); 114 114 # $query->execute( $self->id, $self->uid ); 115 115 116 $self->status(5); 116 117 $self->store; 117 118 } … … 139 140 ]; 140 141 } 141 142 143 sub pre_store 144 { 145 my $self = shift; 142 146 147 if ( grep { $_ eq 'payments' } split /\s+/, $state->plugins ) { 148 my $action; 149 my ($lastop) = $keeper->get_documents( class => 'payments::Operation', order_id => $self->id, order_by => 'id desc', limit => 1 ); 150 if ( ref $lastop ) { 151 if ( $self->status == 1 || $self->status == 2 || $self->status == 6 ) { 152 if ( $lastop->name eq 'suspend' || $lastop->name eq 'cancel' || $lastop->name eq 'close' ) { 153 $action = 'resume'; 154 } 155 } elsif ( $self->status == 7 ) { 156 if ( $lastop->name ne 'suspend' ) { 157 $action = 'suspend'; 158 } 159 } elsif ( $self->status == 4 ) { 160 if ( $lastop->name ne 'close' ) { 161 $action = 'close'; 162 } 163 } elsif ( $self->status == 5 ) { 164 if ( $lastop->name ne 'cancel' ) { 165 $action = 'cancel'; 166 } 167 } 168 } else { 169 if ( $self->status == 1 || $self->status == 2 || $self->status == 6 ) { 170 $action = 'create'; 171 } elsif ( $self->status == 7 ) { 172 $action = 'suspend'; 173 } elsif ( $self->status == 4 ) { 174 $action = 'close'; 175 } elsif ( $self->status == 5 ) { 176 $action = 'cancel'; 177 } 178 } 179 if ( $action ) { 180 my $op = payments::Operation->new( $keeper ); 181 $op->name( $action ); 182 $op->order_id( $self->id ); 183 $op->uid( $self->uid ); 184 if ( ref $user ) { 185 $op->uuid( $user->id ); 186 } 187 $op->sum( $self->sum_total ); 188 $op->store; 189 } 190 } 191 return 1; 192 } 193 194 143 195 sub post_delete 144 196 { 145 197 my $self = shift;