| Line 1... |
Line 1... |
| 1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress, Phone as TPhone, \
|
1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress, UserCommunication as TUserCommunication, \
|
| 2 |
SocialHandles as TSocialHandles, UserCommunication as TUserCommunication, UserState as TUserState, \
|
- |
|
| 3 |
User as TUser, Cart as TCart, Line as TLine, Sex as TSex, MasterAffiliate as TMasterAffiliate, \
|
2 |
User as TUser, Cart as TCart, Line as TLine, MasterAffiliate as TMasterAffiliate, \
|
| 4 |
Affiliate as TAffiliate, Tracker as TTracker, TrackLog as TTrackLog, Promotion as TPromotion, \
|
3 |
Affiliate as TAffiliate, Tracker as TTracker, TrackLog as TTrackLog, Promotion as TPromotion, \
|
| 5 |
Coupon as TCoupon, UserNote as TUserNote, Discount as TDiscount, ItemCouponDiscount as TItemCouponDiscount
|
4 |
Coupon as TCoupon, UserNote as TUserNote, Discount as TDiscount, ItemCouponDiscount as TItemCouponDiscount
|
| 6 |
|
5 |
|
| 7 |
from shop2020.utils.Utils import to_java_date
|
6 |
from shop2020.utils.Utils import to_java_date
|
| 8 |
|
7 |
|
| Line 33... |
Line 32... |
| 33 |
t_user.name = user.name
|
32 |
t_user.name = user.name
|
| 34 |
t_user.email = user.email
|
33 |
t_user.email = user.email
|
| 35 |
t_user.password = user.password
|
34 |
t_user.password = user.password
|
| 36 |
t_user.sex = user.sex
|
35 |
t_user.sex = user.sex
|
| 37 |
|
36 |
|
| 38 |
t_user.socialHandles = to_t_social_handle(user.social_handles)
|
- |
|
| 39 |
t_user.communicationEmail = user.communication_email
|
37 |
t_user.communicationEmail = user.communication_email
|
| 40 |
t_user.defaultAddressId = user.default_address_id
|
38 |
t_user.defaultAddressId = user.default_address_id
|
| 41 |
t_user.isAnonymous = user.is_anonymous
|
39 |
t_user.isAnonymous = user.is_anonymous
|
| 42 |
t_user.activeCartId = user.active_cart_id
|
40 |
t_user.activeCartId = user.active_cart_id
|
| 43 |
t_user.dateOfBirth = user.date_of_birth
|
41 |
t_user.dateOfBirth = user.date_of_birth
|
| 44 |
t_user.mobileNumber = user.mobile_number
|
42 |
t_user.mobileNumber = user.mobile_number
|
| 45 |
t_user.source = user.source
|
43 |
t_user.source = user.source
|
| 46 |
t_user.sourceStartTime = to_java_date(user.source_start_time)
|
44 |
t_user.sourceStartTime = to_java_date(user.source_start_time)
|
| 47 |
t_user.trustLevel = user.trust_level
|
45 |
t_user.trustLevel = user.trust_level
|
| - |
|
46 |
t_user.lastLogin = to_java_date(user.last_login)
|
| - |
|
47 |
t_user.lastLogout = to_java_date(user.last_logout)
|
| - |
|
48 |
t_user.activeSince = to_java_date(user.active_since)
|
| 48 |
#put all addresses
|
49 |
#put all addresses
|
| 49 |
if user.addresses:
|
50 |
if user.addresses:
|
| 50 |
t_user.addresses = list()
|
51 |
t_user.addresses = list()
|
| 51 |
for address in user.addresses:
|
52 |
for address in user.addresses:
|
| 52 |
t_user.addresses.append(to_t_address(address))
|
53 |
t_user.addresses.append(to_t_address(address))
|
| 53 |
return t_user
|
54 |
return t_user
|
| 54 |
|
55 |
|
| 55 |
def to_t_internal_info(internal_info):
|
- |
|
| 56 |
pass
|
- |
|
| 57 |
|
- |
|
| 58 |
def to_t_user_state(user_state):
|
- |
|
| 59 |
t_user_state = TUserState()
|
- |
|
| 60 |
t_user_state.userId = user_state.user.id
|
- |
|
| 61 |
t_user_state.lastLogin = to_java_date(user_state.last_login)
|
- |
|
| 62 |
t_user_state.lastLogout = to_java_date(user_state.last_logout)
|
- |
|
| 63 |
t_user_state.emailVerificationSentOn = to_java_date(user_state.email_verification_sent_on)
|
- |
|
| 64 |
t_user_state.smsVerificationSentOn = to_java_date(user_state.sms_verification_sent_on)
|
- |
|
| 65 |
t_user_state.isEmailVerified = user_state.is_email_verified
|
- |
|
| 66 |
t_user_state.isSMSVerified = user_state.is_sms_verified
|
- |
|
| 67 |
t_user_state.activeSince = to_java_date(user_state.active_since)
|
- |
|
| 68 |
t_user_state.status = user_state.account_status
|
- |
|
| 69 |
return t_user_state
|
- |
|
| 70 |
|
- |
|
| 71 |
def to_t_phone(phone):
|
- |
|
| 72 |
t_phone = TPhone()
|
- |
|
| 73 |
t_phone.areaCode = phone.area_code
|
- |
|
| 74 |
t_phone.countryCode = phone.country_code
|
- |
|
| 75 |
t_phone.extension = phone.extension
|
- |
|
| 76 |
t_phone.number = phone.number
|
- |
|
| 77 |
t_phone.type = phone.type
|
- |
|
| 78 |
return t_phone
|
- |
|
| 79 |
|
- |
|
| 80 |
def to_t_social_handle(social_handles):
|
- |
|
| 81 |
t_socialHandle = TSocialHandles()
|
- |
|
| 82 |
for social_handle in social_handles:
|
- |
|
| 83 |
if social_handle.service.name == "Facebook":
|
- |
|
| 84 |
t_socialHandle.facebook = social_handle.handle
|
- |
|
| 85 |
if social_handle.service.name == "OpenSocial":
|
- |
|
| 86 |
t_socialHandle.opensocial = social_handle.handle
|
- |
|
| 87 |
if social_handle.service.name == "Twitter":
|
- |
|
| 88 |
t_socialHandle.twitter = social_handle.handle
|
- |
|
| 89 |
return t_socialHandle
|
- |
|
| 90 |
|
- |
|
| 91 |
def to_t_cart(cart):
|
56 |
def to_t_cart(cart):
|
| 92 |
t_cart = TCart()
|
57 |
t_cart = TCart()
|
| 93 |
if cart:
|
58 |
if cart:
|
| 94 |
t_cart.id = cart.id
|
59 |
t_cart.id = cart.id
|
| 95 |
t_cart.status = cart.cart_status
|
60 |
t_cart.status = cart.cart_status
|
| Line 101... |
Line 66... |
| 101 |
t_cart.totalPrice = cart.total_price
|
66 |
t_cart.totalPrice = cart.total_price
|
| 102 |
t_cart.discountedPrice = cart.discounted_price
|
67 |
t_cart.discountedPrice = cart.discounted_price
|
| 103 |
t_cart.couponCode = cart.coupon_code
|
68 |
t_cart.couponCode = cart.coupon_code
|
| 104 |
t_cart.createdOn = to_java_date(cart.created_on)
|
69 |
t_cart.createdOn = to_java_date(cart.created_on)
|
| 105 |
t_cart.updatedOn = to_java_date(cart.updated_on)
|
70 |
t_cart.updatedOn = to_java_date(cart.updated_on)
|
| 106 |
t_cart.userId = cart.user_id
|
- |
|
| 107 |
t_cart.addressId = cart.address_id
|
71 |
t_cart.addressId = cart.address_id
|
| 108 |
t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
|
72 |
t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
|
| 109 |
return t_cart
|
73 |
return t_cart
|
| 110 |
|
74 |
|
| 111 |
def to_t_line(line):
|
75 |
def to_t_line(line):
|