| Line 1731... |
Line 1731... |
| 1731 |
else:
|
1731 |
else:
|
| 1732 |
self.user.disposition = 'not_reachable'
|
1732 |
self.user.disposition = 'not_reachable'
|
| 1733 |
self.user.retry_count += 1
|
1733 |
self.user.retry_count += 1
|
| 1734 |
self.user.invalid_retry_count += 1
|
1734 |
self.user.invalid_retry_count += 1
|
| 1735 |
|
1735 |
|
| 1736 |
retryConfig = session.query(RetryConfig).filter_by(call_type=self.callType, disposition_type=self.retailer.disposition, retry_count=self.retailer.retry_count).first()
|
1736 |
#retryConfig = session.query(RetryConfig).filter_by(call_type=self.callType, disposition_type=self.retailer.disposition, retry_count=self.retailer.retry_count).first()
|
| 1737 |
if retryConfig is not None:
|
1737 |
#if retryConfig is not None:
|
| 1738 |
self.user.next_call_time = self.callHistoryCrm.call_time + timedelta(minutes = retryConfig.minutes_ahead)
|
1738 |
#self.user.next_call_time = self.callHistoryCrm.call_time + timedelta(minutes = retryConfig.minutes_ahead)
|
| 1739 |
self.callHistory.disposition_description = 'Call scheduled on ' + datetime.strftime(self.retailer.next_call_time, '%d/%m/%Y %H:%M:%S')
|
1739 |
#self.callHistory.disposition_description = 'Call scheduled on ' + datetime.strftime(self.retailer.next_call_time, '%d/%m/%Y %H:%M:%S')
|
| 1740 |
else:
|
1740 |
#else:
|
| 1741 |
self.user.status = 'failed'
|
1741 |
#self.user.status = 'failed'
|
| 1742 |
self.callHistoryCrm.disposition_description = 'Call failed as all attempts exhausted'
|
1742 |
#self.callHistoryCrm.disposition_description = 'Call failed as all attempts exhausted'
|
| 1743 |
|
1743 |
|
| 1744 |
session.commit()
|
1744 |
session.commit()
|
| 1745 |
return True
|
1745 |
return True
|
| 1746 |
|
1746 |
|
| 1747 |
def insertUserCrmData(project_id):
|
1747 |
def insertUserCrmData(project_id):
|
| Line 1762... |
Line 1762... |
| 1762 |
result = get_mongo_connection_dtr_data().User.browsinghistories.find(queryfilter).distinct('user_id')
|
1762 |
result = get_mongo_connection_dtr_data().User.browsinghistories.find(queryfilter).distinct('user_id')
|
| 1763 |
|
1763 |
|
| 1764 |
for r in result:
|
1764 |
for r in result:
|
| 1765 |
userList.append(r)
|
1765 |
userList.append(r)
|
| 1766 |
|
1766 |
|
| 1767 |
myquery = "select user_id from allorder where store_id='spice' and (category='Accs' or category='Accessories') and user_id in (%s)" % ",".join(map(str,userList))
|
1767 |
myquery = "select a.user_id from allorder a join users u on a.user_id=u.id where a.store_id='spice' and (a.category='Accs' or a.category='Accessories') and u.referrer not like 'emp%%' and u.mobile_number IS NOT NULL and a.user_id in (%s)" % ",".join(map(str,userList)) + " UNION select id from users where lower(referrer) like 'emp%'"
|
| 1768 |
|
1768 |
|
| 1769 |
result = fetchResult(myquery)
|
1769 |
result = fetchResult(myquery)
|
| 1770 |
for r in result:
|
1770 |
for r in result:
|
| 1771 |
orderUserList.append(r)
|
1771 |
orderUserList.append(r[0])
|
| 1772 |
|
- |
|
| 1773 |
finalUserList = list(set(userList) - set(orderUserList))
|
1772 |
finalUserList = list(set(userList) - set(orderUserList))
|
| 1774 |
|
1773 |
|
| 1775 |
queryfilternew = {"$and":
|
1774 |
queryfilternew = {"$and":
|
| 1776 |
[
|
1775 |
[
|
| 1777 |
{'user_id':{"$in":finalUserList}},
|
1776 |
{'user_id':{"$in":finalUserList}},
|
| Line 1786... |
Line 1785... |
| 1786 |
if(userMasterMap.has_key(i.get('user_id'))):
|
1785 |
if(userMasterMap.has_key(i.get('user_id'))):
|
| 1787 |
if userMasterMap.get(i.get('user_id')) > i.get('created'):
|
1786 |
if userMasterMap.get(i.get('user_id')) > i.get('created'):
|
| 1788 |
userMasterMap[i.get('user_id')]=i.get('created')
|
1787 |
userMasterMap[i.get('user_id')]=i.get('created')
|
| 1789 |
else:
|
1788 |
else:
|
| 1790 |
userMasterMap[i.get('user_id')]=i.get('created')
|
1789 |
userMasterMap[i.get('user_id')]=i.get('created')
|
| 1791 |
|
1790 |
|
| 1792 |
d_sorted = sorted(zip(userMasterMap.values(), userMasterMap.keys()))
|
1791 |
d_sorted = sorted(zip(userMasterMap.values(), userMasterMap.keys()))
|
| - |
|
1792 |
addUserToTable(d_sorted,1)
|
| - |
|
1793 |
|
| - |
|
1794 |
def addUserToTable(userList,projectId):
|
| 1793 |
counter=0
|
1795 |
counter=0
|
| 1794 |
for i in d_sorted:
|
1796 |
for i in userList:
|
| 1795 |
if counter==2:
|
- |
|
| 1796 |
break
|
1797 |
try:
|
| 1797 |
userCheck = session.query(UserCrmCallingData).filter_by(user_id=i[1]).filter(UserCrmCallingData.modified<=(datetime.now().date()-timedelta(days=3))).filter(UserCrmCallingData.project_id!=1 or UserCrmCallingData.user_available==1).first()
|
- |
|
| 1798 |
if userCheck is None:
|
- |
|
| 1799 |
counter=counter+1
|
- |
|
| 1800 |
print i[0],i[1],counter
|
- |
|
| 1801 |
userId=i[1]
|
1798 |
userId=i[1]
|
| - |
|
1799 |
if counter==2:
|
| - |
|
1800 |
break
|
| - |
|
1801 |
userPresent = session.query(UserCrmCallingData).filter_by(user_id=userId).order_by(desc(UserCrmCallingData.modified)).first()
|
| - |
|
1802 |
if userPresent is not None:
|
| - |
|
1803 |
if userPresent.user_available==1:
|
| - |
|
1804 |
if userPresent.project_id==projectId:
|
| - |
|
1805 |
print 'Same project Id'
|
| - |
|
1806 |
continue
|
| - |
|
1807 |
elif userPresent.modified>=(datetime.now().date()-timedelta(days=3)):
|
| - |
|
1808 |
print 'Time lag'
|
| - |
|
1809 |
continue
|
| - |
|
1810 |
counter=counter+1
|
| 1802 |
userMasterData = UserCrmCallingData()
|
1811 |
userMasterData = UserCrmCallingData()
|
| 1803 |
userMasterData.user_id = userId
|
1812 |
userMasterData.user_id = userId
|
| 1804 |
userMasterData.name =getUsername(userId)
|
1813 |
userMasterData.name =getUsername(userId)
|
| 1805 |
userMasterData.project_id = 1
|
1814 |
userMasterData.project_id = projectId
|
| 1806 |
userMasterData.user_available=0
|
1815 |
userMasterData.user_available=0
|
| 1807 |
userMasterData.contact1 = getUserContactDetails(userId)
|
1816 |
userMasterData.contact1 = getUserContactDetails(userId)
|
| 1808 |
userMasterData.counter = 0
|
1817 |
userMasterData.counter = 0
|
| 1809 |
userMasterData.created = datetime.now()
|
1818 |
userMasterData.created = datetime.now()
|
| 1810 |
userMasterData.modified = datetime.now()
|
1819 |
userMasterData.modified = datetime.now()
|
| 1811 |
userMasterData.status = 'new'
|
1820 |
userMasterData.status = 'new'
|
| 1812 |
userMasterData.pincode_servicable = checkPincodeServicable(userId)
|
1821 |
userMasterData.pincode_servicable = checkPincodeServicable(userId)
|
| 1813 |
session.commit()
|
1822 |
session.commit()
|
| - |
|
1823 |
except:
|
| - |
|
1824 |
print traceback.print_exc()
|
| - |
|
1825 |
finally:
|
| 1814 |
session.close()
|
1826 |
session.close()
|
| 1815 |
|
1827 |
|
| 1816 |
def getCartTabsUser():
|
1828 |
def getCartTabsUser():
|
| 1817 |
userList=[]
|
1829 |
userList=[]
|
| 1818 |
orderUserList=[]
|
1830 |
orderUserList=[]
|
| 1819 |
userMasterMap={}
|
1831 |
userMasterMap={}
|
| 1820 |
queryfilter = {"$and":
|
1832 |
queryfilter = {"$and":
|
| Line 1925... |
Line 1937... |
| 1925 |
result = Mongo.getDealById(id)
|
1937 |
result = Mongo.getDealById(id)
|
| 1926 |
resp.body = dumps(result)
|
1938 |
resp.body = dumps(result)
|
| 1927 |
|
1939 |
|
| 1928 |
def main():
|
1940 |
def main():
|
| 1929 |
#tagActivatedReatilers()
|
1941 |
#tagActivatedReatilers()
|
| 1930 |
a = RetailerDetail()
|
1942 |
#a = RetailerDetail()
|
| 1931 |
retailer = a.getNotActiveRetailer()
|
1943 |
#retailer = a.getNotActiveRetailer()
|
| 1932 |
otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
1944 |
#otherContacts = [r for r, in session.query(RetailerContacts.mobile_number).filter_by(retailer_id=retailer.id).order_by(RetailerContacts.contact_type).all()]
|
| 1933 |
print json.dumps(todict(getRetailerObj(retailer, otherContacts, 'fresh')), encoding='utf-8')
|
1945 |
#print json.dumps(todict(getRetailerObj(retailer, otherContacts, 'fresh')), encoding='utf-8')
|
| 1934 |
#print make_tiny("AA")
|
1946 |
#print make_tiny("AA")
|
| - |
|
1947 |
a = GetUserCrmApplication()
|
| - |
|
1948 |
a.getUser("accessories", 2)
|
| 1935 |
|
1949 |
|
| 1936 |
if __name__ == '__main__':
|
1950 |
if __name__ == '__main__':
|
| 1937 |
main()
|
1951 |
main()
|
| 1938 |
|
1952 |
|
| 1939 |
|
1953 |
|