update
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
package entity
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
type InProgressOrder struct {
|
||||
ID string
|
||||
PartnerID int64
|
||||
CustomerID *int64
|
||||
CustomerName string
|
||||
CreatedBy int64
|
||||
PaymentType string
|
||||
PaymentProvider string
|
||||
OrderItems []InProgressOrderItem
|
||||
Payment Payment
|
||||
User User
|
||||
Source string
|
||||
OrderType string
|
||||
TableNumber string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type InProgressOrderItem struct {
|
||||
ID int64
|
||||
InProgressOrderID int64
|
||||
ItemID int64
|
||||
Quantity int
|
||||
Product *Product
|
||||
}
|
||||
+27
-23
@@ -5,24 +5,29 @@ import (
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
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"`
|
||||
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
|
||||
CustomerName string
|
||||
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"`
|
||||
PaymentProvider string `gorm:"type:varchar;column:payment_provider"`
|
||||
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"`
|
||||
OrderType string `gorm:"type:varchar;column:order_type"`
|
||||
TableNumber string
|
||||
InProgressOrderID string
|
||||
}
|
||||
|
||||
type OrderDB struct {
|
||||
@@ -97,6 +102,9 @@ type OrderRequest struct {
|
||||
CustomerName string
|
||||
CustomerEmail string
|
||||
CustomerPhoneNumber string
|
||||
TableNumber string
|
||||
PaymentProvider string
|
||||
OrderType string
|
||||
}
|
||||
|
||||
type OrderItemRequest struct {
|
||||
@@ -111,11 +119,7 @@ type OrderExecuteRequest struct {
|
||||
}
|
||||
|
||||
func (o *Order) SetExecutePaymentStatus() {
|
||||
if o.PaymentType == "CASH" {
|
||||
o.Status = "PAID"
|
||||
return
|
||||
}
|
||||
o.Status = "PENDING"
|
||||
o.Status = "PAID"
|
||||
}
|
||||
|
||||
type CallbackRequest struct {
|
||||
|
||||
@@ -23,6 +23,9 @@ type OrderInquiry struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
OrderItems []OrderItem `json:"order_items"`
|
||||
PaymentProvider string `json:"payment_provider"`
|
||||
TableNumber string `json:"table_number"`
|
||||
OrderType string `json:"order_type"`
|
||||
}
|
||||
|
||||
type OrderCalculation struct {
|
||||
@@ -48,6 +51,9 @@ func NewOrderInquiry(
|
||||
customerName string,
|
||||
customerPhoneNumber string,
|
||||
customerEmail string,
|
||||
paymentProvider string,
|
||||
tableNumber string,
|
||||
orderType string,
|
||||
) *OrderInquiry {
|
||||
return &OrderInquiry{
|
||||
ID: constants.GenerateUUID(),
|
||||
@@ -66,6 +72,9 @@ func NewOrderInquiry(
|
||||
CustomerName: customerName,
|
||||
CustomerEmail: customerEmail,
|
||||
CustomerPhoneNumber: customerPhoneNumber,
|
||||
PaymentProvider: paymentProvider,
|
||||
TableNumber: tableNumber,
|
||||
OrderType: orderType,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,22 +89,24 @@ func (oi *OrderInquiry) AddOrderItem(item OrderItemRequest, product *Product) {
|
||||
})
|
||||
}
|
||||
|
||||
func (i *OrderInquiry) ToOrder(paymentMethod string) *Order {
|
||||
func (i *OrderInquiry) ToOrder(paymentMethod, paymentProvider 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)),
|
||||
PartnerID: i.PartnerID,
|
||||
CustomerID: &i.CustomerID,
|
||||
InquiryID: &i.ID,
|
||||
Status: constants.StatusPaid,
|
||||
Amount: i.Amount,
|
||||
Fee: i.Fee,
|
||||
Total: i.Total,
|
||||
PaymentType: paymentMethod,
|
||||
PaymentProvider: paymentProvider,
|
||||
Source: i.Source,
|
||||
CreatedBy: i.CreatedBy,
|
||||
CreatedAt: now,
|
||||
OrderItems: make([]OrderItem, len(i.OrderItems)),
|
||||
OrderType: i.OrderType,
|
||||
}
|
||||
|
||||
for idx, item := range i.OrderItems {
|
||||
|
||||
+29
-21
@@ -30,27 +30,29 @@ type User struct {
|
||||
}
|
||||
|
||||
type Customer struct {
|
||||
ID int64
|
||||
Name string
|
||||
Email string
|
||||
Password string
|
||||
Phone string
|
||||
Points int
|
||||
Status userstatus.UserStatus
|
||||
NIK string
|
||||
UserType string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
RoleID role.Role
|
||||
PhoneNumber string
|
||||
RoleName string
|
||||
PartnerID *int64
|
||||
SiteID *int64
|
||||
SiteName string
|
||||
PartnerName string
|
||||
ResetPassword bool
|
||||
CustomerID string
|
||||
BirthDate time.Time
|
||||
ID int64
|
||||
Name string
|
||||
Email string
|
||||
Password string
|
||||
Phone string
|
||||
Points int
|
||||
Status userstatus.UserStatus
|
||||
NIK string
|
||||
UserType string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
RoleID role.Role
|
||||
PhoneNumber string
|
||||
RoleName string
|
||||
PartnerID *int64
|
||||
SiteID *int64
|
||||
SiteName string
|
||||
PartnerName string
|
||||
ResetPassword bool
|
||||
CustomerID string
|
||||
BirthDate time.Time
|
||||
VerificationID string
|
||||
OTP string
|
||||
}
|
||||
|
||||
type AuthenticateUser struct {
|
||||
@@ -117,3 +119,9 @@ func (u User) HashedPassword(password string) (string, error) {
|
||||
|
||||
return string(hashedPassword), nil
|
||||
}
|
||||
|
||||
func (c Customer) HashedPassword() string {
|
||||
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(c.Password), bcrypt.DefaultCost)
|
||||
|
||||
return string(hashedPassword)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user