Skip to content

Commit

Permalink
Merge pull request #130 from Orange-Co/feature/alarm
Browse files Browse the repository at this point in the history
Feat: reflect modification
  • Loading branch information
Kang1221 authored Nov 29, 2024
2 parents 599bde8 + 36fd04a commit 453abbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface OrderRepository extends JpaRepository<Order, String> {
@Query("SELECT o from Order o where o.buyer = :user AND o.status <>'ORDER_PENDING'")
List<Order> findByBuyerAndStatus(User user);

@Query("SELECT o FROM Order o WHERE o.item = :item AND o.status <> 'ORDER_PENDING'")
@Query("SELECT o FROM Order o WHERE o.item = :item AND o.status NOT IN ('ORDER_PENDING', 'CANCELLED')")
Optional<Order> findByItemAndStatus(@Param("item") Item item);

@Query("SELECT o FROM Order o WHERE o.status = :orderStatus AND o.updatedAt <= :dateTime")
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/co/orange/ddanzi/service/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import co.orange.ddanzi.domain.order.Order;
import co.orange.ddanzi.domain.order.OrderOptionDetail;
import co.orange.ddanzi.domain.order.Payment;
import co.orange.ddanzi.domain.order.enums.OrderStatus;
import co.orange.ddanzi.domain.order.enums.PayStatus;
import co.orange.ddanzi.domain.product.Discount;
import co.orange.ddanzi.domain.product.Item;
import co.orange.ddanzi.domain.product.Product;
import co.orange.ddanzi.domain.product.enums.ItemStatus;
import co.orange.ddanzi.domain.user.User;
import co.orange.ddanzi.domain.user.enums.FcmCase;
import co.orange.ddanzi.dto.common.AddressSeparateInfo;
import co.orange.ddanzi.dto.item.*;
import co.orange.ddanzi.common.error.Error;
Expand All @@ -29,16 +29,11 @@
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;


@Slf4j
Expand Down Expand Up @@ -160,10 +155,11 @@ public ApiResponse<?> deleteItem(String itemId){
try {
paymentService.refundPayment(buyer, order, "현재 남은 재고가 없어 고객에게 결제 금액 환불합니다.");
payment.updatePaymentStatusAndEndedAt(PayStatus.CANCELLED);
historyService.createPaymentHistoryWithError(buyer, payment, "제품 삭제- 환불 처리 성공");
order.updateStatus(OrderStatus.CANCELLED);
historyService.createPaymentHistoryWithError(buyer, payment, "판매자에 의해 제품 삭제- 환불 처리 성공");
}catch (Exception e){
log.info("환불이 불가능하여 제품 삭제에 실패했습니다.");
historyService.createPaymentHistoryWithError(buyer, payment, "제품 삭제 - 환불 처리 실패");
historyService.createPaymentHistoryWithError(buyer, payment, "판매자에 의해 제품 삭제 - 환불 처리 실패");
return ApiResponse.onFailure(Error.REFUND_FAILED, Map.of("itemId", item.getId()));
}
}
Expand All @@ -177,7 +173,7 @@ public ApiResponse<?> deleteItem(String itemId){

Product product = item.getProduct();
product.updateStock(product.getStock() - 1);
log.info("재고를 감소시킴 -> {}개", product.getClosestDueDate());
log.info("재고를 감소시킴 -> {}개", product.getStock());

productService.updateClosestDueDate(product);

Expand Down Expand Up @@ -241,6 +237,9 @@ private List<SelectedOption> setSelectedOptionList(Order order){
public List<MyItem> getMyItemList(User user){
List<Item> itemList = itemRepository.findAllBySellerAndNotDeleted(user);
List<MyItem> myItemList = new ArrayList<>();

Collections.reverse(itemList);

for(Item item : itemList){
Product product = item.getProduct();
Discount discount = discountRepository.findById(product.getId()).orElseThrow(DiscountNotFoundException::new);
Expand All @@ -249,7 +248,7 @@ public List<MyItem> getMyItemList(User user){
.productId(product.getId())
.itemId(item.getId())
.productName(product.getName())
.imgUrl(item.getImgUrl())
.imgUrl(product.getImgUrl())
.originPrice(product.getOriginPrice())
.salePrice(product.getOriginPrice() - discount.getDiscountPrice())
.isInterested(interestProductRepository.existsByIdUserAndIdProduct(user,product))
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/co/orange/ddanzi/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ public ApiResponse<?> withdraw(){
}

private ApiResponse<?> verifyExistingAuthentication(User user, VerifyRequestDto requestDto) {
if (!user.getAuthentication().getCi().equals(requestDto.getCi())) {
if (!user.getAuthentication().getCi().equals(requestDto.getCi()))
return ApiResponse.onFailure(Error.AUTHENTICATION_CANNOT_CHANGE, null);
}
else
user.updateStatus(UserStatus.ACTIVATE);
return ApiResponse.onSuccess(Success.CREATE_AUTHENTICATION_SUCCESS, setVerifyResponse(user));
}

Expand Down

0 comments on commit 453abbb

Please sign in to comment.