Subversion Repositories SmartDukaan

Rev

Rev 6000 | Rev 6147 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6000 Rev 6031
Line 5... Line 5...
5
'''
5
'''
6
from elixir.entity import Entity
6
from elixir.entity import Entity
7
from elixir.fields import Field
7
from elixir.fields import Field
8
from elixir.options import using_options, using_table_options
8
from elixir.options import using_options, using_table_options
9
from sqlalchemy.types import Enum, Integer, DateTime, String
9
from sqlalchemy.types import Enum, Integer, DateTime, String
-
 
10
from elixir.relationships import ManyToOne
-
 
11
import datetime
-
 
12
from shop2020.utils.Utils import to_java_date
10
 
13
 
11
class BaseOrder(Entity):
14
class BaseOrder(Entity):
12
    '''
15
    '''
13
    classdocs
16
    classdocs
14
    '''
17
    '''
15
    id = Field(Integer, primary_key=True, autoincrement=True)
18
    id = Field(Integer, primary_key=True, autoincrement=True)
16
    idPrefix = Field(String(8))
19
    idPrefix = Field(String(8))
17
    transactionId = Field(Integer)
20
    transaction = ManyToOne("DigitalTransaction")
18
    creationTimestamp = Field(DateTime)
21
    creationTimestamp = Field(DateTime)
19
    amount = Field(Integer)
22
    totalAmount = Field(Integer)
-
 
23
    walletAmount = Field(Integer)
20
    customerId = Field(Integer)
24
    userId = Field(Integer)
21
    customerEmailId = Field(String(256))
25
    userEmailId = Field(String(256))
22
    invoiceNumber = Field(Integer)
26
    invoiceNumber = Field(Integer)
23
    orderType = Field(Enum('B2C', 'B2Cbulk', 'B2B'))
27
    orderType = Field(Integer)
24
    using_options(shortnames=True, inheritance='multi')
28
    using_options(shortnames=True, inheritance='multi')
25
    using_table_options(mysql_engine="InnoDB")
29
    using_table_options(mysql_engine="InnoDB")
26
 
30
 
27
    def __init__(self):
31
    def __init__(self):
28
        '''
32
        '''
Line 31... Line 35...
31
 
35
 
32
    def to_thrift_object(self, thriftObject):
36
    def to_thrift_object(self, thriftObject):
33
        '''
37
        '''
34
        Copies attributes to thrift object
38
        Copies attributes to thrift object
35
        '''
39
        '''
36
        thriftObject.amount = self.amount
40
        thriftObject.totalAmount = self.totalAmount
-
 
41
        thriftObject.walletAmount = self.walletAmount
37
        thriftObject.creationTimestamp = self.creationTimestamp
42
        thriftObject.creationTimestamp = to_java_date(self.creationTimestamp)
38
        thriftObject.customerEmailId = self.customerEmailId
43
        thriftObject.userEmailId = self.userEmailId
39
        thriftObject.customerId = self.customerId
44
        thriftObject.userId = self.userId
-
 
45
        thriftObject.id = self.id
40
        thriftObject.id = self.idPrefix + self.id
46
        thriftObject.displayId = self.idPrefix + str(self.id)
41
        thriftObject.invoiceNumber = self.invoiceNumber
47
        thriftObject.invoiceNumber = self.invoiceNumber
42
        thriftObject.orderType = self.orderType
48
        thriftObject.orderType = self.orderType
43
        thriftObject.transactionId = self.transactionId
49
        thriftObject.transactionId = self.transaction.id
44
 
50
 
45
    def from_thrift_object(self, thriftBaseOrder):
51
    def from_thrift_object(self, thriftBaseOrder):
46
        self.amount = thriftBaseOrder.amount
52
        self.totalAmount = thriftBaseOrder.totalAmount
47
        self.creationTimestamp = thriftBaseOrder.creationTimestamp
53
        self.walletAmount = thriftBaseOrder.walletAmount
48
        self.customerEmailId = thriftBaseOrder.customerEmailId
54
        self.creationTimestamp = datetime.datetime.now()
49
        self.customerId = thriftBaseOrder.customerId
55
        self.userEmailId = thriftBaseOrder.userEmailId
50
        self.id = thriftBaseOrder.id.split(self.idPrefix)[1]
56
        self.userId = thriftBaseOrder.userId
51
        self.invoiceNumber = thriftBaseOrder.invoiceNumber
57
        self.invoiceNumber = thriftBaseOrder.invoiceNumber
52
        self.orderType = thriftBaseOrder.orderType
58
        self.orderType = thriftBaseOrder.orderType
53
        self.transactionId = thriftBaseOrder.transactionId
-
 
54
 
59
 
55
    def is_valid(self):
60
    def is_valid(self):
56
        return True
61
        return True
57
62