patch projet finish v2 + translate

This commit is contained in:
jleroy
2024-05-02 16:29:01 +02:00
parent d61797ba02
commit 8eedcc35db
8 changed files with 60 additions and 23 deletions

View File

@@ -99,14 +99,15 @@ public class EnchereController {
.max(Comparator.comparing(Enchere::getMontantEnchere)) // Comparaison basée sur le montant d'enchère
.map(Enchere::getPseudoUtilisateur);
UserProfil user = this.userService.utilisateurByName(pseudoMaxEnchere.get());
//Get seller
Article articleSell = articleService.findArticleById(id);
UserProfil userSeller = userService.utilisateurById(articleSell.getUtilisateur());
Optional<Float> maxMontantEnchere = listEncheres.stream()
.map(Enchere::getMontantEnchere) // Récupère seulement les montants d'enchère
.max(Float::compareTo);
//setCredit user.
float userCredit = user.getCredit();
float newCredit = userCredit - maxMontantEnchere.get();
float newCredit = user.getCredit() - maxMontantEnchere.get();
this.userService.setCredit(newCredit, user.getId());
//Delete enchere
@@ -116,6 +117,11 @@ public class EnchereController {
//Delete article
this.articleService.setSellPrice(id, maxMontantEnchere.get());
//Crédit selleur
float sellerCredit = userSeller.getCredit() + maxMontantEnchere.get();
this.userService.setCredit(sellerCredit, userSeller.getId());
return "redirect:/enchere";
}