Subversion Repositories SmartDukaan

Rev

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

Rev 20091 Rev 20152
Line 28... Line 28...
28
import in.shop2020.thrift.clients.HelperClient;
28
import in.shop2020.thrift.clients.HelperClient;
29
import in.shop2020.thrift.clients.PaymentClient;
29
import in.shop2020.thrift.clients.PaymentClient;
30
import in.shop2020.thrift.clients.TransactionClient;
30
import in.shop2020.thrift.clients.TransactionClient;
31
import in.shop2020.thrift.clients.UserClient;
31
import in.shop2020.thrift.clients.UserClient;
32
import in.shop2020.util.CRMConstants;
32
import in.shop2020.util.CRMConstants;
-
 
33
import in.shop2020.util.CRMConstants.Actionable;
33
import in.shop2020.util.CRMConstants.EscalationMatrix;
34
import in.shop2020.util.CRMConstants.EscalationMatrix;
34
import in.shop2020.util.CRMConstants.PMEscalationMatrix;
35
import in.shop2020.util.CRMConstants.PMEscalationMatrix;
35
import in.shop2020.util.SendGrid;
36
import in.shop2020.util.SendGrid;
36
import in.shop2020.util.SendGridException;
37
import in.shop2020.util.SendGridException;
37
import in.shop2020.utils.GmailUtils;
38
import in.shop2020.utils.GmailUtils;
Line 106... Line 107...
106
    private String            pickupExtension;
107
    private String            pickupExtension;
107
    private Map<String, Long> ticketCategorycountMap;
108
    private Map<String, Long> ticketCategorycountMap;
108
    private String premises = "";
109
    private String premises = "";
109
    private String closureType = "";
110
    private String closureType = "";
110
    private String paymentId;
111
    private String paymentId;
111
    private String 			  quantity;
112
    private String quantity;
-
 
113
    private String disposition;
-
 
114
    private List<String> actionable;
112
 
115
 
113
    private HashMap<String, String> allAttachmentsForTicket;
116
    private HashMap<String, String> allAttachmentsForTicket;
114
 
117
 
115
    public String index() {
118
    public String index() {
116
        try {
119
        try {
Line 151... Line 154...
151
                }
154
                }
152
            }
155
            }
153
 
156
 
154
            customerEmailId = ticket.getCustomerEmailId();
157
            customerEmailId = ticket.getCustomerEmailId();
155
 
158
 
-
 
159
            setSuitableActionable(ticket.getCategory());
-
 
160
            //log.info("actionable list "+ getActionable());
-
 
161
            
156
            if (TicketCategory.ORDER_CANCELLATION.equals(ticket.getCategory())) {
162
            if (TicketCategory.ORDER_CANCELLATION.equals(ticket.getCategory())) {
157
                log.info("Fetching orders for " + ticket.getCustomerId());
163
                log.info("Fetching orders for " + ticket.getCustomerId());
158
                orders = new ArrayList<Order>();
164
                orders = new ArrayList<Order>();
159
                transactionServiceClient = new TransactionClient().getClient();
165
                transactionServiceClient = new TransactionClient().getClient();
160
                for (Order order : transactionServiceClient
166
                for (Order order : transactionServiceClient
Line 596... Line 602...
596
                activityDescription = "Ticket fields updated";
602
                activityDescription = "Ticket fields updated";
597
            }
603
            }
598
 
604
 
599
            Activity activity = new Activity();
605
            Activity activity = new Activity();
600
            activity.setDescription(activityDescription);
606
            activity.setDescription(activityDescription);
-
 
607
            if(getDisposition()!=null&&!Actionable.NO_ACTION.toString().equals(getDisposition())){
-
 
608
            	activity.setDescription(getDisposition()+" -> "+activityDescription);
-
 
609
            }
601
            activity.setType(ActivityType.valueOf(activityType));
610
            activity.setType(ActivityType.valueOf(activityType));
602
            activity.setTicketPriority(ticket.getPriority());
611
            activity.setTicketPriority(ticket.getPriority());
603
            activity.setTicketStatus(ticket.getStatus());
612
            activity.setTicketStatus(ticket.getStatus());
604
            activity.setCreatorId(creatorId);
613
            activity.setCreatorId(creatorId);
605
            activity.setTicketCategory(ticket.getCategory());
614
            activity.setTicketCategory(ticket.getCategory());
Line 777... Line 786...
777
                activity.setCustomerId(user.getUserId());
786
                activity.setCustomerId(user.getUserId());
778
            }
787
            }
779
 
788
 
780
            crmServiceClient = new CRMClient().getClient();
789
            crmServiceClient = new CRMClient().getClient();
781
            crmServiceClient.updateTicket(ticket, activity);
790
            crmServiceClient.updateTicket(ticket, activity);
-
 
791
            
-
 
