| Line 59... |
Line 59... |
| 59 |
self.createdTime = None
|
59 |
self.createdTime = None
|
| 60 |
self.userId = userId
|
60 |
self.userId = userId
|
| 61 |
|
61 |
|
| 62 |
|
62 |
|
| 63 |
def getAndStoreMerchantSubOrders():
|
63 |
def getAndStoreMerchantSubOrders():
|
| 64 |
existingMaxOrderId = session.query(func.max(MerchantSubOrders.orderId)).one()
|
64 |
existingMaxOrderId = session.query(func.max(MerchantSubOrders.orderId)).one()
|
| 65 |
db = client.Dtr
|
65 |
db = client.Dtr
|
| 66 |
collection = db.merchantOrder
|
66 |
collection = db.merchantOrder
|
| 67 |
orders = collection.find({'orderId':{'$gt':int(existingMaxOrderId[0])}})
|
67 |
orders = collection.find({'orderId':{'$gt':int(0)}})
|
| 68 |
catalogdb = client.Catalog
|
68 |
catalogdb = client.Catalog
|
| 69 |
masterDataCollection = catalogdb.MasterData
|
69 |
masterDataCollection = catalogdb.MasterData
|
| 70 |
for order in orders:
|
70 |
for order in orders:
|
| 71 |
if order.has_key('subOrders'):
|
71 |
if order.has_key('subOrders'):
|
| 72 |
orderId = order['orderId']
|
72 |
orderId = order['orderId']
|
| Line 82... |
Line 82... |
| 82 |
if subOrder.has_key('unitPrice'):
|
82 |
if subOrder.has_key('unitPrice'):
|
| 83 |
unitPrice = subOrder['unitPrice']
|
83 |
unitPrice = subOrder['unitPrice']
|
| 84 |
productCode = "Undefined"
|
84 |
productCode = "Undefined"
|
| 85 |
if subOrder.has_key('productCode'):
|
85 |
if subOrder.has_key('productCode'):
|
| 86 |
productCode = subOrder['productCode']
|
86 |
productCode = subOrder['productCode']
|
| - |
|
87 |
skuData=Mongo.getItemByMerchantIdentifier(merchantSubOrder.productCode,merchantSubOrder.storeId)
|
| - |
|
88 |
if(skuData.has_key('category_id')):
|
| - |
|
89 |
category_id=skuData['category_id']
|
| - |
|
90 |
else:
|
| - |
|
91 |
category_id=None
|
| 87 |
merchantSubOrder = MerchantSubOrder(orderId, merchantOrderId, subOrder['merchantSubOrderId'], storeId, userId, productCode, subOrder['productTitle'], subOrder['amountPaid'], subOrder['quantity'], unitPrice, subOrder['status'], createdOnInt)
|
92 |
merchantSubOrder = MerchantSubOrder(orderId, merchantOrderId, subOrder['merchantSubOrderId'], storeId, userId, productCode, subOrder['productTitle'], category_id,subOrder['amountPaid'], subOrder['quantity'], unitPrice, subOrder['status'], createdOnInt)
|
| 88 |
product = None
|
93 |
product = None
|
| 89 |
if storeId in (1,2,4,5):
|
94 |
if storeId in (1,2,4,5):
|
| 90 |
product = list(masterDataCollection.find({'identifier':productCode.strip(), 'source_id':storeId}))
|
95 |
product = list(masterDataCollection.find({'identifier':productCode.strip(), 'source_id':storeId}))
|
| 91 |
elif storeId == 3:
|
96 |
elif storeId == 3:
|
| 92 |
product = list(masterDataCollection.find({'secondaryIdentifier':productCode.strip(), 'source_id':storeId}))
|
97 |
product = list(masterDataCollection.find({'secondaryIdentifier':productCode.strip(), 'source_id':storeId}))
|
| 93 |
if product is not None and len(product)>0:
|
98 |
if product is not None and len(product)>0:
|
| 94 |
merchantSubOrder.brand = product[0]["brand"]
|
99 |
merchantSubOrder.brand = product[0]["brand"]
|
| 95 |
else:
|
100 |
else:
|
| 96 |
merchantSubOrder.brand = 'NA'
|
101 |
merchantSubOrder.brand = 'NA'
|
| 97 |
skuData=Mongo.getItemByMerchantIdentifier(merchantSubOrder.productCode,merchantSubOrder.storeId)
|
- |
|
| 98 |
if(skuData.has_key('category_id')):
|
- |
|
| 99 |
merchantSubOrder.category_id=skuData['category_id']
|
- |
|
| 100 |
else:
|
102 |
|
| 101 |
merchantSubOrder.category_id=None
|
- |
|
| 102 |
existingMerchantSubOrder = MerchantSubOrders.query.filter(MerchantSubOrders.orderId == orderId).filter(MerchantSubOrders.merchantOrderId == merchantOrderId).filter(MerchantSubOrders.merchantSubOrderId == merchantSubOrder.merchantSubOrderId).first()
|
103 |
existingMerchantSubOrder = MerchantSubOrders.query.filter(MerchantSubOrders.orderId == orderId).filter(MerchantSubOrders.merchantOrderId == merchantOrderId).filter(MerchantSubOrders.merchantSubOrderId == merchantSubOrder.merchantSubOrderId).first()
|
| 103 |
if existingMerchantSubOrder is None:
|
104 |
if existingMerchantSubOrder is None:
|
| 104 |
merchantSubOrderDetail = MerchantSubOrders()
|
105 |
merchantSubOrderDetail = MerchantSubOrders()
|
| 105 |
merchantSubOrderDetail.orderId = merchantSubOrder.orderId
|
106 |
merchantSubOrderDetail.orderId = merchantSubOrder.orderId
|
| 106 |
merchantSubOrderDetail.merchantOrderId = merchantSubOrder.merchantOrderId
|
107 |
merchantSubOrderDetail.merchantOrderId = merchantSubOrder.merchantOrderId
|
| Line 174... |
Line 175... |
| 174 |
print "session is active. closing it."
|
175 |
print "session is active. closing it."
|
| 175 |
session.close()
|
176 |
session.close()
|
| 176 |
client.close()
|
177 |
client.close()
|
| 177 |
|
178 |
|
| 178 |
if __name__=='__main__':
|
179 |
if __name__=='__main__':
|
| 179 |
main()
|
- |
|
| 180 |
|
180 |
main()
|
| - |
|
181 |
|