Add Order Detail
This commit is contained in:
parent
90ef6b910b
commit
c4e0c6d2c8
@ -13,6 +13,7 @@ type Order struct {
|
|||||||
Total float64 `gorm:"type:numeric;not null;column:total"`
|
Total float64 `gorm:"type:numeric;not null;column:total"`
|
||||||
Fee float64 `gorm:"type:numeric;not null;column:fee"`
|
Fee float64 `gorm:"type:numeric;not null;column:fee"`
|
||||||
SiteID *int64 `gorm:"type:numeric;not null;column:site_id"`
|
SiteID *int64 `gorm:"type:numeric;not null;column:site_id"`
|
||||||
|
Site *Site `gorm:"foreignKey:SiteID;constraint:OnDelete:CASCADE;"`
|
||||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||||
|
|||||||
@ -233,6 +233,12 @@ func (h *Handler) toOrderDetail(order *entity.Order) *response.OrderDetail {
|
|||||||
qrCode = order.RefID
|
qrCode = order.RefID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var siteName string
|
||||||
|
|
||||||
|
if order.Site != nil {
|
||||||
|
siteName = order.Site.Name
|
||||||
|
}
|
||||||
|
|
||||||
orderDetail := &response.OrderDetail{
|
orderDetail := &response.OrderDetail{
|
||||||
ID: order.ID,
|
ID: order.ID,
|
||||||
QRCode: qrCode,
|
QRCode: qrCode,
|
||||||
@ -244,6 +250,7 @@ func (h *Handler) toOrderDetail(order *entity.Order) *response.OrderDetail {
|
|||||||
Status: order.Status,
|
Status: order.Status,
|
||||||
PaymentLink: paymentLink,
|
PaymentLink: paymentLink,
|
||||||
PaymentToken: paymentToken,
|
PaymentToken: paymentToken,
|
||||||
|
SiteName: siteName,
|
||||||
}
|
}
|
||||||
|
|
||||||
orderDetail.OrderItems = make([]response.OrderDetailItem, len(order.OrderItems))
|
orderDetail.OrderItems = make([]response.OrderDetailItem, len(order.OrderItems))
|
||||||
|
|||||||
@ -167,6 +167,7 @@ type PaymentDistribution struct {
|
|||||||
type OrderDetail struct {
|
type OrderDetail struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
QRCode string `json:"qr_code"`
|
QRCode string `json:"qr_code"`
|
||||||
|
SiteName string `json:"site_name"`
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
PhoneNumber string `json:"phone_number"`
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
|||||||
@ -52,6 +52,7 @@ func (r *OrderRepository) FindByID(ctx context.Context, id int64) (*entity.Order
|
|||||||
Preload("OrderItems", func(db *gorm.DB) *gorm.DB {
|
Preload("OrderItems", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Preload("Product")
|
return db.Preload("Product")
|
||||||
}).
|
}).
|
||||||
|
Preload("Site").
|
||||||
Preload("User").
|
Preload("User").
|
||||||
Preload("Payment").
|
Preload("Payment").
|
||||||
First(&order, id).Error
|
First(&order, id).Error
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user