| Line 19... |
Line 19... |
| 19 |
import urllib2
|
19 |
import urllib2
|
| 20 |
import urlparse
|
20 |
import urlparse
|
| 21 |
from Crypto.Hash import MD5
|
21 |
from Crypto.Hash import MD5
|
| 22 |
from Crypto.Cipher import DES
|
22 |
from Crypto.Cipher import DES
|
| 23 |
import string
|
23 |
import string
|
| 24 |
from shop2020.clients.CRMClient import CRMClient
|
- |
|
| 25 |
from shop2020.clients.UserClient import UserClient
|
- |
|
| 26 |
from shop2020.thriftpy.crm.ttypes import SearchFilter, TicketCategory, Ticket, \
|
- |
|
| 27 |
Activity, TicketPriority, TicketStatus, ActivityType
|
- |
|
| 28 |
from dtr.utils.MailSender import Email
|
24 |
from dtr.utils.MailSender import Email
|
| 29 |
#TODO Need to add messy stuff to conf.
|
25 |
#TODO Need to add messy stuff to conf.
|
| 30 |
|
26 |
|
| 31 |
|
27 |
|
| 32 |
SENDER = "cnc.center@shop2020.in"
|
28 |
SENDER = "cnc.center@shop2020.in"
|
| Line 438... |
Line 434... |
| 438 |
emailpushrequest = urllib2.Request(EMAIL_CRM_PUSH_URL, parameters, headers=headers)
|
434 |
emailpushrequest = urllib2.Request(EMAIL_CRM_PUSH_URL, parameters, headers=headers)
|
| 439 |
emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
435 |
emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
| 440 |
connection = urllib2.urlopen(emailpushrequest)
|
436 |
connection = urllib2.urlopen(emailpushrequest)
|
| 441 |
connection.close()
|
437 |
connection.close()
|
| 442 |
|
438 |
|
| 443 |
def generateCrmTicket(customerFeedBack):
|
- |
|
| 444 |
sendCrmProjectMailByDtr(customerFeedBack)
|
- |
|
| 445 |
crmServiceClient = CRMClient().get_client()
|
- |
|
| 446 |
userServiceClient = UserClient().get_client()
|
- |
|
| 447 |
ticket = Ticket()
|
- |
|
| 448 |
activity = Activity()
|
- |
|
| 449 |
ticket.creatorId = 1
|
- |
|
| 450 |
user = userServiceClient.getUserByEmail(customerFeedBack.get('email'))
|
- |
|
| 451 |
if 'Return or replacement pending' in customerFeedBack.get('subject'):
|
- |
|
| 452 |
ticket.category = TicketCategory.PROFITMANDI_REFUND_PROBLEM
|
- |
|
| 453 |
ticket.priority = TicketPriority.HIGH
|
- |
|
| 454 |
elif 'Product Quality issue' in customerFeedBack.get('subject'):
|
- |
|
| 455 |
ticket.category = TicketCategory.PROFITMANDI_PRODUCT_ISSUE
|
- |
|
| 456 |
ticket.priority = TicketPriority.HIGH
|
- |
|
| 457 |
elif 'Delayed Delivery' in customerFeedBack.get('subject'):
|
- |
|
| 458 |
ticket.category = TicketCategory.PROFITMANDI_DELAYED_DELIVERY
|
- |
|
| 459 |
ticket.priority = TicketPriority.HIGH
|
- |
|
| 460 |
elif 'Technical issue at Profitmandi' in customerFeedBack.get('subject'):
|
- |
|
| 461 |
ticket.category = TicketCategory.PROFITMANDI_TECHNICAL_PROBLEM
|
- |
|
| 462 |
ticket.priority = TicketPriority.HIGH
|
- |
|
| 463 |
else:
|
- |
|
| 464 |
ticket.category = TicketCategory.PROFITMANDI_OTHER
|
- |
|
| 465 |
ticket.priority = TicketPriority.MEDIUM
|
- |
|
| 466 |
|
- |
|
| 467 |
ticket.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
- |
|
| 468 |
ticket.customerEmailId = customerFeedBack.get('email')
|
- |
|
| 469 |
if user is not None and user.userId !=-1:
|
- |
|
| 470 |
ticket.customerId = user.userId
|
- |
|
| 471 |
ticket.assigneeId=57
|
- |
|
| 472 |
ticket.status = TicketStatus.OPEN
|
- |
|
| 473 |
ticket.openDate = to_java_date(customerFeedBack.get('created'))
|
- |
|
| 474 |
ticket.customerMobileNumber = customerFeedBack.get('mobile_number')
|
- |
|
| 475 |
ticket.customerName = customerFeedBack.get('customer_name')
|
- |
|
| 476 |
activity.creatorId = 1
|
- |
|
| 477 |
activity.ticketAssigneeId = ticket.assigneeId
|
- |
|
| 478 |
activity.type = ActivityType.PROFITMANDI_CRM_APP_TICKET
|
- |
|
| 479 |
activity.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
- |
|
| 480 |
|
- |
|
| 481 |
activity.ticketCategory = ticket.category
|
- |
|
| 482 |
activity.ticketDescription = ticket.description
|
- |
|
| 483 |
activity.ticketPriority = ticket.priority
|
- |
|
| 484 |
activity.ticketStatus = ticket.status
|
- |
|
| 485 |
activity.customerEmailId = customerFeedBack.get('email')
|
- |
|
| 486 |
if user is not None and user.userId !=-1:
|
- |
|
| 487 |
activity.customerId = user.userId
|
- |
|
| 488 |
activity.customerName = customerFeedBack.get('customer_name')
|
- |
|
| 489 |
activity.customerMobileNumber = customerFeedBack.get('mobile_number')
|
- |
|
| 490 |
activity.creationTimestamp = ticket.openDate
|
- |
|
| 491 |
activity.customerEmailId= customerFeedBack.get('email')
|
- |
|
| 492 |
|
- |
|
| 493 |
if not crmServiceClient.isAlive():
|
- |
|
| 494 |
crmServiceClient = CRMClient().get_client()
|
- |
|
| 495 |
|
- |
|
| 496 |
ticketId = crmServiceClient.insertTicket(ticket, activity)
|
- |
|
| 497 |
|
- |
|
| 498 |
if ticketId > 0:
|
- |
|
| 499 |
return True
|
- |
|
| 500 |
else:
|
- |
|
| 501 |
return False
|
- |
|
| 502 |
|
- |
|
| 503 |
def sendCrmProjectMailByDtr(customerFeedback):
|
439 |
def sendCrmProjectMailByDtr(customerFeedback):
|
| 504 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
440 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
| 505 |
mailServer.ehlo()
|
441 |
mailServer.ehlo()
|
| 506 |
mailServer.starttls()
|
442 |
mailServer.starttls()
|
| 507 |
mailServer.ehlo()
|
443 |
mailServer.ehlo()
|