Skip to content

Commit

Permalink
FEAT:fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo pelu committed Dec 4, 2024
1 parent a4237c1 commit d06c998
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/pos/app/service/impl/OrderServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,26 @@ public ResponseIdQr generateQROrder() {

@Override
public ResponseEnum createOrderViaQr(String code, ReqCreateOrderViaQrCode req) {

Optional<QrCode> findQrCode = qrCodeRepository.findByCode(code);

if (findQrCode.isEmpty()) {
throw new BadRequestException(ResponseEnum.REQUEST_INVALID.name());
}


QrCode qrCode = findQrCode.get();
String clientId = qrCode.getClient().getId();

Optional<Order> checkOrder = orderRepository.findById(qrCode.getOrder().getId());
if (checkOrder.isEmpty()) {
throw new NotFoundException(ResponseEnum.ORDER_NOT_FOUND.name());
}

if (!checkOrder.get().getStatus().equals(OrderStatusEnum.PENDING)) {
throw new BadRequestException(ResponseEnum.REQUEST_INVALID.name());
}

Optional<Order> findOrder = orderRepository.findById(qrCode.getOrder().getId());
if (findOrder.isEmpty()) {
throw new NotFoundException(ResponseEnum.ORDER_NOT_FOUND.name());
Expand Down

0 comments on commit d06c998

Please sign in to comment.