Update template email
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package entity
|
||||
|
||||
type CustomerResolutionRequest struct {
|
||||
ID *int64
|
||||
Name string
|
||||
Email string
|
||||
PhoneNumber string
|
||||
}
|
||||
@@ -14,8 +14,9 @@ type JWTAuthClaims struct {
|
||||
}
|
||||
|
||||
type JWTOrderClaims struct {
|
||||
PartnerID int64 `json:"id"`
|
||||
OrderID int64 `json:"order_id"`
|
||||
PartnerID int64 `json:"id"`
|
||||
OrderID int64 `json:"order_id"`
|
||||
InquiryID string `json:"inquiry_id"`
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
|
||||
+29
-34
@@ -1,32 +1,28 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"gorm.io/datatypes"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
RefID string `gorm:"type:varchar;column:ref_id"`
|
||||
PartnerID int64 `gorm:"type:int;column:partner_id"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Amount float64 `gorm:"type:numeric;not null;column:amount"`
|
||||
Total float64 `gorm:"type:numeric;not null;column:total"`
|
||||
Fee float64 `gorm:"type:numeric;not null;column:fee"`
|
||||
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"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
PaymentType string `gorm:"type:varchar;column:payment_type"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
OrderItems []OrderItem `gorm:"foreignKey:OrderID;constraint:OnDelete:CASCADE;"`
|
||||
Payment Payment `gorm:"foreignKey:OrderID;constraint:OnDelete:CASCADE;"`
|
||||
User User `gorm:"foreignKey:CreatedBy;constraint:OnDelete:CASCADE;"`
|
||||
Source string `gorm:"type:varchar;column:source"`
|
||||
TicketStatus string `gorm:"type:varchar;column:ticket_status"`
|
||||
VisitDate time.Time `gorm:"type:date;column:visit_date"`
|
||||
Metadata datatypes.JSON `gorm:"type:json;not null;column:metadata"`
|
||||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
PartnerID int64 `gorm:"type:int;column:partner_id"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Amount float64 `gorm:"type:numeric;not null;column:amount"`
|
||||
Total float64 `gorm:"type:numeric;not null;column:total"`
|
||||
Fee float64 `gorm:"type:numeric;not null;column:fee"`
|
||||
CustomerID *int64
|
||||
InquiryID *string
|
||||
Site *Site `gorm:"foreignKey:SiteID;constraint:OnDelete:CASCADE;"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
PaymentType string `gorm:"type:varchar;column:payment_type"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
OrderItems []OrderItem `gorm:"foreignKey:OrderID;constraint:OnDelete:CASCADE;"`
|
||||
Payment Payment `gorm:"foreignKey:OrderID;constraint:OnDelete:CASCADE;"`
|
||||
User User `gorm:"foreignKey:CreatedBy;constraint:OnDelete:CASCADE;"`
|
||||
Source string `gorm:"type:varchar;column:source"`
|
||||
}
|
||||
|
||||
type OrderDB struct {
|
||||
@@ -47,7 +43,6 @@ func (e *OrderDB) ToSumAmount() *Order {
|
||||
|
||||
type OrderResponse struct {
|
||||
Order *Order
|
||||
Token string
|
||||
}
|
||||
|
||||
type CheckinResponse struct {
|
||||
@@ -80,7 +75,7 @@ type OrderItem struct {
|
||||
ItemID int64 `gorm:"type:int;column:item_id"`
|
||||
ItemType string `gorm:"type:varchar;column:item_type"`
|
||||
Price float64 `gorm:"type:numeric;not null;column:price"`
|
||||
Quantity int64 `gorm:"type:int;column:qty"`
|
||||
Quantity int `gorm:"type:int;column:qty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
@@ -93,19 +88,20 @@ func (OrderItem) TableName() string {
|
||||
}
|
||||
|
||||
type OrderRequest struct {
|
||||
Source string
|
||||
CreatedBy int64
|
||||
PartnerID int64 `json:"partner_id" validate:"required"`
|
||||
PaymentMethod string `json:"payment_method" validate:"required"`
|
||||
OrderItems []OrderItemRequest `json:"order_items" validate:"required,dive"`
|
||||
VisitDate string `json:"visit_date"`
|
||||
BankCode string `json:"bank_code"`
|
||||
BankName string `json:"bank_name"`
|
||||
Source string
|
||||
CreatedBy int64
|
||||
PartnerID int64
|
||||
PaymentMethod string
|
||||
OrderItems []OrderItemRequest
|
||||
CustomerID *int64
|
||||
CustomerName string
|
||||
CustomerEmail string
|
||||
CustomerPhoneNumber string
|
||||
}
|
||||
|
||||
type OrderItemRequest struct {
|
||||
ProductID int64 `json:"product_id" validate:"required"`
|
||||
Quantity int64 `json:"quantity" validate:"required"`
|
||||
Quantity int `json:"quantity" validate:"required"`
|
||||
}
|
||||
|
||||
type OrderExecuteRequest struct {
|
||||
@@ -117,7 +113,6 @@ type OrderExecuteRequest struct {
|
||||
func (o *Order) SetExecutePaymentStatus() {
|
||||
if o.PaymentType == "CASH" {
|
||||
o.Status = "PAID"
|
||||
o.TicketStatus = "USED"
|
||||
return
|
||||
}
|
||||
o.Status = "PENDING"
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"enaklo-pos-be/internal/constants"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OrderInquiry struct {
|
||||
ID string `json:"id"`
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
CustomerID int64 `json:"customer_id,omitempty"`
|
||||
CustomerName string `json:"customer_name"`
|
||||
CustomerPhoneNumber string `json:"customer_phone_number"`
|
||||
CustomerEmail string `json:"customer_email"`
|
||||
Status string `json:"status"`
|
||||
Amount float64 `json:"amount"`
|
||||
Fee float64 `json:"fee"`
|
||||
Total float64 `json:"total"`
|
||||
PaymentType string `json:"payment_type"`
|
||||
Source string `json:"source"`
|
||||
CreatedBy int64 `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
OrderItems []OrderItem `json:"order_items"`
|
||||
}
|
||||
|
||||
type OrderCalculation struct {
|
||||
Subtotal float64 `json:"subtotal"`
|
||||
Fee float64 `json:"fee"`
|
||||
Total float64 `json:"total"`
|
||||
}
|
||||
|
||||
type OrderInquiryResponse struct {
|
||||
OrderInquiry *OrderInquiry `json:"order_inquiry"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
func NewOrderInquiry(
|
||||
partnerID int64,
|
||||
customerID int64,
|
||||
amount float64,
|
||||
fee float64,
|
||||
total float64,
|
||||
paymentType string,
|
||||
source string,
|
||||
createdBy int64,
|
||||
customerName string,
|
||||
customerPhoneNumber string,
|
||||
customerEmail string,
|
||||
) *OrderInquiry {
|
||||
return &OrderInquiry{
|
||||
ID: constants.GenerateUUID(),
|
||||
PartnerID: partnerID,
|
||||
Status: "PENDING",
|
||||
Amount: amount,
|
||||
Fee: fee,
|
||||
Total: total,
|
||||
PaymentType: paymentType,
|
||||
CustomerID: customerID,
|
||||
Source: source,
|
||||
CreatedBy: createdBy,
|
||||
CreatedAt: time.Now(),
|
||||
ExpiresAt: time.Now().Add(2 * time.Minute),
|
||||
OrderItems: []OrderItem{},
|
||||
CustomerName: customerName,
|
||||
CustomerEmail: customerEmail,
|
||||
CustomerPhoneNumber: customerPhoneNumber,
|
||||
}
|
||||
}
|
||||
|
||||
func (oi *OrderInquiry) AddOrderItem(item OrderItemRequest, product *Product) {
|
||||
oi.OrderItems = append(oi.OrderItems, OrderItem{
|
||||
ItemID: item.ProductID,
|
||||
ItemType: product.Type,
|
||||
Price: product.Price,
|
||||
Quantity: item.Quantity,
|
||||
CreatedBy: oi.CreatedBy,
|
||||
Product: product,
|
||||
})
|
||||
}
|
||||
|
||||
func (i *OrderInquiry) ToOrder(paymentMethod string) *Order {
|
||||
now := time.Now()
|
||||
|
||||
order := &Order{
|
||||
PartnerID: i.PartnerID,
|
||||
CustomerID: &i.CustomerID,
|
||||
InquiryID: &i.ID,
|
||||
Status: constants.StatusPaid,
|
||||
Amount: i.Amount,
|
||||
Fee: i.Fee,
|
||||
Total: i.Total,
|
||||
PaymentType: paymentMethod,
|
||||
Source: i.Source,
|
||||
CreatedBy: i.CreatedBy,
|
||||
CreatedAt: now,
|
||||
OrderItems: make([]OrderItem, len(i.OrderItems)),
|
||||
}
|
||||
|
||||
for idx, item := range i.OrderItems {
|
||||
order.OrderItems[idx] = OrderItem{
|
||||
ItemID: item.ItemID,
|
||||
ItemType: item.ItemType,
|
||||
Price: item.Price,
|
||||
Quantity: item.Quantity,
|
||||
CreatedBy: i.CreatedBy,
|
||||
CreatedAt: now,
|
||||
Product: item.Product,
|
||||
}
|
||||
}
|
||||
|
||||
return order
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
type Product struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
PartnerID int64 `gorm:"type:int;column:partner_id"`
|
||||
SiteID int64 `gorm:"type:int;column:site_id"`
|
||||
Name string `gorm:"type:varchar(255);not null;column:name"`
|
||||
Type string `gorm:"type:varchar;column:type"`
|
||||
Price float64 `gorm:"type:decimal;column:price"`
|
||||
@@ -19,7 +18,7 @@ type Product struct {
|
||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
Image string `gorm:"type:varchar;column:type"`
|
||||
Image string `gorm:"type:varchar;column:image"`
|
||||
}
|
||||
|
||||
func (Product) TableName() string {
|
||||
@@ -71,7 +70,7 @@ func (e *ProductDB) ToProduct() *Product {
|
||||
DeletedAt: e.DeletedAt,
|
||||
CreatedBy: e.CreatedBy,
|
||||
UpdatedBy: e.UpdatedBy,
|
||||
SiteID: e.SiteID,
|
||||
Image: e.Image,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +78,7 @@ func (b *ProductList) ToProductList() []*Product {
|
||||
var Products []*Product
|
||||
|
||||
for _, p := range *b {
|
||||
if p.Status == "Available" {
|
||||
Products = append(Products, p.ToProduct())
|
||||
}
|
||||
Products = append(Products, p.ToProduct())
|
||||
}
|
||||
|
||||
return Products
|
||||
@@ -126,3 +123,8 @@ func (o *ProductDB) SetDeleted(updatedby int64) {
|
||||
o.DeletedAt = ¤tTime
|
||||
o.UpdatedBy = updatedby
|
||||
}
|
||||
|
||||
type ProductDetails struct {
|
||||
Products map[int64]*Product // Map for quick lookups by ID
|
||||
PartnerID int64 // Common site ID for all products
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@ import (
|
||||
)
|
||||
|
||||
type Transaction struct {
|
||||
ID string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
|
||||
ID string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
|
||||
OrderID int64
|
||||
PartnerID int64 `gorm:"not null"`
|
||||
TransactionType string `gorm:"not null"`
|
||||
ReferenceID string `gorm:"size:255"`
|
||||
Status string `gorm:"size:255"`
|
||||
CreatedBy int64 `gorm:"not null"`
|
||||
UpdatedBy int64 `gorm:"not null"`
|
||||
Amount float64 `gorm:"not null"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
||||
SiteID *int64
|
||||
PaymentMethod string `json:"payment_method"`
|
||||
Fee float64
|
||||
Total float64
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ type Customer struct {
|
||||
Name string
|
||||
Email string
|
||||
Password string
|
||||
Phone string
|
||||
Points int
|
||||
Status userstatus.UserStatus
|
||||
NIK string
|
||||
UserType string
|
||||
|
||||
Reference in New Issue
Block a user