diff --git a/backend/internal/modules/order/repository.go b/backend/internal/modules/order/repository.go index 40814e5..2a19edb 100644 --- a/backend/internal/modules/order/repository.go +++ b/backend/internal/modules/order/repository.go @@ -605,7 +605,7 @@ func (r *Repository) AcceptCheckout(userID uint64, orderID uint64) error { func (r *Repository) ListForUser(userID uint64) ([]OrderDTO, error) { var rows []orderRow err := r.baseQuery(). - Where("o.renter_id = ?", userID). + Where("o.renter_id = ? OR o.owner_id = ?", userID, userID). Order("o.id DESC"). Scan(&rows).Error if err != nil { diff --git a/frontend/src/views/account/OrdersView.vue b/frontend/src/views/account/OrdersView.vue index 199bcac..2b6196a 100644 --- a/frontend/src/views/account/OrdersView.vue +++ b/frontend/src/views/account/OrdersView.vue @@ -3,11 +3,13 @@ import { onMounted, ref } from 'vue' import { ElMessage } from 'element-plus' import { fetchOrders, payOrder, type Order } from '@/api/orders' +import { useSessionStore } from '@/stores/session' import { orderStatusLabel } from '@/utils/statusLabels' const loading = ref(false) const orders = ref([]) const payingOrderId = ref(null) +const session = useSessionStore() onMounted(loadOrders) @@ -40,6 +42,12 @@ function readError(error: unknown, fallback: string) { } return fallback } + +function orderRole(order: Order) { + if (order.renter_id === session.userId) return '买家' + if (order.owner_id === session.userId) return '号主' + return '-' +}