order.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package models
  2. import (
  3. "time"
  4. "gorm.io/gorm"
  5. )
  6. type OrderStatus string
  7. const (
  8. OrderStatus_Pending OrderStatus = "Pending"
  9. OrderStatus_Authorised OrderStatus = "Authorised"
  10. OrderStatus_Cancelled OrderStatus = "Cancelled"
  11. OrderStatus_AuthUnknown OrderStatus = "AuthUnknown"
  12. OrderStatus_Sending OrderStatus = "Sending"
  13. OrderStatus_CheckedIn OrderStatus = "CheckedIn"
  14. OrderStatus_Refunded OrderStatus = "Refunded"
  15. OrderStatus_Validating OrderStatus = "Validating"
  16. OrderStatus_Paid OrderStatus = "Paid"
  17. OrderStatusColor_Grey = "#e0e0e0"
  18. OrderStatusColor_Orange = "#ffa600"
  19. OrderStatusColor_Blue = "#2194f3"
  20. OrderStatusColor_Green = "#4caf4f"
  21. OrderStatusColor_Purple = "#4a148c"
  22. OrderStatusColor_Brown = "#9f6d6d"
  23. OrderStatusColor_Red = "#f44336"
  24. )
  25. type Order struct {
  26. gorm.Model
  27. Source string
  28. Status OrderStatus
  29. DeliveryMethod string
  30. PaymentMethod string
  31. ConfirmedAt *time.Time
  32. OrderItems []*OrderItem `gorm:"type:text[]"`
  33. }
  34. type OrderItem struct {
  35. ProductCode string
  36. Quantity int32
  37. UnitPrice float64
  38. TaxUnknown bool
  39. TotalPriceExTax *float64
  40. TotalPrice float64
  41. Name string
  42. Image string
  43. }
  44. var OrderStatuses = []OrderStatus{
  45. OrderStatus_Pending,
  46. OrderStatus_Authorised,
  47. OrderStatus_Cancelled,
  48. OrderStatus_AuthUnknown,
  49. OrderStatus_Sending,
  50. OrderStatus_CheckedIn,
  51. OrderStatus_Refunded,
  52. OrderStatus_Validating,
  53. OrderStatus_Paid,
  54. }
  55. var OrderStatusColorMap = map[OrderStatus]string{
  56. OrderStatus_Pending: OrderStatusColor_Grey,
  57. OrderStatus_Authorised: OrderStatusColor_Blue,
  58. OrderStatus_Cancelled: OrderStatusColor_Red,
  59. OrderStatus_AuthUnknown: OrderStatusColor_Red,
  60. OrderStatus_Sending: OrderStatusColor_Orange,
  61. OrderStatus_CheckedIn: OrderStatusColor_Green,
  62. OrderStatus_Refunded: OrderStatusColor_Purple,
  63. OrderStatus_Validating: OrderStatusColor_Orange,
  64. OrderStatus_Paid: OrderStatusColor_Blue,
  65. }