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