fix: recrediter l'ancien proprio
Co-authored-by: pejour <pejour@users.noreply.github.com> Co-authored-by: Tom Heurtebise <theurt@users.noreply.github.com>
This commit is contained in:
parent
1dd63ac090
commit
8850924f19
|
@ -68,6 +68,11 @@ public class PixelService {
|
|||
User user = User.fromSessionID(cookie.getValue(), em);
|
||||
|
||||
if (user.getBalance() >= pixel.getPrice()) {
|
||||
// crediter l'argent a l'ancien owner
|
||||
User previousOwner = pixel.getOwner();
|
||||
if (previousOwner != null)
|
||||
previousOwner.setBalance(previousOwner.getBalance() + pixel.getPrice());
|
||||
|
||||
// on update l'owner
|
||||
pixel.setOwner(user);
|
||||
user.setBalance(user.getBalance() - pixel.getPrice());
|
||||
|
|
Loading…
Reference in a new issue