| 9651 |
manish.sha |
1 |
from shop2020.model.v1.order.impl import DataService
|
|
|
2 |
from shop2020.clients.UserClient import UserClient
|
|
|
3 |
from elixir import *
|
|
|
4 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, cast, \
|
|
|
5 |
between
|
|
|
6 |
from shop2020.model.v1.order.impl.DataService import Order
|
|
|
7 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
|
|
8 |
from shop2020.thriftpy.model.v1.user.ttypes import User, Sex
|
|
|
9 |
import time
|
|
|
10 |
|
|
|
11 |
def change_email_other_sources_orders():
|
|
|
12 |
DataService.initialize('transaction','192.168.190.114')
|
|
|
13 |
user_client = UserClient().get_client()
|
|
|
14 |
other_source_orders = Order.query.filter(Order.source == OrderSource.FLIPKART).filter(or_(Order.source == OrderSource.SNAPDEAL)).all()
|
|
|
15 |
for order in other_source_orders:
|
|
|
16 |
user = None
|
|
|
17 |
if order.source == OrderSource.FLIPKART :
|
|
|
18 |
try:
|
|
|
19 |
user_to_add = User()
|
|
|
20 |
user_to_add.email = 'FK.'+ order.id + '@mailinator.com'
|
|
|
21 |
user_to_add.password = 'gR9zF-Ish2im6tbYFNivgA'
|
|
|
22 |
user_to_add.communicationEmail = user.email
|
|
|
23 |
user_to_add.sourceStartTime = int(round(time.time() * 1000))
|
|
|
24 |
user_to_add.source = 'FLIPKART'
|
|
|
25 |
user_to_add.sex = Sex.WONT_SAY
|
|
|
26 |
user_to_add = user_client.createUser(user_to_add)
|
|
|
27 |
user = user_to_add
|
|
|
28 |
except:
|
|
|
29 |
pass
|
|
|
30 |
if order.source == OrderSource.SNAPDEAL :
|
|
|
31 |
user = None
|
|
|
32 |
try:
|
|
|
33 |
user_client = UserClient().get_client()
|
|
|
34 |
user_to_add = User()
|
|
|
35 |
user_to_add.email = 'SD.'+ order.id + '@mailinator.com'
|
|
|
36 |
user_to_add.password = 'hSp5gvCsrrhZcceE6mzzOQ'
|
|
|
37 |
user_to_add.communicationEmail = user.email
|
|
|
38 |
user_to_add.sourceStartTime = int(round(time.time() * 1000))
|
|
|
39 |
user_to_add.source = 'SNAPDEAL'
|
|
|
40 |
user_to_add.sex = Sex.WONT_SAY
|
|
|
41 |
user_to_add = user_client.createUser(user_to_add)
|
|
|
42 |
user = user_to_add
|
|
|
43 |
except:
|
|
|
44 |
pass
|
|
|
45 |
if user:
|
|
|
46 |
order.customer_id = user.userId
|
|
|
47 |
order.customer_email = user.email
|
|
|
48 |
session.commit()
|
|
|
49 |
return True
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
def main():
|
|
|
53 |
change_email_other_sources_orders()
|
|
|
54 |
|
|
|
55 |
if __name__ == '__main__':
|
|
|
56 |
main()
|