OrderRepo.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.izouma.nineth.repo;
  2. import com.izouma.nineth.domain.Order;
  3. import com.izouma.nineth.enums.OrderStatus;
  4. import org.springframework.data.jpa.repository.JpaRepository;
  5. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  6. import org.springframework.data.jpa.repository.Modifying;
  7. import org.springframework.data.jpa.repository.Query;
  8. import javax.transaction.Transactional;
  9. import java.time.LocalDateTime;
  10. import java.util.Collection;
  11. import java.util.List;
  12. import java.util.Optional;
  13. public interface OrderRepo extends JpaRepository<Order, Long>, JpaSpecificationExecutor<Order> {
  14. @Query("update Order t set t.del = true where t.id = ?1")
  15. @Modifying
  16. @Transactional
  17. void softDelete(Long id);
  18. Optional<Order> findByIdAndDelFalse(Long id);
  19. List<Order> findByStatusAndCreatedAtBeforeAndDelFalse(OrderStatus status, LocalDateTime time);
  20. List<Order> findByCollectionId(Long collectionId);
  21. List<Order> findByCollectionIdIn(Iterable<Long> collectionId);
  22. int countByUserIdAndCollectionIdAndStatusIn(Long userId, Long collectionId, Iterable<OrderStatus> orderStatuses);
  23. int countByUserIdAndCountIdAndStatusIn(Long userId, String countId, Iterable<OrderStatus> orderStatuses);
  24. List<Order> findByStatus(OrderStatus orderStatus);
  25. @Query("select count(o) from Order o join Collection c on o.collectionId = c.id " +
  26. "where c.minterId = ?1 and c.source = 'OFFICIAL' and o.status <> 'NOT_PAID' and o.status <> 'CANCELLED'")
  27. long countSales(Long userId);
  28. Order findByTransactionId(String txId);
  29. long countAllByPayTimeAfter(LocalDateTime payTime);
  30. @Query("select id from Order where userId = ?1 and opened = false")
  31. List<Long> findAllByUserIdAndOpenedFalse(Long userId);
  32. int countByUserIdAndCollectionIdAndVipTrueAndStatusIn(Long userId, Long collectionId, Collection<OrderStatus> status);
  33. }