| Line 35... |
Line 35... |
| 35 |
from falcon.util.uri import decode
|
35 |
from falcon.util.uri import decode
|
| 36 |
import MySQLdb
|
36 |
import MySQLdb
|
| 37 |
from shop2020.clients.CatalogClient import CatalogClient
|
37 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 38 |
from pyquery import PyQuery as pq
|
38 |
from pyquery import PyQuery as pq
|
| 39 |
import time
|
39 |
import time
|
| - |
|
40 |
from dtr.main import refundToWallet
|
| 40 |
|
41 |
|
| 41 |
alphalist = list(string.uppercase)
|
42 |
alphalist = list(string.uppercase)
|
| 42 |
alphalist.remove('O')
|
43 |
alphalist.remove('O')
|
| 43 |
numList = ['1','2','3','4','5','6','7','8','9']
|
44 |
numList = ['1','2','3','4','5','6','7','8','9']
|
| 44 |
codesys = [alphalist, alphalist, numList, numList, numList]
|
45 |
codesys = [alphalist, alphalist, numList, numList, numList]
|
| Line 2383... |
Line 2384... |
| 2383 |
|
2384 |
|
| 2384 |
class RefundWalletStatus():
|
2385 |
class RefundWalletStatus():
|
| 2385 |
def on_post(self,req,resp):
|
2386 |
def on_post(self,req,resp):
|
| 2386 |
status = req.get_param('status')
|
2387 |
status = req.get_param('status')
|
| 2387 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
2388 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
| 2388 |
print jsonReq
|
- |
|
| 2389 |
userId = jsonReq.get('user_id')
|
2389 |
user_id = jsonReq.get('user_id')
|
| 2390 |
_id = jsonReq.get('_id')
|
2390 |
_id = jsonReq.get('_id')
|
| 2391 |
if status == utils.REFUND_ADJUSTMENT_MAP.get(1):
|
2391 |
if status == utils.REFUND_ADJUSTMENT_MAP.get(1):
|
| 2392 |
Mongo.updateCrmWalletStatus(status, _id,userId)
|
2392 |
value = int(jsonReq.get('amount'))
|
| - |
|
2393 |
userAmountMap = {}
|
| 2393 |
datetimeNow = datetime.now()
|
2394 |
datetimeNow = datetime.now()
|
| 2394 |
batchId = int(time.mktime(datetimeNow.timetuple()))
|
2395 |
batchId = int(time.mktime(datetimeNow.timetuple()))
|
| 2395 |
user_id = jsonReq.get('user_id')
|
2396 |
userAmountMap[user_id] = value
|
| 2396 |
value = int(jsonReq.get('amount'))
|
2397 |
if refundToWallet(batchId,userAmountMap):
|
| 2397 |
print value
|
- |
|
| 2398 |
print user_id
|
2398 |
Mongo.updateCrmWalletStatus(status, _id,user_id)
|
| 2399 |
refundType = jsonReq.get('type')
|
2399 |
refundType = jsonReq.get('type')
|
| 2400 |
print refundType
|
- |
|
| 2401 |
get_mongo_connection().Dtr.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":refundType})
|
2400 |
get_mongo_connection().Dtr.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":refundType})
|
| 2402 |
get_mongo_connection().Dtr.user.update({"userId":user_id}, {"$inc": { "credited": value, refundType:value}}, upsert=True)
|
2401 |
get_mongo_connection().Dtr.user.update({"userId":user_id}, {"$inc": { "credited": value, refundType:value}}, upsert=True)
|
| - |
|
2402 |
print user_id,value
|
| - |
|
2403 |
Mongo.sendNotification([user_id], 'Batch Credit', 'Cashback Credited for %ss'%(str(refundType)), 'Rs.%s has been added to your wallet'%(value),'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(user_id), '2999-01-01', True, "TRAN_SMS Dear Customer, Cashback Credited for %ss. Rs.%s has been added to your wallet"%(refundType,value))
|
| 2403 |
resp.body = "{\"result\":\"success\"}"
|
2404 |
resp.body = "{\"result\":\"success\"}"
|
| - |
|
2405 |
else:
|
| - |
|
2406 |
resp.body = "{\"result\":\"failed\"}"
|
| 2404 |
elif status == utils.REFUND_ADJUSTMENT_MAP.get(2):
|
2407 |
elif status == utils.REFUND_ADJUSTMENT_MAP.get(2):
|
| 2405 |
Mongo.updateCrmWalletStatus(status, _id,userId)
|
2408 |
Mongo.updateCrmWalletStatus(status, _id,user_id)
|
| 2406 |
resp.body = "{\"result\":\"success\"}"
|
2409 |
resp.body = "{\"result\":\"success\"}"
|
| 2407 |
else:
|
2410 |
else:
|
| 2408 |
resp.body = "{\"result\":\"failed\"}"
|
2411 |
resp.body = "{\"result\":\"failed\"}"
|
| 2409 |
|
2412 |
|
| 2410 |
|
- |
|
| 2411 |
def main():
|
2413 |
def main():
|
| 2412 |
a = RetailerDetail()
|
2414 |
a = RetailerDetail()
|
| 2413 |
retailer = a.getNotActiveRetailer()
|
2415 |
retailer = a.getNotActiveRetailer()
|
| 2414 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
2416 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
| 2415 |
print json.dumps(todict(getRetailerObj(retailer, otherContacts, 'fresh')), encoding='utf-8')
|
2417 |
print json.dumps(todict(getRetailerObj(retailer, otherContacts, 'fresh')), encoding='utf-8')
|