Subversion Repositories SmartDukaan

Rev

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

Rev 1859 Rev 1976
Line 1... Line 1...
1
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress,\
1
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress,\
2
    Phone as TPhone, SocialHandles as TSocialHandles, UserCommunication as TUserCommunication,\
2
    Phone as TPhone, SocialHandles as TSocialHandles, UserCommunication as TUserCommunication,\
3
    UserState as TUserState, User as TUser, Cart as TCart, Line as TLine, Sex as TSex,\
3
    UserState as TUserState, User as TUser, Cart as TCart, Line as TLine, Sex as TSex,\
4
    Tracker as TTracker, MasterAffiliate as TMasterAffiliate, Affiliate as TAffiliate, TrackLog as TTrackLog
4
    Tracker as TTracker, MasterAffiliate as TMasterAffiliate, Affiliate as TAffiliate, TrackLog as TTrackLog,\
-
 
5
    Promotion as TPromotion, Coupon as TCoupon
5
from shop2020.utils.Utils import to_java_date
6
from shop2020.utils.Utils import to_java_date
6
 
7
 
7
def to_t_address(address):
8
def to_t_address(address):
8
    t_address = TAddress()
9
    t_address = TAddress()
9
    t_address.id = address.id
10
    t_address.id = address.id
Line 91... Line 92...
91
        lines = []
92
        lines = []
92
        if cart.lines:
93
        if cart.lines:
93
            for line in cart.lines:
94
            for line in cart.lines:
94
                lines.append(to_t_line(line))
95
                lines.append(to_t_line(line))
95
        t_cart.lines = lines
96
        t_cart.lines = lines
-
 
97
        t_cart.totalPrice = cart.total_price
-
 
98
        t_cart.discountedPrice = cart.discounted_price
-
 
99
        t_cart.couponCode = cart.coupon_code
96
        t_cart.createdOn = to_java_date(cart.created_on)
100
        t_cart.createdOn = to_java_date(cart.created_on)
97
        t_cart.updatedOn = to_java_date(cart.updated_on)
101
        t_cart.updatedOn = to_java_date(cart.updated_on)
98
        t_cart.userId = cart.user_id
102
        t_cart.userId = cart.user_id
99
        t_cart.addressId = cart.address_id
103
        t_cart.addressId = cart.address_id
100
        t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
104
        t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
Line 105... Line 109...
105
    if line:
109
    if line:
106
        t_line.cartId = line.cart_id
110
        t_line.cartId = line.cart_id
107
        t_line.itemId = line.item_id
111
        t_line.itemId = line.item_id
108
        t_line.quantity = line.quantity
112
        t_line.quantity = line.quantity
109
        t_line.estimate = line.estimate
113
        t_line.estimate = line.estimate
-
 
114
        t_line.actualPrice = line.actual_price
-
 
115
        t_line.discountedPrice = line.discounted_price
110
        t_line.createdOn = to_java_date(line.created_on)
116
        t_line.createdOn = to_java_date(line.created_on)
111
        t_line.updatedOn = to_java_date(line.updated_on)
117
        t_line.updatedOn = to_java_date(line.updated_on)
112
        t_line.lineStatus = line.line_status
118
        t_line.lineStatus = line.line_status
113
    return t_line
119
    return t_line
114
 
120
 
Line 171... Line 177...
171
        t_track_log.event = track_log.event
177
        t_track_log.event = track_log.event
172
        t_track_log.url = track_log.url
178
        t_track_log.url = track_log.url
173
        t_track_log.data = track_log.data
179
        t_track_log.data = track_log.data
174
        t_track_log.addedOn = to_java_date(track_log.added_on)
180
        t_track_log.addedOn = to_java_date(track_log.added_on)
175
 
181
 
176
    return t_track_log
-
 
177
182
    return t_track_log
-
 
183
 
-
 
184
def to_t_promotion(promotion):
-
 
185
    t_promotion = TPromotion()
-
 
186
    
-
 
187
    if promotion:
-
 
188
        t_promotion.id = promotion.id
-
 
189
        t_promotion.name = promotion.name
-
 
190
        t_promotion.ruleExecutionSrc = promotion.rule_execution_src
-
 
191
        t_promotion.startOn = to_java_date(promotion.start_on)
-
 
192
        t_promotion.endOn = to_java_date(promotion.end_on)
-
 
193
        
-
 
194
        #if promotion.coupons:
-
 
195
        #    t_promotion.coupons = [to_t_coupon(coupon) for coupon in promotion.coupons]
-
 
196
        
-
 
197
        t_promotion.createdOn = to_java_date(promotion.created_on)
-
 
198
    return t_promotion
-
 
199
 
-
 
200
def to_t_coupon(coupon):
-
 
201
    t_coupon = TCoupon()
-
 
202
 
-
 
203
    if coupon:
-
 
204
        t_coupon.code = coupon.code
-
 
205
        t_coupon.promotion_id = coupon.promotion_id
-
 
206
        t_coupon.arguments = coupon.arguments
-
 
207
    
-
 
208
    return t_coupon
-
 
209
178
210