| Line 28... |
Line 28... |
| 28 |
from shop2020.clients.CRMClient import CRMClient
|
28 |
from shop2020.clients.CRMClient import CRMClient
|
| 29 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
29 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 30 |
from shop2020.clients.TransactionClient import TransactionClient
|
30 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 31 |
from shop2020.clients.UserClient import UserClient
|
31 |
from shop2020.clients.UserClient import UserClient
|
| 32 |
from shop2020.config.client.ConfigClient import ConfigClient
|
32 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 33 |
from shop2020.model.v1.order.script.LogisticUtils import enqueueMailForFDA
|
33 |
from shop2020.model.v1.order.script.LogisticUtils import enqueueMailForFDA, \
|
| - |
|
34 |
create_crm_tickets_for_delivey_attempted_orders
|
| 34 |
from shop2020.thriftpy.config.ttypes import ConfigException
|
35 |
from shop2020.thriftpy.config.ttypes import ConfigException
|
| 35 |
from shop2020.thriftpy.crm.ttypes import *
|
36 |
from shop2020.thriftpy.crm.ttypes import *
|
| 36 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
37 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
| 37 |
OrderStatus
|
38 |
OrderStatus
|
| 38 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part, mail
|
39 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part, mail
|
| Line 57... |
Line 58... |
| 57 |
except ConfigException as cex:
|
58 |
except ConfigException as cex:
|
| 58 |
print cex.message
|
59 |
print cex.message
|
| 59 |
traceback.print_exc()
|
60 |
traceback.print_exc()
|
| 60 |
|
61 |
|
| 61 |
defaultUndeliveredAsssigneeId = 47
|
62 |
defaultUndeliveredAsssigneeId = 47
|
| - |
|
63 |
dtrUndeliveredAsssigneeId = 33
|
| 62 |
from_user = 'cnc.center@shop2020.in'
|
64 |
from_user = 'cnc.center@shop2020.in'
|
| 63 |
from_pwd = '5h0p2o2o'
|
65 |
from_pwd = '5h0p2o2o'
|
| 64 |
to = ['cnc.center@shop2020.in', "amit.sirohi@shop2020.in", "sandeep.sachdeva@shop2020.in", "manoj.kumar@shop2020.in"]
|
66 |
to = ['cnc.center@shop2020.in', "amit.sirohi@shop2020.in", "sandeep.sachdeva@shop2020.in", "manoj.kumar@shop2020.in"]
|
| 65 |
|
67 |
|
| 66 |
def process_dao_pickup_orders(provider):
|
68 |
def process_dao_pickup_orders(provider):
|
| Line 545... |
Line 547... |
| 545 |
statusDescription = ''
|
547 |
statusDescription = ''
|
| 546 |
if order.statusDescription is not None:
|
548 |
if order.statusDescription is not None:
|
| 547 |
statusDescription = order.statusDescription.replace(","," ")
|
549 |
statusDescription = order.statusDescription.replace(","," ")
|
| 548 |
writer.writerow([order.id, order.airwaybill_no, order.status, statusDescription, to_py_date(order.shipping_timestamp), to_py_date(order.pickup_timestamp), to_py_date(order.promised_delivery_time), to_py_date(order.expected_delivery_time)])
|
550 |
writer.writerow([order.id, order.airwaybill_no, order.status, statusDescription, to_py_date(order.shipping_timestamp), to_py_date(order.pickup_timestamp), to_py_date(order.promised_delivery_time), to_py_date(order.expected_delivery_time)])
|
| 549 |
|
551 |
|
| 550 |
def create_crm_tickets_for_delivey_attempted_orders(provider):
|
- |
|
| 551 |
try:
|
- |
|
| 552 |
tickets_tobe_created = fetch_data(provider.id, [OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE])
|
- |
|
| 553 |
userClient = UserClient().get_client()
|
- |
|
| 554 |
crmServiceClient = CRMClient().get_client()
|
- |
|
| 555 |
for order in tickets_tobe_created:
|
- |
|
| 556 |
ticket_created = False
|
- |
|
| 557 |
searchFilter = SearchFilter()
|
- |
|
| 558 |
user = userClient.getUserByEmail(order.customer_email)
|
- |
|
| 559 |
if user is None or user.userId == -1:
|
- |
|
| 560 |
searchFilter.customerEmailId = order.customer_email
|
- |
|
| 561 |
searchFilter.customerMobileNumber = order.customer_mobilenumber
|
- |
|
| 562 |
else:
|
- |
|
| 563 |
searchFilter.customerId = user.userId
|
- |
|
| 564 |
searchFilter.ticketCategory = TicketCategory.UNDELIVERED
|
- |
|
| 565 |
tickets = crmServiceClient.getTickets(searchFilter)
|
- |
|
| 566 |
print tickets
|
- |
|
| 567 |
for old_ticket in tickets:
|
- |
|
| 568 |
if old_ticket.orderId == order.id:
|
- |
|
| 569 |
ticket_created = True
|
- |
|
| 570 |
break
|
- |
|
| 571 |
if not ticket_created:
|
- |
|
| 572 |
print "creating ticket for orderId:"+str(order.id)
|
- |
|
| 573 |
ticket = Ticket()
|
- |
|
| 574 |
activity = Activity()
|
- |
|
| 575 |
description = order.statusDescription + "\n\nOrder not delivered by courier due to problems at customer end."
|
- |
|
| 576 |
ticket.creatorId = 1
|
- |
|
| 577 |
ticket.assigneeId = defaultUndeliveredAsssigneeId
|
- |
|
| 578 |
ticket.category = TicketCategory.UNDELIVERED
|
- |
|
| 579 |
ticket.priority = TicketPriority.HIGH
|
- |
|
| 580 |
ticket.status = TicketStatus.OPEN
|
- |
|
| 581 |
ticket.description = description
|
- |
|
| 582 |
ticket.orderId = order.id
|
- |
|
| 583 |
ticket.airwayBillNo = order.airwaybill_no
|
- |
|
| 584 |
|
- |
|
| 585 |
activity.creatorId = 1
|
- |
|
| 586 |
activity.ticketAssigneeId = ticket.assigneeId
|
- |
|
| 587 |
activity.type = ActivityType.OTHER
|
- |
|
| 588 |
activity.description = description
|
- |
|
| 589 |
activity.ticketCategory = ticket.category
|
- |
|
| 590 |
activity.ticketDescription = ticket.description
|
- |
|
| 591 |
activity.ticketPriority = ticket.priority
|
- |
|
| 592 |
activity.ticketStatus = ticket.status
|
- |
|
| 593 |
|
- |
|
| 594 |
if user is None or user.userId == -1:
|
- |
|
| 595 |
ticket.customerEmailId = order.customer_email
|
- |
|
| 596 |
ticket.customerMobileNumber = order.customer_mobilenumber
|
- |
|
| 597 |
ticket.customerName = order.customer_name
|
- |
|
| 598 |
activity.customerEmailId = order.customer_email
|
- |
|
| 599 |
activity.customerMobileNumber = order.customer_mobilenumber
|
- |
|
| 600 |
activity.customerName = order.customer_name
|
- |
|
| 601 |
else:
|
- |
|
| 602 |
ticket.customerId = user.userId
|
- |
|
| 603 |
activity.customerId = user.userId
|
- |
|
| 604 |
|
- |
|
| 605 |
crmServiceClient.insertTicket(ticket, activity)
|
- |
|
| 606 |
'''
|
- |
|
| 607 |
Inform user about first delivery attempt
|
- |
|
| 608 |
'''
|
- |
|
| 609 |
enqueueMailForFDA(order)
|
- |
|
| 610 |
except:
|
- |
|
| 611 |
print "Some issue while creating crm tickets for orders in FIRST_DELIVERY_ATTEMPT_MADE status"
|
- |
|
| 612 |
traceback.print_exc()
|
- |
|
| 613 |
|
- |
|
| 614 |
def auto_close_crm_tickets_created():
|
552 |
def auto_close_crm_tickets_created():
|
| 615 |
try:
|
553 |
try:
|
| 616 |
ticket_created_orders = []
|
554 |
ticket_created_orders = []
|
| 617 |
tickets_map = {}
|
555 |
tickets_map = {}
|
| 618 |
crmServiceClient = CRMClient().get_client()
|
556 |
crmServiceClient = CRMClient().get_client()
|
| Line 628... |
Line 566... |
| 628 |
tickets_map[old_ticket.orderId] = old_ticket
|
566 |
tickets_map[old_ticket.orderId] = old_ticket
|
| 629 |
print ticket_created_orders
|
567 |
print ticket_created_orders
|
| 630 |
txnClient = TransactionClient().get_client()
|
568 |
txnClient = TransactionClient().get_client()
|
| 631 |
orders = txnClient.getOrderList(ticket_created_orders)
|
569 |
orders = txnClient.getOrderList(ticket_created_orders)
|
| 632 |
for order in orders:
|
570 |
for order in orders:
|
| 633 |
if order.status not in [OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE]:
|
571 |
if order.status not in [OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE, OrderStatus.RTO_IN_TRANSIT]:
|
| 634 |
old_ticket = tickets_map.get(order.id)
|
572 |
old_ticket = tickets_map.get(order.id)
|
| 635 |
old_ticket.status = TicketStatus.CLOSED
|
573 |
old_ticket.status = TicketStatus.CLOSED
|
| 636 |
activity = Activity()
|
574 |
activity = Activity()
|
| 637 |
activity.creatorId = 1
|
575 |
activity.creatorId = 1
|
| 638 |
activity.ticketAssigneeId = old_ticket.assigneeId
|
576 |
activity.ticketAssigneeId = old_ticket.assigneeId
|