| 19651 |
manas |
1 |
from shop2020.clients.CRMClient import CRMClient
|
|
|
2 |
from shop2020.clients.UserClient import UserClient
|
|
|
3 |
from shop2020.thriftpy.crm.ttypes import SearchFilter, TicketCategory, Ticket, \
|
|
|
4 |
Activity, TicketPriority, TicketStatus, ActivityType
|
|
|
5 |
from dtr.utils.utils import to_java_date,sendCrmProjectMailByDtr
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
def generateCrmTicket(customerFeedBack):
|
|
|
9 |
sendCrmProjectMailByDtr(customerFeedBack)
|
|
|
10 |
crmServiceClient = CRMClient().get_client()
|
|
|
11 |
userServiceClient = UserClient().get_client()
|
|
|
12 |
ticket = Ticket()
|
|
|
13 |
activity = Activity()
|
|
|
14 |
ticket.creatorId = 1
|
|
|
15 |
user = userServiceClient.getUserByEmail(customerFeedBack.get('email'))
|
|
|
16 |
if 'Return or replacement pending' in customerFeedBack.get('subject'):
|
|
|
17 |
ticket.category = TicketCategory.PROFITMANDI_REFUND_PROBLEM
|
|
|
18 |
ticket.priority = TicketPriority.HIGH
|
|
|
19 |
elif 'Product Quality issue' in customerFeedBack.get('subject'):
|
|
|
20 |
ticket.category = TicketCategory.PROFITMANDI_PRODUCT_ISSUE
|
|
|
21 |
ticket.priority = TicketPriority.HIGH
|
|
|
22 |
elif 'Delayed Delivery' in customerFeedBack.get('subject'):
|
|
|
23 |
ticket.category = TicketCategory.PROFITMANDI_DELAYED_DELIVERY
|
|
|
24 |
ticket.priority = TicketPriority.HIGH
|
|
|
25 |
elif 'Technical issue at Profitmandi' in customerFeedBack.get('subject'):
|
|
|
26 |
ticket.category = TicketCategory.PROFITMANDI_TECHNICAL_PROBLEM
|
|
|
27 |
ticket.priority = TicketPriority.HIGH
|
|
|
28 |
else:
|
|
|
29 |
ticket.category = TicketCategory.PROFITMANDI_OTHER
|
|
|
30 |
ticket.priority = TicketPriority.MEDIUM
|
|
|
31 |
|
|
|
32 |
ticket.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
|
|
33 |
ticket.customerEmailId = customerFeedBack.get('email')
|
|
|
34 |
if user is not None and user.userId !=-1:
|
|
|
35 |
ticket.customerId = user.userId
|
|
|
36 |
ticket.assigneeId=57
|
|
|
37 |
ticket.status = TicketStatus.OPEN
|
|
|
38 |
ticket.openDate = to_java_date(customerFeedBack.get('created'))
|
|
|
39 |
ticket.customerMobileNumber = customerFeedBack.get('mobile_number')
|
|
|
40 |
ticket.customerName = customerFeedBack.get('customer_name')
|
|
|
41 |
activity.creatorId = 1
|
|
|
42 |
activity.ticketAssigneeId = ticket.assigneeId
|
|
|
43 |
activity.type = ActivityType.PROFITMANDI_CRM_APP_TICKET
|
|
|
44 |
activity.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
|
|
45 |
|
|
|
46 |
activity.ticketCategory = ticket.category
|
|
|
47 |
activity.ticketDescription = ticket.description
|
|
|
48 |
activity.ticketPriority = ticket.priority
|
|
|
49 |
activity.ticketStatus = ticket.status
|
|
|
50 |
activity.customerEmailId = customerFeedBack.get('email')
|
|
|
51 |
if user is not None and user.userId !=-1:
|
|
|
52 |
activity.customerId = user.userId
|
|
|
53 |
activity.customerName = customerFeedBack.get('customer_name')
|
|
|
54 |
activity.customerMobileNumber = customerFeedBack.get('mobile_number')
|
|
|
55 |
activity.creationTimestamp = ticket.openDate
|
|
|
56 |
activity.customerEmailId= customerFeedBack.get('email')
|
|
|
57 |
|
|
|
58 |
if not crmServiceClient.isAlive():
|
|
|
59 |
crmServiceClient = CRMClient().get_client()
|
|
|
60 |
|
|
|
61 |
ticketId = crmServiceClient.insertTicket(ticket, activity)
|
|
|
62 |
|
|
|
63 |
if ticketId > 0:
|
|
|
64 |
return True
|
|
|
65 |
else:
|
|
|
66 |
return False
|