| 5326 |
rajveer |
1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress, UserCommunication as TUserCommunication, \
|
|
|
2 |
User as TUser, Cart as TCart, Line as TLine, MasterAffiliate as TMasterAffiliate, \
|
| 4189 |
varun.gupt |
3 |
Affiliate as TAffiliate, Tracker as TTracker, TrackLog as TTrackLog, Promotion as TPromotion, \
|
| 6394 |
amit.gupta |
4 |
Coupon as TCoupon, Discount as TDiscount, ItemCouponDiscount as TItemCouponDiscount,\
|
| 12722 |
amit.gupta |
5 |
Voucher, CouponCategory, PrivateDealUser as TPrivateDealUser, Counter as TCounter
|
| 4189 |
varun.gupt |
6 |
|
| 130 |
ashish |
7 |
from shop2020.utils.Utils import to_java_date
|
| 12722 |
amit.gupta |
8 |
from shop2020.model.v1.user.impl.Dataservice import Counter
|
| 130 |
ashish |
9 |
|
|
|
10 |
def to_t_address(address):
|
|
|
11 |
t_address = TAddress()
|
|
|
12 |
t_address.id = address.id
|
|
|
13 |
t_address.line1 = address.line_1
|
|
|
14 |
t_address.line2 = address.line_2
|
|
|
15 |
t_address.landmark = address.landmark
|
|
|
16 |
t_address.city = address.city
|
|
|
17 |
t_address.state = address.state
|
|
|
18 |
t_address.pin = address.pin
|
|
|
19 |
t_address.country = address.country
|
|
|
20 |
t_address.enabled = address.enabled
|
|
|
21 |
t_address.type = address.type
|
|
|
22 |
t_address.addedOn = to_java_date(address.added_on)
|
| 414 |
ashish |
23 |
t_address.name = address.name
|
|
|
24 |
t_address.phone = address.phone
|
| 557 |
chandransh |
25 |
return t_address
|
| 130 |
ashish |
26 |
|
| 557 |
chandransh |
27 |
def to_t_user(user):
|
|
|
28 |
t_user = TUser()
|
| 576 |
chandransh |
29 |
if user is None:
|
|
|
30 |
t_user.userId = -1
|
|
|
31 |
return t_user
|
|
|
32 |
|
| 557 |
chandransh |
33 |
t_user.userId = user.id
|
|
|
34 |
t_user.name = user.name
|
|
|
35 |
t_user.email = user.email
|
| 619 |
rajveer |
36 |
t_user.password = user.password
|
| 557 |
chandransh |
37 |
t_user.sex = user.sex
|
|
|
38 |
|
|
|
39 |
t_user.communicationEmail = user.communication_email
|
|
|
40 |
t_user.defaultAddressId = user.default_address_id
|
|
|
41 |
t_user.isAnonymous = user.is_anonymous
|
|
|
42 |
t_user.activeCartId = user.active_cart_id
|
| 567 |
rajveer |
43 |
t_user.dateOfBirth = user.date_of_birth
|
|
|
44 |
t_user.mobileNumber = user.mobile_number
|
| 2020 |
vikas |
45 |
t_user.source = user.source
|
| 2815 |
vikas |
46 |
t_user.sourceStartTime = to_java_date(user.source_start_time)
|
| 3499 |
mandeep.dh |
47 |
t_user.trustLevel = user.trust_level
|
| 5326 |
rajveer |
48 |
t_user.lastLogin = to_java_date(user.last_login)
|
|
|
49 |
t_user.lastLogout = to_java_date(user.last_logout)
|
|
|
50 |
t_user.activeSince = to_java_date(user.active_since)
|
| 7883 |
rajveer |
51 |
t_user.isFacebookUser = False
|
|
|
52 |
if user.fbusers and user.fbusers[0]:
|
|
|
53 |
t_user.isFacebookUser = True
|
|
|
54 |
t_user.facebookAccessToken = user.fbusers[0].facebook_access_token
|
|
|
55 |
t_user.facebookId = user.fbusers[0].facebook_id
|
| 8201 |
rajveer |
56 |
|
|
|
57 |
t_user.sourceId = 1
|
|
|
58 |
#put source
|
|
|
59 |
if user.sources and user.sources[0]:
|
|
|
60 |
t_user.sourceId = user.sources[0].source_id
|
|
|
61 |
|
| 130 |
ashish |
62 |
#put all addresses
|
| 557 |
chandransh |
63 |
if user.addresses:
|
|
|
64 |
t_user.addresses = list()
|
|
|
65 |
for address in user.addresses:
|
|
|
66 |
t_user.addresses.append(to_t_address(address))
|
|
|
67 |
return t_user
|
| 513 |
rajveer |
68 |
|
| 557 |
chandransh |
69 |
def to_t_cart(cart):
|
|
|
70 |
t_cart = TCart()
|
|
|
71 |
if cart:
|
|
|
72 |
t_cart.id = cart.id
|
|
|
73 |
t_cart.status = cart.cart_status
|
|
|
74 |
lines = []
|
|
|
75 |
if cart.lines:
|
|
|
76 |
for line in cart.lines:
|
|
|
77 |
lines.append(to_t_line(line))
|
|
|
78 |
t_cart.lines = lines
|
| 1976 |
varun.gupt |
79 |
t_cart.totalPrice = cart.total_price
|
|
|
80 |
t_cart.discountedPrice = cart.discounted_price
|
|
|
81 |
t_cart.couponCode = cart.coupon_code
|
| 557 |
chandransh |
82 |
t_cart.createdOn = to_java_date(cart.created_on)
|
|
|
83 |
t_cart.updatedOn = to_java_date(cart.updated_on)
|
|
|
84 |
t_cart.addressId = cart.address_id
|
| 690 |
chandransh |
85 |
t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
|
| 5555 |
rajveer |
86 |
t_cart.pickupStoreId = cart.pickupStoreId
|
| 557 |
chandransh |
87 |
return t_cart
|
|
|
88 |
|
| 612 |
chandransh |
89 |
def to_t_line(line):
|
|
|
90 |
t_line = TLine()
|
|
|
91 |
if line:
|
| 643 |
chandransh |
92 |
t_line.cartId = line.cart_id
|
| 612 |
chandransh |
93 |
t_line.itemId = line.item_id
|
|
|
94 |
t_line.quantity = line.quantity
|
|
|
95 |
t_line.estimate = line.estimate
|
| 1976 |
varun.gupt |
96 |
t_line.actualPrice = line.actual_price
|
|
|
97 |
t_line.discountedPrice = line.discounted_price
|
| 3554 |
varun.gupt |
98 |
t_line.discounts = [to_t_discount(discount) for discount in line.discounts]
|
| 612 |
chandransh |
99 |
t_line.createdOn = to_java_date(line.created_on)
|
|
|
100 |
t_line.updatedOn = to_java_date(line.updated_on)
|
|
|
101 |
t_line.lineStatus = line.line_status
|
| 6903 |
anupam.sin |
102 |
t_line.insurer = line.insurer
|
|
|
103 |
t_line.insuranceAmount = line.insuranceAmount
|
| 9299 |
kshitij.so |
104 |
t_line.dataProtectionInsurer = line.dataProtectionInsurer
|
|
|
105 |
t_line.dataProtectionAmount = line.dataProtectionAmount
|
| 11656 |
amit.gupta |
106 |
t_line.freebieId = line.freebieId
|
|
|
107 |
t_line.dealText = line.dealText
|
| 612 |
chandransh |
108 |
return t_line
|
| 1583 |
varun.gupt |
109 |
|
| 3554 |
varun.gupt |
110 |
def to_t_discount(discount):
|
|
|
111 |
t_discount = TDiscount()
|
|
|
112 |
|
|
|
113 |
if discount:
|
|
|
114 |
t_discount.cart_id = discount.line_cart_id
|
|
|
115 |
t_discount.item_id = discount.line_item_id
|
|
|
116 |
t_discount.discount = discount.discount
|
|
|
117 |
t_discount.quantity = discount.quantity
|
|
|
118 |
|
|
|
119 |
return t_discount
|
|
|
120 |
|
| 1583 |
varun.gupt |
121 |
def to_t_user_communication(user_communication):
|
|
|
122 |
t_user_communication = TUserCommunication()
|
|
|
123 |
|
|
|
124 |
if user_communication:
|
|
|
125 |
t_user_communication.id = user_communication.id
|
| 1603 |
varun.gupt |
126 |
t_user_communication.userId = user_communication.user_id
|
|
|
127 |
t_user_communication.communicationType = user_communication.communication_type
|
|
|
128 |
t_user_communication.orderId = user_communication.order_id
|
|
|
129 |
t_user_communication.airwaybillNo = user_communication.airwaybill_no
|
|
|
130 |
t_user_communication.replyTo = user_communication.reply_to
|
|
|
131 |
t_user_communication.productName = user_communication.product_name
|
| 1583 |
varun.gupt |
132 |
t_user_communication.subject = user_communication.subject
|
|
|
133 |
t_user_communication.message = user_communication.message
|
|
|
134 |
t_user_communication.communication_timestamp = to_java_date(user_communication.communication_timestamp)
|
|
|
135 |
|
| 1845 |
vikas |
136 |
return t_user_communication
|
|
|
137 |
|
|
|
138 |
def to_t_master_affiliate(master_affiliate):
|
|
|
139 |
t_master_affiliate = TMasterAffiliate()
|
|
|
140 |
|
|
|
141 |
if master_affiliate:
|
|
|
142 |
t_master_affiliate.id = master_affiliate.id
|
|
|
143 |
t_master_affiliate.name = master_affiliate.name
|
| 1859 |
vikas |
144 |
t_master_affiliate.addedOn = to_java_date(master_affiliate.added_on)
|
| 1845 |
vikas |
145 |
|
|
|
146 |
return t_master_affiliate
|
|
|
147 |
|
|
|
148 |
def to_t_affiliate(affiliate):
|
|
|
149 |
t_affiliate = TAffiliate()
|
|
|
150 |
|
|
|
151 |
if affiliate:
|
|
|
152 |
t_affiliate.id = affiliate.id
|
|
|
153 |
t_affiliate.name = affiliate.name
|
|
|
154 |
t_affiliate.url = affiliate.url
|
|
|
155 |
t_affiliate.masterAffiliateId = affiliate.master_affiliate_id
|
| 1859 |
vikas |
156 |
t_affiliate.addedOn = to_java_date(affiliate.added_on)
|
| 1845 |
vikas |
157 |
|
|
|
158 |
return t_affiliate
|
|
|
159 |
|
|
|
160 |
def to_t_tracker(tracker):
|
|
|
161 |
t_tracker = TTracker()
|
|
|
162 |
|
|
|
163 |
if tracker:
|
|
|
164 |
t_tracker.id = tracker.id
|
|
|
165 |
t_tracker.affiliateId = tracker.affiliate_id
|
| 1997 |
vikas |
166 |
t_tracker.addedOn = to_java_date(tracker.added_on)
|
|
|
167 |
|
| 1845 |
vikas |
168 |
return t_tracker
|
|
|
169 |
|
|
|
170 |
def to_t_track_log(track_log):
|
|
|
171 |
t_track_log = TTrackLog()
|
|
|
172 |
|
|
|
173 |
if track_log:
|
|
|
174 |
t_track_log.id = track_log.id
|
| 1996 |
vikas |
175 |
t_track_log.affiliateId = track_log.affiliate_id
|
| 1845 |
vikas |
176 |
t_track_log.userId = track_log.user_id
|
| 3378 |
vikas |
177 |
t_track_log.eventType = track_log.event_id
|
| 1845 |
vikas |
178 |
t_track_log.url = track_log.url
|
|
|
179 |
t_track_log.data = track_log.data
|
| 1859 |
vikas |
180 |
t_track_log.addedOn = to_java_date(track_log.added_on)
|
| 1845 |
vikas |
181 |
|
| 1976 |
varun.gupt |
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)
|
| 6367 |
amit.gupta |
192 |
t_promotion.type = promotion.type
|
| 1976 |
varun.gupt |
193 |
t_promotion.endOn = to_java_date(promotion.end_on)
|
|
|
194 |
|
|
|
195 |
#if promotion.coupons:
|
|
|
196 |
# t_promotion.coupons = [to_t_coupon(coupon) for coupon in promotion.coupons]
|
|
|
197 |
|
|
|
198 |
t_promotion.createdOn = to_java_date(promotion.created_on)
|
|
|
199 |
return t_promotion
|
|
|
200 |
|
|
|
201 |
def to_t_coupon(coupon):
|
|
|
202 |
t_coupon = TCoupon()
|
|
|
203 |
|
|
|
204 |
if coupon:
|
| 3386 |
varun.gupt |
205 |
t_coupon.couponCode = coupon.coupon_code
|
|
|
206 |
t_coupon.promotion = to_t_promotion(coupon.promotion)
|
| 6571 |
amit.gupta |
207 |
t_coupon.arguments = coupon.arguments
|
| 8707 |
manish.sha |
208 |
if coupon.coupon_category:
|
|
|
209 |
t_coupon.coupon_category = CouponCategory._NAMES_TO_VALUES[coupon.coupon_category]
|
| 1976 |
varun.gupt |
210 |
|
| 1997 |
vikas |
211 |
return t_coupon
|
| 2641 |
varun.gupt |
212 |
|
| 4189 |
varun.gupt |
213 |
def to_t_item_coupon_discount(item_coupon_discount):
|
|
|
214 |
t_item_coupon_discount = TItemCouponDiscount()
|
|
|
215 |
|
|
|
216 |
if item_coupon_discount:
|
|
|
217 |
t_item_coupon_discount.itemId = item_coupon_discount[0]
|
|
|
218 |
t_item_coupon_discount.couponCode = item_coupon_discount[1]
|
|
|
219 |
t_item_coupon_discount.discount = item_coupon_discount[2]
|
|
|
220 |
|
| 5469 |
rajveer |
221 |
return t_item_coupon_discount
|
|
|
222 |
|
|
|
223 |
def to_t_voucher(voucher):
|
|
|
224 |
t_voucher = Voucher()
|
|
|
225 |
|
|
|
226 |
if voucher:
|
|
|
227 |
t_voucher.id = voucher.id
|
|
|
228 |
t_voucher.voucherCode = voucher.voucherCode
|
|
|
229 |
t_voucher.voucherType = voucher.voucherType
|
|
|
230 |
t_voucher.issuedOn = to_java_date(voucher.issuedOn)
|
|
|
231 |
t_voucher.expiredOn = to_java_date(voucher.expiredOn)
|
|
|
232 |
t_voucher.amount = voucher.amount
|
|
|
233 |
t_voucher.userEmail = voucher.email
|
| 11890 |
kshitij.so |
234 |
return t_voucher
|
|
|
235 |
|
|
|
236 |
def to_t_private_deal(privateDeal):
|
|
|
237 |
t_private_deal = TPrivateDealUser()
|
|
|
238 |
if privateDeal is not None:
|
|
|
239 |
t_private_deal.userId = privateDeal.id
|
|
|
240 |
t_private_deal.addedOn = to_java_date(privateDeal.created_on)
|
|
|
241 |
t_private_deal.isActive = privateDeal.isActive
|
|
|
242 |
return t_private_deal
|
| 12722 |
amit.gupta |
243 |
|
|
|
244 |
def to_t_counter(counter):
|
|
|
245 |
t_counter = TCounter()
|
| 12726 |
amit.gupta |
246 |
t_counter.code = counter.code
|
| 12722 |
amit.gupta |
247 |
t_counter.addedOn = to_java_date(counter.createdOn)
|
|
|
248 |
t_counter.alternateMobile = counter.alternateMobile
|
|
|
249 |
t_counter.mobile = counter.mobile
|
|
|
250 |
t_counter.dob = counter.dob
|
|
|
251 |
t_counter.name = counter.name
|
|
|
252 |
t_counter.ownerName = counter.ownerName
|
|
|
253 |
t_counter.id = counter.id
|
|
|
254 |
t_counter.address = counter.addressId
|
|
|
255 |
t_counter.email = counter.email
|
|
|
256 |
t_counter.fpCounterSize = counter.fpCounterSize
|
|
|
257 |
t_counter.spCounterSize = counter.spCounterSize
|
|
|
258 |
t_counter.striker = counter.striker
|
|
|
259 |
t_counter.tin = counter.tin
|
| 12733 |
amit.gupta |
260 |
return t_counter
|