...
This commit is contained in:
115
specs/models_marketplace/main/order.v
Normal file
115
specs/models_marketplace/main/order.v
Normal file
@@ -0,0 +1,115 @@
|
||||
module main
|
||||
|
||||
import freeflowuniverse.herolib.hero.models.marketplace.core
|
||||
|
||||
pub struct Order {
|
||||
core.Base
|
||||
pub mut:
|
||||
id string
|
||||
user_id string
|
||||
items []OrderItem
|
||||
subtotal_base f64 // Using f64 for Decimal
|
||||
total_base f64 // Using f64 for Decimal
|
||||
base_currency string
|
||||
currency_used string
|
||||
currency_total f64 // Using f64 for Decimal
|
||||
conversion_rate f64 // Using f64 for Decimal
|
||||
status OrderStatus
|
||||
payment_method string
|
||||
payment_details PaymentDetails
|
||||
billing_address Address
|
||||
shipping_address Address
|
||||
notes string
|
||||
purchase_type PurchaseType
|
||||
created_at u64 // Unix timestamp
|
||||
updated_at u64 // Unix timestamp
|
||||
}
|
||||
|
||||
pub struct OrderItem {
|
||||
pub mut:
|
||||
product_id string
|
||||
product_name string
|
||||
product_category string
|
||||
quantity u32
|
||||
unit_price_base f64 // Using f64 for Decimal
|
||||
total_price_base f64 // Using f64 for Decimal
|
||||
specifications map[string]string // Using map[string]string for HashMap<String, serde_json::Value>
|
||||
provider_id string
|
||||
provider_name string
|
||||
}
|
||||
|
||||
pub enum OrderStatus {
|
||||
pending
|
||||
confirmed
|
||||
processing
|
||||
deployed
|
||||
completed
|
||||
cancelled
|
||||
refunded
|
||||
failed
|
||||
}
|
||||
|
||||
// Purchase type to distinguish between cart-based and instant purchases
|
||||
pub enum PurchaseType {
|
||||
cart
|
||||
instant
|
||||
}
|
||||
|
||||
pub struct PaymentDetails {
|
||||
pub mut:
|
||||
payment_id string
|
||||
payment_method PaymentMethod
|
||||
transaction_id string
|
||||
payment_status PaymentStatus
|
||||
payment_timestamp u64 // Unix timestamp
|
||||
failure_reason string
|
||||
}
|
||||
|
||||
pub enum PaymentMethod {
|
||||
credit_card // CreditCard { last_four: String, card_type: String }
|
||||
bank_transfer // BankTransfer { bank_name: String, account_last_four: String }
|
||||
cryptocurrency // Cryptocurrency { currency: String, wallet_address: String }
|
||||
token // Token { token_type: String, wallet_address: String }
|
||||
mock // Mock { method_name: String }
|
||||
}
|
||||
|
||||
pub struct Address {
|
||||
pub mut:
|
||||
street string
|
||||
city string
|
||||
state string
|
||||
postal_code string
|
||||
country string
|
||||
company string
|
||||
}
|
||||
|
||||
// Shopping Cart Models
|
||||
pub struct CartItem {
|
||||
pub mut:
|
||||
product_id string
|
||||
quantity u32
|
||||
selected_specifications map[string]string // Using map[string]string for HashMap<String, serde_json::Value>
|
||||
added_at u64 // Unix timestamp
|
||||
updated_at u64 // Unix timestamp
|
||||
}
|
||||
|
||||
pub struct Cart {
|
||||
pub mut:
|
||||
user_id string
|
||||
items []CartItem
|
||||
session_id string
|
||||
created_at u64 // Unix timestamp
|
||||
updated_at u64 // Unix timestamp
|
||||
}
|
||||
|
||||
// Order summary for display purposes
|
||||
pub struct OrderSummary {
|
||||
pub mut:
|
||||
subtotal f64 // Using f64 for Decimal
|
||||
tax f64 // Using f64 for Decimal
|
||||
shipping f64 // Using f64 for Decimal
|
||||
discount f64 // Using f64 for Decimal
|
||||
total f64 // Using f64 for Decimal
|
||||
currency string
|
||||
item_count u32
|
||||
}
|
Reference in New Issue
Block a user