| Line 13... |
Line 13... |
| 13 |
import MySQLdb as mdb
|
13 |
import MySQLdb as mdb
|
| 14 |
import _mysql
|
14 |
import _mysql
|
| 15 |
import smtplib
|
15 |
import smtplib
|
| 16 |
import sys
|
16 |
import sys
|
| 17 |
import re
|
17 |
import re
|
| - |
|
18 |
import traceback
|
| 18 |
|
19 |
|
| 19 |
|
20 |
|
| 20 |
|
21 |
|
| 21 |
# DataService.initialize()
|
22 |
# DataService.initialize()
|
| 22 |
# client = MongoClient('mongodb://localhost:27017/')
|
23 |
# client = MongoClient('mongodb://localhost:27017/')
|
| Line 83... |
Line 84... |
| 83 |
if morder is not None:
|
84 |
if morder is not None:
|
| 84 |
reconciled=morder.get("reconciled")
|
85 |
reconciled=morder.get("reconciled")
|
| 85 |
subOrders = morder.get("subOrders")
|
86 |
subOrders = morder.get("subOrders")
|
| 86 |
if subOrders is not None:
|
87 |
if subOrders is not None:
|
| 87 |
for subOrder in subOrders:
|
88 |
for subOrder in subOrders:
|
| - |
|
89 |
try:
|
| 88 |
user_id = result[1]
|
90 |
user_id = result[1]
|
| 89 |
user_name= result[7]
|
91 |
user_name= result[7]
|
| 90 |
order_id = result[0]
|
92 |
order_id = result[0]
|
| 91 |
created_on =result[6]
|
93 |
created_on =result[6]
|
| 92 |
store_id = sourceMap.get(result[2])
|
94 |
store_id = sourceMap.get(result[2])
|
| 93 |
merchant_order_id = morder.get("merchantOrderId")
|
95 |
merchant_order_id = morder.get("merchantOrderId")
|
| 94 |
status = subOrder.get("status")
|
96 |
status = subOrder.get("status")
|
| 95 |
detailed_status = subOrder.get("detailedStatus")
|
97 |
detailed_status = subOrder.get("detailedStatus")
|
| 96 |
product_title= subOrder.get("productTitle")
|
98 |
product_title= subOrder.get("productTitle")
|
| 97 |
referrer = result[9]
|
99 |
referrer = result[9]
|
| 98 |
amount_paid = int(subOrder.get("amountPaid"))
|
100 |
amount_paid = int(subOrder.get("amountPaid"))
|
| 99 |
quantity=int(subOrder.get("quantity"))
|
101 |
quantity=int(subOrder.get("quantity"))
|
| 100 |
skuData = getSkuData(morder.get("storeId"), subOrder.get("productCode"))
|
102 |
skuData = getSkuData(morder.get("storeId"), subOrder.get("productCode"))
|
| 101 |
if morder.get("storeId") == 3:
|
103 |
if morder.get("storeId") == 3:
|
| 102 |
skuData = db1.MasterData.find_one({'secondaryIdentifier':subOrder.get("productCode").strip(), 'source_id':morder.get("storeId")})
|
104 |
skuData = db1.MasterData.find_one({'secondaryIdentifier':subOrder.get("productCode").strip(), 'source_id':morder.get("storeId")})
|
| 103 |
else:
|
105 |
else:
|
| 104 |
skuData = db1.MasterData.find_one({'identifier':subOrder.get("productCode").strip(), 'source_id':morder.get("storeId")})
|
106 |
skuData = db1.MasterData.find_one({'identifier':subOrder.get("productCode").strip(), 'source_id':morder.get("storeId")})
|
| 105 |
if skuData is not None:
|
107 |
if skuData is not None:
|
| 106 |
catalog_id = skuData.get("skuBundleId")
|
108 |
catalog_id = skuData.get("skuBundleId")
|
| 107 |
brand= skuData.get("brand")
|
109 |
brand= skuData.get("brand")
|
| 108 |
model = skuData.get("model_name")
|
110 |
model = skuData.get("model_name")
|
| 109 |
category = skuData.get("category")
|
111 |
category = skuData.get("category")
|
| 110 |
deal_rank = subOrder.get("dealRank")
|
112 |
deal_rank = subOrder.get("dealRank")
|
| 111 |
max_nlc = subOrder.get("maxNlc")
|
113 |
max_nlc = subOrder.get("maxNlc")
|
| 112 |
min_nlc = subOrder.get("minNlc")
|
114 |
min_nlc = subOrder.get("minNlc")
|
| 113 |
dp = subOrder.get("db")
|
115 |
dp = subOrder.get("db")
|
| 114 |
item_status = utils.statusMap.get(subOrder.get("itemStatus"))
|
116 |
item_status = utils.statusMap.get(subOrder.get("itemStatus"))
|
| 115 |
else:
|
117 |
else:
|
| 116 |
catalog_id = 'None'
|
118 |
catalog_id = 'None'
|
| 117 |
brand= 'None'
|
119 |
brand= 'None'
|
| 118 |
model = 'None'
|
120 |
model = 'None'
|
| 119 |
category = 'None'
|
121 |
category = 'None'
|
| 120 |
deal_rank = 'None'
|
122 |
deal_rank = 'None'
|
| 121 |
max_nlc = 'None'
|
123 |
max_nlc = 'None'
|
| 122 |
min_nlc = 'None'
|
124 |
min_nlc = 'None'
|
| 123 |
dp = 'None'
|
125 |
dp = 'None'
|
| 124 |
item_status = 'None'
|
126 |
item_status = 'None'
|
| 125 |
affStatus = subOrder.get('affStatus')
|
127 |
affStatus = subOrder.get('affStatus')
|
| 126 |
merchant_suborder_id = subOrder.get("merchantSubOrderId")
|
128 |
merchant_suborder_id = subOrder.get("merchantSubOrderId")
|
| 127 |
cashback_status = subOrder.get("cashBackStatus")
|
129 |
cashback_status = subOrder.get("cashBackStatus")
|
| 128 |
cashback_amount = subOrder.get("cashBackAmount")
|
130 |
cashback_amount = subOrder.get("cashBackAmount")
|
| 129 |
city = result[10]
|
131 |
city = result[10]
|
| 130 |
state = result[11]
|
132 |
state = result[11]
|
| 131 |
pincode = result[12]
|
133 |
pincode = result[12]
|
| 132 |
|
134 |
|
| 133 |
user_name = re.sub(r'[^\x00-\x7F]+',' ', user_name)
|
135 |
user_name = re.sub(r'[^\x00-\x7F]+',' ', user_name)
|
| 134 |
product_title = re.sub(r'[^\x00-\x7F]+',' ', product_title)
|
136 |
product_title = re.sub(r'[^\x00-\x7F]+',' ', product_title)
|
| 135 |
print user_id, user_name, product_title
|
137 |
print user_id, user_name, product_title
|
| 136 |
|
138 |
|
| 137 |
values = (str(user_id), str(user_name), str(order_id), str(created_on), str(store_id), str(merchant_order_id), str(status), str(detailed_status), str(product_title), str(referrer), str(amount_paid), str(catalog_id), str(brand), str(model),str(category), str(deal_rank), str(max_nlc), str(min_nlc), str(dp), str(item_status), str(city), str(state), str(pincode),str(merchant_suborder_id),str(cashback_status),str(cashback_amount), str(quantity), str(reconciled), str(affStatus))
|
139 |
values = (str(user_id), str(user_name), str(order_id), str(created_on), str(store_id), str(merchant_order_id), str(status), str(detailed_status), str(product_title), str(referrer), str(amount_paid), str(catalog_id), str(brand), str(model),str(category), str(deal_rank), str(max_nlc), str(min_nlc), str(dp), str(item_status), str(city), str(state), str(pincode),str(merchant_suborder_id),str(cashback_status),str(cashback_amount), str(quantity), str(reconciled), str(affStatus))
|
| 138 |
cur.execute(query,values)
|
140 |
cur.execute(query,values)
|
| 139 |
con.commit()
|
141 |
con.commit()
|
| - |
|
142 |
except:
|
| - |
|
143 |
print traceback.print_exc()
|
| - |
|
144 |
continue
|
| 140 |
except _mysql.Error, e:
|
145 |
except _mysql.Error, e:
|
| 141 |
print "Error %d: %s" % (e.args[0], e.args[1])
|
146 |
print "Error %d: %s" % (e.args[0], e.args[1])
|
| 142 |
sys.exit(1)
|
147 |
sys.exit(1)
|
| 143 |
|
148 |
|
| 144 |
finally:
|
149 |
finally:
|