| Line 218... |
Line 218... |
| 218 |
def settlePayBack(runtype='dry'):
|
218 |
def settlePayBack(runtype='dry'):
|
| 219 |
userAmountMap = {}
|
219 |
userAmountMap = {}
|
| 220 |
searchMapList = []
|
220 |
searchMapList = []
|
| 221 |
for mo in client.Dtr.merchantOrder.find({"subOrders.cashBackStatus":Store.CB_APPROVED}):
|
221 |
for mo in client.Dtr.merchantOrder.find({"subOrders.cashBackStatus":Store.CB_APPROVED}):
|
| 222 |
userId = mo.get("userId")
|
222 |
userId = mo.get("userId")
|
| 223 |
if mo.get('subOrders') is not None:
|
223 |
if mo.get('subOrders') is not None:
|
| 224 |
for so in mo['subOrders']:
|
224 |
for so in mo['subOrders']:
|
| 225 |
if so.get('cashBackStatus') == Store.CB_APPROVED:
|
225 |
if so.get('cashBackStatus') == Store.CB_APPROVED:
|
| 226 |
searchMapList.append({"orderId":mo.get("orderId"), "subOrders.merchantSubOrderId":so.get("merchantSubOrderId")})
|
226 |
searchMapList.append({"orderId":mo.get("orderId"), "subOrders.merchantSubOrderId":so.get("merchantSubOrderId")})
|
| 227 |
if not userAmountMap.has_key(userId):
|
227 |
if not userAmountMap.has_key(userId):
|
| 228 |
userAmountMap[userId] = so.get('cashBackAmount')
|
228 |
userAmountMap[userId] = so.get('cashBackAmount')
|
| Line 231... |
Line 231... |
| 231 |
print "%s\t%s\t%s\t%s\t%s\t%s\t%s"%(userId, mo.get("orderId"), so.get("merchantSubOrderId"),so.get("productTitle") ,so.get("cashBackStatus"), so.get("cashBackAmount"), so.get("batchId"))
|
231 |
print "%s\t%s\t%s\t%s\t%s\t%s\t%s"%(userId, mo.get("orderId"), so.get("merchantSubOrderId"),so.get("productTitle") ,so.get("cashBackStatus"), so.get("cashBackAmount"), so.get("batchId"))
|
| 232 |
else:
|
232 |
else:
|
| 233 |
print "%s\t%s\t%s\t%s\t%s\t%s\t%s"%(userId, mo.get("orderId"), so.get("merchantSubOrderId"),so.get("productTitle") ,so.get("cashBackStatus"), so.get("cashBackAmount"), so.get("batchId"))
|
233 |
print "%s\t%s\t%s\t%s\t%s\t%s\t%s"%(userId, mo.get("orderId"), so.get("merchantSubOrderId"),so.get("productTitle") ,so.get("cashBackStatus"), so.get("cashBackAmount"), so.get("batchId"))
|
| 234 |
for searchMap in searchMapList:
|
234 |
for searchMap in searchMapList:
|
| 235 |
print "%s\t%s"%(searchMap.get('orderId'),searchMap.get('subOrders.merchantSubOrderId'))
|
235 |
print "%s\t%s"%(searchMap.get('orderId'),searchMap.get('subOrders.merchantSubOrderId'))
|
| - |
|
236 |
for key,val in userAmountMap.iteritems():
|
| - |
|
237 |
print "%s\t%s"%(key,val)
|
| 236 |
if (runtype=='live'):
|
238 |
if (runtype=='live'):
|
| 237 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
239 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
| 238 |
if len(searchMapList) == 0:
|
240 |
if len(searchMapList) == 0:
|
| 239 |
return
|
241 |
return
|
| 240 |
for searchMap in searchMapList:
|
242 |
for searchMap in searchMapList:
|