mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-09 20:26:51 +00:00
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package booking
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"github.com/rjNemo/rentease/config"
|
|
)
|
|
|
|
type Booking struct {
|
|
From time.Time
|
|
To time.Time
|
|
gorm.Model
|
|
Name string `gorm:"column:customer_name"`
|
|
PhoneNumber string
|
|
Email string
|
|
Platform string
|
|
ExternalId *string `gorm:"uniqueIndex:booking_external_id"`
|
|
Items []Item
|
|
Id int
|
|
CustomerNumber int `gorm:"column:customers"`
|
|
PlatformFees float64 `gorm:"type:decimal(10,2)"`
|
|
Canceled bool `gorm:"default:false"`
|
|
}
|
|
|
|
func (b Booking) InvoiceNumber(hc *config.Host) string {
|
|
return fmt.Sprintf("%s%04s", hc.InvoicePrefix, strconv.Itoa(b.Id+hc.CustomerSeed))
|
|
}
|
|
|
|
type BookingRequest struct {
|
|
gorm.Model
|
|
From time.Time
|
|
To time.Time
|
|
PhoneNumber *string
|
|
Email *string
|
|
BookingId *int
|
|
CustomerName string
|
|
ItemType string
|
|
Message string
|
|
Status string
|
|
CustomerNumber int
|
|
}
|
|
|
|
type Item struct {
|
|
gorm.Model
|
|
Item string
|
|
PaymentMethod string
|
|
PaymentStatus string `gorm:"default:Pending"`
|
|
Id int
|
|
BookingId int
|
|
Quantity int
|
|
Price float64 `gorm:"type:decimal(10,2)"`
|
|
}
|