21 lines
648 B
Kotlin
21 lines
648 B
Kotlin
package com.android.trisolarisserver.repo
|
|
|
|
import com.android.trisolarisserver.models.booking.Payment
|
|
import org.springframework.data.jpa.repository.JpaRepository
|
|
import org.springframework.data.jpa.repository.Query
|
|
import org.springframework.data.repository.query.Param
|
|
import java.util.UUID
|
|
|
|
interface PaymentRepo : JpaRepository<Payment, UUID> {
|
|
fun findByBookingIdOrderByReceivedAtDesc(bookingId: UUID): List<Payment>
|
|
|
|
@Query(
|
|
"""
|
|
select coalesce(sum(p.amount), 0)
|
|
from Payment p
|
|
where p.booking.id = :bookingId
|
|
"""
|
|
)
|
|
fun sumAmountByBookingId(@Param("bookingId") bookingId: UUID): Long
|
|
}
|