79 lines
3.0 KiB
Go
79 lines
3.0 KiB
Go
package models
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"time"
|
|
)
|
|
|
|
type CustomerDB struct {
|
|
ID int64 `gorm:"primaryKey;column:id"`
|
|
Name string `gorm:"column:name"`
|
|
Email string `gorm:"column:email"`
|
|
Phone string `gorm:"column:phone"`
|
|
Points int `gorm:"column:points"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
|
CustomerID string `gorm:"column:customer_id"`
|
|
BirthDate time.Time `gorm:"column:birth_date"`
|
|
Password string `gorm:"column:password"`
|
|
IsEmailVerified bool `gorm:"column:is_email_verified"`
|
|
IsPhoneVerified bool `gorm:"column:is_phone_verified"`
|
|
}
|
|
|
|
func (CustomerDB) TableName() string {
|
|
return "customers"
|
|
}
|
|
|
|
type PartnerMemberSequence struct {
|
|
ID int64 `gorm:"column:id;primary_key;auto_increment"`
|
|
PartnerID int64 `gorm:"column:partner_id;not null;index:idx_partner_month,unique"`
|
|
LastSequence int64 `gorm:"column:last_sequence;not null;default:0"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
|
|
}
|
|
|
|
func (PartnerMemberSequence) TableName() string {
|
|
return "partner_member_sequences"
|
|
}
|
|
|
|
type CustomerPointsDB struct {
|
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement"`
|
|
CustomerID uint64 `gorm:"column:customer_id;not null"`
|
|
TotalPoints int `gorm:"column:total_points;not null;default:0"`
|
|
AvailablePoints int `gorm:"column:available_points;not null;default:0"`
|
|
LastUpdated time.Time `gorm:"column:last_updated;default:CURRENT_TIMESTAMP"`
|
|
}
|
|
|
|
func (CustomerPointsDB) TableName() string {
|
|
return "customer_points"
|
|
}
|
|
|
|
type CustomerPointTransactionDB struct {
|
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement"`
|
|
CustomerID int64 `gorm:"column:customer_id;not null"`
|
|
Reference string `gorm:"column:transaction_id"`
|
|
PointsEarned int `gorm:"column:points_earned;not null"`
|
|
TransactionDate time.Time `gorm:"column:transaction_date;not null"`
|
|
ExpirationDate *time.Time `gorm:"column:expiration_date"`
|
|
Status string `gorm:"column:status;default:active"`
|
|
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP"`
|
|
}
|
|
|
|
func (CustomerPointTransactionDB) TableName() string {
|
|
return "customer_point_transactions"
|
|
}
|
|
|
|
type CustomerVerificationCodeDB struct {
|
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement"`
|
|
CustomerID uint64 `gorm:"column:customer_id;not null"`
|
|
Code string `gorm:"column:code;not null"`
|
|
Type string `gorm:"column:type;not null"`
|
|
ExpiresAt time.Time `gorm:"column:expires_at;not null"`
|
|
IsUsed bool `gorm:"column:is_used;default:false"`
|
|
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP"`
|
|
VerificationID uuid.UUID `gorm:"column:verification_id;type:uuid;default:uuid_generate_v4()"`
|
|
}
|
|
|
|
func (CustomerVerificationCodeDB) TableName() string {
|
|
return "customer_verification_codes"
|
|
}
|