enaklo pos backend
This commit is contained in:
+28
-44
@@ -6,22 +6,20 @@ 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"`
|
||||
IsWeekendTicket bool `gorm:"type:bool;column:is_weekend_ticket"`
|
||||
IsSeasonTicket bool `gorm:"type:bool;column:is_season_ticket"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Description string `gorm:"type:varchar(255);not null;column:description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
Stock int64 `gorm:"type:int;column:stock"`
|
||||
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"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Description string `gorm:"type:varchar(255);not null;column:description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func (Product) TableName() string {
|
||||
@@ -61,22 +59,19 @@ func (ProductDB) TableName() string {
|
||||
|
||||
func (e *ProductDB) ToProduct() *Product {
|
||||
return &Product{
|
||||
ID: e.ID,
|
||||
Name: e.Name,
|
||||
Type: e.Type,
|
||||
Price: e.Price,
|
||||
Status: e.Status,
|
||||
Description: e.Description,
|
||||
PartnerID: e.PartnerID,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
DeletedAt: e.DeletedAt,
|
||||
CreatedBy: e.CreatedBy,
|
||||
UpdatedBy: e.UpdatedBy,
|
||||
SiteID: e.SiteID,
|
||||
IsSeasonTicket: e.IsSeasonTicket,
|
||||
IsWeekendTicket: e.IsWeekendTicket,
|
||||
Stock: e.Stock,
|
||||
ID: e.ID,
|
||||
Name: e.Name,
|
||||
Type: e.Type,
|
||||
Price: e.Price,
|
||||
Status: e.Status,
|
||||
Description: e.Description,
|
||||
PartnerID: e.PartnerID,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
DeletedAt: e.DeletedAt,
|
||||
CreatedBy: e.CreatedBy,
|
||||
UpdatedBy: e.UpdatedBy,
|
||||
SiteID: e.SiteID,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,20 +89,9 @@ func (b *ProductList) ToProductList() []*Product {
|
||||
|
||||
func (b *ProductList) ToProductListPOS() []*Product {
|
||||
var Products []*Product
|
||||
location, _ := time.LoadLocation("Asia/Jakarta")
|
||||
today := time.Now().In(location).Weekday()
|
||||
isWeekend := today == time.Saturday || today == time.Sunday
|
||||
|
||||
for _, p := range *b {
|
||||
if p.Status != "Available" {
|
||||
continue
|
||||
}
|
||||
|
||||
if isWeekend && p.IsWeekendTicket {
|
||||
Products = append(Products, p.ToProduct())
|
||||
} else if !isWeekend && !p.IsWeekendTicket {
|
||||
Products = append(Products, p.ToProduct())
|
||||
}
|
||||
Products = append(Products, p.ToProduct())
|
||||
}
|
||||
|
||||
return Products
|
||||
|
||||
Reference in New Issue
Block a user