Subversion Repositories SmartDukaan

Rev

Rev 4008 | Rev 4034 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4008 Rev 4020
Line 25... Line 25...
25
import in.shop2020.thrift.clients.HelperClient;
25
import in.shop2020.thrift.clients.HelperClient;
26
import in.shop2020.thrift.clients.PaymentClient;
26
import in.shop2020.thrift.clients.PaymentClient;
27
import in.shop2020.thrift.clients.TransactionClient;
27
import in.shop2020.thrift.clients.TransactionClient;
28
import in.shop2020.thrift.clients.UserClient;
28
import in.shop2020.thrift.clients.UserClient;
29
import in.shop2020.util.CRMConstants;
29
import in.shop2020.util.CRMConstants;
-
 
30
import in.shop2020.util.CRMConstants.EscalationMatrix;
30
import in.shop2020.utils.HelperService.Client;
31
import in.shop2020.utils.HelperService.Client;
31
import in.shop2020.utils.HelperServiceException;
32
import in.shop2020.utils.HelperServiceException;
32
import in.shop2020.utils.ModelUtils;
33
import in.shop2020.utils.ModelUtils;
33
 
34
 
34
import java.text.ParseException;
35
import java.text.ParseException;
Line 76... Line 77...
76
    private String            customerName;
77
    private String            customerName;
77
    private String            customerMobileNumber;
78
    private String            customerMobileNumber;
78
    private User              user;
79
    private User              user;
79
    private String            orderStatus;
80
    private String            orderStatus;
80
    private List<Order>       orders;
81
    private List<Order>       orders;
-
 
82
    private String            escalate;
81
 
83
 
82
    public String index() {
84
    public String index() {
83
        try {
85
        try {
84
            if (id != null && !id.isEmpty()) {
86
            if (id != null && !id.isEmpty()) {
85
                SearchFilter searchFilter = new SearchFilter();
87
                SearchFilter searchFilter = new SearchFilter();
Line 396... Line 398...
396
                // closes
398
                // closes
397
                activity.setDescription("Subject: " + subject + "\n\n"
399
                activity.setDescription("Subject: " + subject + "\n\n"
398
                        + "Body: " + body);
400
                        + "Body: " + body);
399
            }
401
            }
400
 
402
 
-
 
403
            if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
-
 
404
                log.info("Sending escalation mail");
-
 
405
                EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
-
 
406
                List<Integer> escalationReceipients = escalation.getAgentIds();
-
 
407
 
-
 
408
                String toMailIds = "";
-
 
409
                for (Integer agentId : escalationReceipients) {
-
 
410
                    toMailIds += CRMAuthorizingRealm.getAgent(agentId).getEmailId() + ";";
-
 
411
                }
-
 
412
 
-
 
413
                Client helperClient = new HelperClient().getClient();
-
 
414
                String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
-
 
415
                String escalationMailBody = createEscalationMailBody(ticket, escalation);
-
 
416
 
-
 
417
                activity.setUserEmailId(helperClient.saveUserEmailForSending(
-
 
418
                        toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
-
 
419
                        escalationMailSubject, escalationMailBody,
-
 
420
                        null, CRMConstants.CRM_EMAIL_TYPE));
-
 
421
 
-
 
422
                // We change activityType to OTHER when pop up box for email
-
 
423
                // closes
-
 
424
                activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
-
 
425
                        + "Body: " + escalationMailBody);
-
 
426
            }
-
 
427
 
401
            // handling null values appropriately
428
            // handling null values appropriately
402
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
429
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
403
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
430
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
404
                        .getId();
431
                        .getId();
405
                ticket.setAssigneeId(assigneeId);
432
                ticket.setAssigneeId(assigneeId);
Line 450... Line 477...
450
        }
477
        }
451
 
478
 
452
        return index();
479
        return index();
453
    }
480
    }
454
 
481
 
-
 
482
    private String createEscalationMailBody(Ticket ticket,
-
 
483
            EscalationMatrix escalation)
-
 
484
    {
-
 
485
        return body + "<br />Please visit following URL to check ticket details.<br />" + 
-
 
486
            "http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
-
 
487
    }
-
 
488
 
-
 
489
    private String createEscalationMailSubject(Ticket ticket,
-
 
490
            EscalationMatrix escalation)
-
 
491
    {
-
 
492
        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
-
 
493
    }
-
 
494
 
455
    private boolean pendingCODOrders(long customerId) {
495
    private boolean pendingCODOrders(long customerId) {
456
        try {
496
        try {
457
            log.info("Trying to fetch orders for " + customerId);
497
            log.info("Trying to fetch orders for " + customerId);
458
            transactionServiceClient = new TransactionClient().getClient();
498
            transactionServiceClient = new TransactionClient().getClient();
459
            for (Order order : transactionServiceClient.getOrdersForCustomer(
499
            for (Order order : transactionServiceClient.getOrdersForCustomer(
Line 536... Line 576...
536
        }
576
        }
537
 
577
 
538
        return user;
578
        return user;
539
    }
579
    }
540
 
580
 
-
 
581
    public EscalationMatrix[] getEscalationMatrix () {
-
 
582
        return CRMConstants.EscalationMatrix.values();
-
 
583
    }
-
 
584
 
541
    public String getAddress(Order order) {
585
    public String getAddress(Order order) {
542
        return ModelUtils.extractAddressFromOrder(order);
586
        return ModelUtils.extractAddressFromOrder(order);
543
    }
587
    }
544
 
588
 
545
    public String getProductName(LineItem lineItem) {
589
    public String getProductName(LineItem lineItem) {
Line 759... Line 803...
759
    }
803
    }
760
 
804
 
761
    public void setOrders(List<Order> orders) {
805
    public void setOrders(List<Order> orders) {
762
        this.orders = orders;
806
        this.orders = orders;
763
    }
807
    }
-
 
808
 
-
 
809
    public String getEscalate() {
-
 
810
        return escalate;
-
 
811
    }
-
 
812
 
-
 
813
    public void setEscalate(String escalate) {
-
 
814
        this.escalate = escalate;
-
 
815
    }
764
}
816
}