| Line 37... |
Line 37... |
| 37 |
import MySQLdb
|
37 |
import MySQLdb
|
| 38 |
from shop2020.clients.CatalogClient import CatalogClient
|
38 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 39 |
from pyquery import PyQuery as pq
|
39 |
from pyquery import PyQuery as pq
|
| 40 |
import time
|
40 |
import time
|
| 41 |
from dtr.main import refundToWallet
|
41 |
from dtr.main import refundToWallet
|
| 42 |
|
42 |
import random
|
| 43 |
alphalist = list(string.uppercase)
|
43 |
alphalist = list(string.uppercase)
|
| 44 |
alphalist.remove('O')
|
44 |
alphalist.remove('O')
|
| 45 |
numList = ['1','2','3','4','5','6','7','8','9']
|
45 |
numList = ['1','2','3','4','5','6','7','8','9']
|
| 46 |
codesys = [alphalist, alphalist, numList, numList, numList]
|
46 |
codesys = [alphalist, alphalist, numList, numList, numList]
|
| - |
|
47 |
newcodesys = alphalist + numList
|
| 47 |
CONTACT_PRIORITY = ['sms', 'called', 'ringing']
|
48 |
CONTACT_PRIORITY = ['sms', 'called', 'ringing']
|
| 48 |
RETRY_MAP = {'fresh':'retry', 'followup':'fretry', 'onboarding':'oretry'}
|
49 |
RETRY_MAP = {'fresh':'retry', 'followup':'fretry', 'onboarding':'oretry'}
|
| 49 |
ASSIGN_MAP = {'retry':'assigned', 'fretry':'fassigned', 'oretry':'oassigned'}
|
50 |
ASSIGN_MAP = {'retry':'assigned', 'fretry':'fassigned', 'oretry':'oassigned'}
|
| 50 |
|
51 |
|
| 51 |
sticky_agents = [17]
|
52 |
sticky_agents = [17]
|
| 52 |
|
53 |
|
| - |
|
54 |
def getNextRandomCode(newcodesys,size=6):
|
| - |
|
55 |
return ''.join(random.choice(newcodesys) for _ in range(size))
|
| 53 |
def getNextCode(codesys, code=None):
|
56 |
def getNextCode(codesys, code=None):
|
| 54 |
if code is None:
|
57 |
if code is None:
|
| 55 |
code = []
|
58 |
code = []
|
| 56 |
for charcode in codesys:
|
59 |
for charcode in codesys:
|
| 57 |
code.append(charcode[0])
|
60 |
code.append(charcode[0])
|
| Line 582... |
Line 585... |
| 582 |
retailer.contact1 = user.mobile_number
|
585 |
retailer.contact1 = user.mobile_number
|
| 583 |
retailer.status = 'assigned'
|
586 |
retailer.status = 'assigned'
|
| 584 |
retailer.retry_count = 0
|
587 |
retailer.retry_count = 0
|
| 585 |
retailer.invalid_retry_count = 0
|
588 |
retailer.invalid_retry_count = 0
|
| 586 |
retailer.is_elavated=1
|
589 |
retailer.is_elavated=1
|
| - |
|
590 |
retailer.agent_id = 2
|
| - |
|
591 |
retailer.isvalidated = 0
|
| 587 |
user.status = 2
|
592 |
user.status = 2
|
| 588 |
session.commit()
|
593 |
session.commit()
|
| 589 |
print "retailer id", retailer.id
|
594 |
print "retailer id", retailer.id
|
| 590 |
retailer.contact = user.mobile_number
|
595 |
retailer.contact = user.mobile_number
|
| 591 |
return retailer
|
596 |
return retailer
|
| Line 659... |
Line 664... |
| 659 |
self.retailerId = int(retailerId)
|
664 |
self.retailerId = int(retailerId)
|
| 660 |
retailerLink = session.query(RetailerLinks).filter_by(retailer_id=self.retailerId).first()
|
665 |
retailerLink = session.query(RetailerLinks).filter_by(retailer_id=self.retailerId).first()
|
| 661 |
if retailerLink is not None:
|
666 |
if retailerLink is not None:
|
| 662 |
code = retailerLink.code
|
667 |
code = retailerLink.code
|
| 663 |
else:
|
668 |
else:
|
| 664 |
code = self.getCode()
|
669 |
code = self.getNewRandomCode()
|
| 665 |
retailerLink = RetailerLinks()
|
670 |
retailerLink = RetailerLinks()
|
| 666 |
retailerLink.code = code
|
671 |
retailerLink.code = code
|
| 667 |
retailerLink.agent_id = self.agentId
|
672 |
retailerLink.agent_id = self.agentId
|
| 668 |
retailerLink.retailer_id = self.retailerId
|
673 |
retailerLink.retailer_id = self.retailerId
|
| 669 |
|
674 |
|
| Line 818... |
Line 823... |
| 818 |
if lastLink is not None:
|
823 |
if lastLink is not None:
|
| 819 |
if len(lastLink.code)==len(codesys):
|
824 |
if len(lastLink.code)==len(codesys):
|
| 820 |
newCode=lastLink.code
|
825 |
newCode=lastLink.code
|
| 821 |
return getNextCode(codesys, newCode)
|
826 |
return getNextCode(codesys, newCode)
|
| 822 |
|
827 |
|
| - |
|
828 |
def getNewRandomCode(self,):
|
| - |
|
829 |
newCode = None
|
| - |
|
830 |
while True:
|
| - |
|
831 |
newCode = getNextRandomCode(newcodesys, 6)
|
| - |
|
832 |
print 'NewCode',newCode
|
| - |
|
833 |
isCodePresent = session.query(Activation_Codes).filter_by(code=newCode).first()
|
| - |
|
834 |
if isCodePresent is not None:
|
| - |
|
835 |
continue
|
| - |
|
836 |
else:
|
| - |
|
837 |
break
|
| - |
|
838 |
return newCode
|
| 823 |
|
839 |
|
| 824 |
def callLater(self,):
|
840 |
def callLater(self,):
|
| 825 |
self.retailer.status = RETRY_MAP.get(self.callType)
|
841 |
self.retailer.status = RETRY_MAP.get(self.callType)
|
| 826 |
self.retailer.call_priority = None
|
842 |
self.retailer.call_priority = None
|
| 827 |
if self.callDisposition == 'call_later':
|
843 |
if self.callDisposition == 'call_later':
|
| Line 960... |
Line 976... |
| 960 |
storeName = str(jsonReq.get("storename"))
|
976 |
storeName = str(jsonReq.get("storename"))
|
| 961 |
pin = str(jsonReq.get("pin"))
|
977 |
pin = str(jsonReq.get("pin"))
|
| 962 |
city = str(jsonReq.get("city"))
|
978 |
city = str(jsonReq.get("city"))
|
| 963 |
state = str(jsonReq.get("state"))
|
979 |
state = str(jsonReq.get("state"))
|
| 964 |
updateType = str(jsonReq.get("updatetype"))
|
980 |
updateType = str(jsonReq.get("updatetype"))
|
| - |
|
981 |
tinnumber = str(jsonReq.get("tinnumber"))
|
| 965 |
addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType)
|
982 |
addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType,tinnumber)
|
| 966 |
|
983 |
|
| 967 |
def addContactToRetailer(agentId, retailerId, mobile, callType, contactType):
|
984 |
def addContactToRetailer(agentId, retailerId, mobile, callType, contactType):
|
| 968 |
retailerContact = session.query(RetailerContacts).filter_by(retailer_id=retailerId).filter_by(mobile_number=mobile).first()
|
985 |
retailerContact = session.query(RetailerContacts).filter_by(retailer_id=retailerId).filter_by(mobile_number=mobile).first()
|
| 969 |
if retailerContact is None:
|
986 |
if retailerContact is None:
|
| 970 |
retailerContact = RetailerContacts()
|
987 |
retailerContact = RetailerContacts()
|
| Line 975... |
Line 992... |
| 975 |
retailerContact.mobile_number = mobile
|
992 |
retailerContact.mobile_number = mobile
|
| 976 |
else:
|
993 |
else:
|
| 977 |
if CONTACT_PRIORITY.index(retailerContact.contact_type) > CONTACT_PRIORITY.index(contactType):
|
994 |
if CONTACT_PRIORITY.index(retailerContact.contact_type) > CONTACT_PRIORITY.index(contactType):
|
| 978 |
retailerContact.contact_type = contactType
|
995 |
retailerContact.contact_type = contactType
|
| 979 |
|
996 |
|
| 980 |
def addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType):
|
997 |
def addAddressToRetailer(agentId, retailerId, address, storeName, pin, city,state, updateType,tinnumber):
|
| 981 |
print "I am in addAddress"
|
998 |
print "I am in addAddress"
|
| 982 |
print agentId, retailerId, address, storeName, pin, city, state, updateType
|
999 |
print agentId, retailerId, address, storeName, pin, city, state, updateType
|
| 983 |
try:
|
1000 |
try:
|
| 984 |
if updateType=='new':
|
1001 |
if updateType=='new':
|
| 985 |
retailer = session.query(Retailers).filter_by(id=retailerId).first()
|
1002 |
retailer = session.query(Retailers).filter_by(id=retailerId).first()
|
| 986 |
retailer.address = address
|
1003 |
retailer.address = address
|
| 987 |
retailer.title = storeName
|
1004 |
retailer.title = storeName
|
| 988 |
retailer.city = city
|
1005 |
retailer.city = city
|
| 989 |
retailer.state = state
|
1006 |
retailer.state = state
|
| 990 |
retailer.pin = pin
|
1007 |
retailer.pin = pin
|
| - |
|
1008 |
retailer.tinnumber = tinnumber
|
| 991 |
raddress = RetailerAddresses()
|
1009 |
raddress = RetailerAddresses()
|
| 992 |
raddress.address = address
|
1010 |
raddress.address = address
|
| 993 |
raddress.title = storeName
|
1011 |
raddress.title = storeName
|
| 994 |
raddress.agent_id = agentId
|
1012 |
raddress.agent_id = agentId
|
| 995 |
raddress.city = city
|
1013 |
raddress.city = city
|
| Line 1161... |
Line 1179... |
| 1161 |
obj.title = retailer.title
|
1179 |
obj.title = retailer.title
|
| 1162 |
obj.city = retailer.city
|
1180 |
obj.city = retailer.city
|
| 1163 |
obj.state = retailer.state
|
1181 |
obj.state = retailer.state
|
| 1164 |
obj.pin = retailer.pin
|
1182 |
obj.pin = retailer.pin
|
| 1165 |
obj.status = retailer.status
|
1183 |
obj.status = retailer.status
|
| 1166 |
|
1184 |
obj.tinnumber = retailer.tinnumber
|
| 1167 |
if hasattr(retailer, 'contact'):
|
1185 |
if hasattr(retailer, 'contact'):
|
| 1168 |
obj.contact = retailer.contact
|
1186 |
obj.contact = retailer.contact
|
| - |
|
1187 |
obj.isvalidated = retailer.isvalidated
|
| - |
|
1188 |
|
| - |
|
1189 |
if callType == 'followup':
|
| - |
|
1190 |
obj.last_call_time = datetime.strftime(retailer.modified, "%B %Y")
|
| 1169 |
if callType == 'onboarding':
|
1191 |
if callType == 'onboarding':
|
| 1170 |
try:
|
1192 |
try:
|
| 1171 |
userId, activatedTime = session.query(RetailerLinks.user_id, RetailerLinks.activated).filter(RetailerLinks.retailer_id==retailer.id).first()
|
1193 |
userId, activatedTime = session.query(RetailerLinks.user_id, RetailerLinks.activated).filter(RetailerLinks.retailer_id==retailer.id).first()
|
| 1172 |
activated, = session.query(Users.activation_time).filter(Users.id==userId).first()
|
1194 |
activated, = session.query(Users.activation_time).filter(Users.id==userId).first()
|
| 1173 |
if activated is not None:
|
1195 |
if activated is not None:
|