Files
TrisolarisServer/src/main/kotlin/com/android/trisolarisserver/repo/PaymentRepo.kt
androidlover5842 52bcdd3648
All checks were successful
build-and-deploy / build-deploy (push) Successful in 42s
Process PayU webhook into payments
2026-01-30 09:20:39 +05:30

37 lines
1.1 KiB
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>
fun findByReference(reference: String): Payment?
@Query(
"""
select coalesce(sum(p.amount), 0)
from Payment p
where p.booking.id = :bookingId
"""
)
fun sumAmountByBookingId(@Param("bookingId") bookingId: UUID): Long
@Query(
"""
select p.booking.id as bookingId, coalesce(sum(p.amount), 0) as total
from Payment p
where p.booking.id in :bookingIds
group by p.booking.id
"""
)
fun sumAmountByBookingIds(@Param("bookingIds") bookingIds: List<UUID>): List<BookingPaymentSumRow>
}
interface BookingPaymentSumRow {
val bookingId: UUID
val total: Long
}