-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder.py
47 lines (40 loc) · 1.87 KB
/
order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from datetime import date, timedelta
from enum import Enum
from shipping_address import ShippingAddress
class OrderStatus(Enum):
pending_payment = 0
preparing_order = 1
on_route = 2
cancelled_refunded = 3
class Order:
order_id_counter = 0
tracking_number_counter = 0
def __init__(self, payment_method = "", total_price = 0, discounted_price = 0, status: str = "", items: list = [], shipping_address: ShippingAddress = None):
self.__order_date = date.today()
self.__delivery_expect_date = self.__order_date + timedelta(days = 4)
self.__payment_method = payment_method
self.__total_price = total_price
self.__discounted_price = discounted_price
self.__status = status
self.__items_list = items
self.__shipping_address = shipping_address
Order.order_id_counter += 1
Order.tracking_number_counter += 1
self.__tracking_number = Order.tracking_number_counter
self.__order_id = Order.order_id_counter
def get_order(self):
return {"order_date": self.__order_date,
"delivery_expect_date": self.__delivery_expect_date,
"payment_method": self.__payment_method,
"tracking_number": str(self.__tracking_number),
"total_price": float(self.__total_price),
"discounted_price": float(self.__discounted_price),
"order_id": str(self.__order_id),
"status": self.__status,
"items_list": self.__items_list,
"shipping_address": self.__shipping_address
}
def get_order_id(self):
return self.__order_id
def update_status(self, new_status: int):
self.__status = OrderStatus(new_status).name