792
            if(getDisposition()!=null&&!Actionable.NO_ACTION.toString().equals(getDisposition())){
-
 
793
            	if(Actionable.EMAIL_PROVIDER_REATTEMPT_DELIVERY.toString().equals(getDisposition())){
-
 
794
            TransactionClient transactionServiceClient = new TransactionClient();
-
 
795
            
-
 
796
            Order order = transactionServiceClient.getClient().getOrder(ticket.getOrderId());
-
 
797
            CRMConstants.LogisticProvider lgp = CRMConstants.LogisticProvider.findByValue(order.getLogistics_provider_id());
-
 
798
            
-
 
799
            List<String> emailDetails = CRMConstants.LOGISTIC_PROVIDER_MAP.get(lgp);
-
 
800
            if(emailDetails!=null){
-
 
801
            	String to[] = emailDetails.get(0).split(",");
-
 
802
            	String cc[] = emailDetails.get(1).split(",");
-
 
803
            	String awb = order.getAirwaybill_no();
-
 
804
            	String subject = "Arrange the delivery on priority - "+awb;
-
 
805
            	String masterOrderId = order.getLogisticsTransactionId();
-
 
806
            	String emailBody = "Hi,\n\nPlease find the below shipment details as customer is ready "
-
 
807
            			+ "to take delivery. So please arrange the delivery on priority.\n\nOrder "
-
 
808
            			+ "details: Master Order Id:- "+masterOrderId+"\n\nAirway Bill No : "+awb+
-
 
809
            			"\nLogitics Provider : "+lgp.toString()+"\n\nRegards,\nShailesh Kumar\nHotspot Sales "
-
 
810
            					+ "& Solution Pvt Ltd.\nContact-: +91-8826003137, 0120-3859501";
-
 
811
            	
-
 
812
            	
-
 
813
            	
-
 
814
            	//send mail
-
 
815
            	log.info("Sending delivery attempt mail to logistic provider :- "+to[0]);
-
 
816
            	
-
 
817
            	GmailUtils mailer = new GmailUtils();
-
 
818
            	mailer.sendSSLMessage(to,cc, subject, emailBody, CRMConstants.ADWORDS_EMAIL, 
-
 
819
            			CRMConstants.ADWORDS_PASSWORD, new ArrayList<File>());
-
 
820
        		log.info("Mail sent to logistic provider:- "+to[0]+" "+cc[0]);
-
 
821
            	
-
 
822
            	
-
 
823
            }
-
 
824
            	}
-
 
825
            }
782
        } catch (TException e) {
826
        } catch (TException e) {
783
            log.error("Error while updating ticket", e);
827
            log.error("Error while updating ticket", e);
784
            return EXCEPTION;
828
            return EXCEPTION;
785
        } catch (HelperServiceException hse) {
829
        } catch (HelperServiceException hse) {
786
            log.error("Error while sending mail", hse);
830
            log.error("Error while sending mail", hse);
787
            return EXCEPTION;
831
            return EXCEPTION;
-
 
832
        } catch (TransactionServiceException e) {
-
 
833
        	log.error("Error while fetching order details", e);
-
 
834
            return EXCEPTION;
-
 
835
		} catch (MessagingException e) {
-
 
836
			// TODO Auto-generated catch block
-
 
837
			e.printStackTrace();
788
        }
838
		}
789
 
839
 
790
        return INDEX;
840
        return INDEX;
791
    }
841
    }
792
 
842
 
793
    private String createEscalationMailBody(Ticket ticket)
843
    private String createEscalationMailBody(Ticket ticket)
Line 1796... Line 1846...
1796
	}
1846
	}
1797
 
1847
 
1798
	public void setTransactionTotal(Map<Long, Long> transactionTotal) {
1848
	public void setTransactionTotal(Map<Long, Long> transactionTotal) {
1799
		this.transactionTotal = transactionTotal;
1849
		this.transactionTotal = transactionTotal;
1800
	}
1850
	}
-
 
1851
 
-
 
1852
	public String getDisposition() {
-
 
1853
		return disposition;
-
 
1854
	}
-
 
1855
 
-
 
1856
	public void setDisposition(String disposition) {
-
 
1857
		this.disposition = disposition;
-
 
1858
	}
-
 
1859
 
-
 
1860
	public List<String> getActionable() {
-
 
1861
		return actionable;
-
 
1862
	}
-
 
1863
 
-
 
1864
	public void setActionable(List<String> actionable) {
-
 
1865
		this.actionable = actionable;
-
 
1866
	}
-
 
1867
	
-
 
1868
	public void setSuitableActionable(TicketCategory ticketCategory){
-
 
1869
		this.actionable = CRMConstants.CATEGORY_ACTION_MAP.get(ticketCategory);
-
 
1870
	}
-
 
1871
	
1801
}
1872
}