Skip to content

Commit

Permalink
결제 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
bongsh0112 committed Sep 27, 2023
1 parent 47ce473 commit 906ea3d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,29 @@
@RequiredArgsConstructor
@Controller
public class PaymentController {

private final PaymentService paymentService;
private final UserService userService;

@GetMapping("/payment")
public String paymentForm() {
return "payment/payment";
}

@GetMapping("/success")
public String paymentSuccess() {
return "exchange/success";
}

@GetMapping("/failed")
public String paymentFailed() {
return "exchange/failed";
}

@ResponseBody
@PostMapping("/payment")
public void createPayment(@RequestBody PostCreatePaymentRequest body) {
paymentService.savePaymentHistory(body);
Optional<User> user = userService.findUserById(body.getUserId());
user.ifPresent(u -> u.updatePoint(body.getPaidAmount()));
}

private final PaymentService paymentService;
private final UserService userService;

@GetMapping("/payment")
public String paymentForm() {
return "payment/payment";
}

@GetMapping("/success")
public String paymentSuccess() {
return "exchange/success";
}

@GetMapping("/failed")
public String paymentFailed() {
return "exchange/failed";
}

@ResponseBody
@PostMapping("/payment")
public void createPayment(@RequestBody PostCreatePaymentRequest body) {
paymentService.savePaymentHistory(body);
userService.findUserById(body.getUserId()).ifPresent(u -> u.updatePoint(body.getPaidAmount()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import picasso.server.api.exchange.model.request.PostCreatePaymentRequest;
import picasso.server.api.exchange.validator.PaymentValidator;
import picasso.server.domain.domains.payments.items.PGName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void updatePoint(Long point) {
this.point += point;
}
public void minusPoint(Long point) {
this.point -= point;}


this.point -= point;
}
}

0 comments on commit 906ea3d

Please sign in to comment.