| 6000 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 11-Sep-2012
|
|
|
3 |
|
|
|
4 |
@author: mandeep
|
|
|
5 |
'''
|
|
|
6 |
from elixir.entity import Entity
|
|
|
7 |
from elixir.fields import Field
|
|
|
8 |
from elixir.options import using_options, using_table_options
|
|
|
9 |
from sqlalchemy.types import Enum, Integer, DateTime, String
|
| 6031 |
rajveer |
10 |
from elixir.relationships import ManyToOne
|
|
|
11 |
import datetime
|
| 6515 |
anupam.sin |
12 |
from shop2020.utils.Utils import to_java_date, to_py_date
|
| 6147 |
rajveer |
13 |
import DigitalTransaction
|
| 6000 |
mandeep.dh |
14 |
|
|
|
15 |
class BaseOrder(Entity):
|
|
|
16 |
'''
|
|
|
17 |
classdocs
|
|
|
18 |
'''
|
|
|
19 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
20 |
idPrefix = Field(String(8))
|
| 6031 |
rajveer |
21 |
transaction = ManyToOne("DigitalTransaction")
|
| 6000 |
mandeep.dh |
22 |
creationTimestamp = Field(DateTime)
|
| 6031 |
rajveer |
23 |
totalAmount = Field(Integer)
|
|
|
24 |
walletAmount = Field(Integer)
|
| 6433 |
anupam.sin |
25 |
couponAmount = Field(Integer, default=0)
|
|
|
26 |
couponCode = Field(String(256))
|
| 6031 |
rajveer |
27 |
userId = Field(Integer)
|
|
|
28 |
userEmailId = Field(String(256))
|
| 6000 |
mandeep.dh |
29 |
invoiceNumber = Field(Integer)
|
| 6031 |
rajveer |
30 |
orderType = Field(Integer)
|
| 6515 |
anupam.sin |
31 |
refundTimestamp = Field(DateTime)
|
| 6591 |
anupam.sin |
32 |
ipAddress = Field(String(256))
|
| 6000 |
mandeep.dh |
33 |
using_options(shortnames=True, inheritance='multi')
|
|
|
34 |
using_table_options(mysql_engine="InnoDB")
|
|
|
35 |
|
|
|
36 |
def __init__(self):
|
|
|
37 |
'''
|
|
|
38 |
Constructor
|
|
|
39 |
'''
|
|
|
40 |
|
|
|
41 |
def to_thrift_object(self, thriftObject):
|
|
|
42 |
'''
|
|
|
43 |
Copies attributes to thrift object
|
|
|
44 |
'''
|
| 6031 |
rajveer |
45 |
thriftObject.totalAmount = self.totalAmount
|
|
|
46 |
thriftObject.walletAmount = self.walletAmount
|
| 6433 |
anupam.sin |
47 |
thriftObject.couponAmount = self.couponAmount
|
|
|
48 |
thriftObject.couponCode = self.couponCode
|
| 6031 |
rajveer |
49 |
thriftObject.creationTimestamp = to_java_date(self.creationTimestamp)
|
|
|
50 |
thriftObject.userEmailId = self.userEmailId
|
|
|
51 |
thriftObject.userId = self.userId
|
|
|
52 |
thriftObject.id = self.id
|
|
|
53 |
thriftObject.displayId = self.idPrefix + str(self.id)
|
| 6000 |
mandeep.dh |
54 |
thriftObject.invoiceNumber = self.invoiceNumber
|
|
|
55 |
thriftObject.orderType = self.orderType
|
| 6031 |
rajveer |
56 |
thriftObject.transactionId = self.transaction.id
|
| 6515 |
anupam.sin |
57 |
thriftObject.refundTimestamp = to_java_date(self.refundTimestamp)
|
| 6591 |
anupam.sin |
58 |
thriftObject.ipAddress = self.ipAddress
|
| 6000 |
mandeep.dh |
59 |
|
|
|
60 |
def from_thrift_object(self, thriftBaseOrder):
|
| 6031 |
rajveer |
61 |
self.totalAmount = thriftBaseOrder.totalAmount
|
|
|
62 |
self.walletAmount = thriftBaseOrder.walletAmount
|
|
|
63 |
self.creationTimestamp = datetime.datetime.now()
|
|
|
64 |
self.userEmailId = thriftBaseOrder.userEmailId
|
|
|
65 |
self.userId = thriftBaseOrder.userId
|
| 6000 |
mandeep.dh |
66 |
self.invoiceNumber = thriftBaseOrder.invoiceNumber
|
|
|
67 |
self.orderType = thriftBaseOrder.orderType
|
| 6443 |
anupam.sin |
68 |
self.couponAmount = thriftBaseOrder.couponAmount
|
|
|
69 |
self.couponCode = thriftBaseOrder.couponCode
|
| 6597 |
rajveer |
70 |
if thriftBaseOrder.refundTimestamp:
|
|
|
71 |
self.refundTimestamp = to_py_date(thriftBaseOrder.refundTimestamp)
|
| 6591 |
anupam.sin |
72 |
self.ipAddress = thriftBaseOrder.ipAddress
|
| 6000 |
mandeep.dh |
73 |
|
|
|
74 |
def is_valid(self):
|
|
|
75 |
return True
|