Subversion Repositories SmartDukaan

Rev

Rev 18342 | Rev 18929 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3137 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
3339 mandeep.dh 6
import in.shop2020.crm.Activity;
7
import in.shop2020.crm.ActivityType;
3137 mandeep.dh 8
import in.shop2020.crm.Agent;
3390 mandeep.dh 9
import in.shop2020.crm.SearchFilter;
3137 mandeep.dh 10
import in.shop2020.crm.Ticket;
3339 mandeep.dh 11
import in.shop2020.crm.TicketCategory;
12
import in.shop2020.crm.TicketPriority;
3137 mandeep.dh 13
import in.shop2020.crm.TicketStatus;
5791 anupam.sin 14
import in.shop2020.model.v1.order.Attribute;
3546 mandeep.dh 15
import in.shop2020.model.v1.order.LineItem;
16
import in.shop2020.model.v1.order.Order;
17
import in.shop2020.model.v1.order.OrderStatus;
4267 anupam.sin 18
import in.shop2020.model.v1.order.Transaction;
3546 mandeep.dh 19
import in.shop2020.model.v1.order.TransactionServiceException;
4267 anupam.sin 20
import in.shop2020.model.v1.order.TransactionStatus;
3137 mandeep.dh 21
import in.shop2020.model.v1.user.User;
22
import in.shop2020.model.v1.user.UserContextException;
3578 mandeep.dh 23
import in.shop2020.payments.Payment;
24
import in.shop2020.payments.PaymentException;
25
import in.shop2020.payments.PaymentStatus;
3390 mandeep.dh 26
import in.shop2020.serving.auth.CRMAuthorizingRealm;
27
import in.shop2020.thrift.clients.CRMClient;
3405 mandeep.dh 28
import in.shop2020.thrift.clients.HelperClient;
3578 mandeep.dh 29
import in.shop2020.thrift.clients.PaymentClient;
3546 mandeep.dh 30
import in.shop2020.thrift.clients.TransactionClient;
3390 mandeep.dh 31
import in.shop2020.thrift.clients.UserClient;
3405 mandeep.dh 32
import in.shop2020.util.CRMConstants;
4020 mandeep.dh 33
import in.shop2020.util.CRMConstants.EscalationMatrix;
16244 manish.sha 34
import in.shop2020.util.CRMConstants.PMEscalationMatrix;
17196 manish.sha 35
import in.shop2020.util.SendGrid;
16642 manish.sha 36
import in.shop2020.util.SendGridException;
17196 manish.sha 37
import in.shop2020.utils.GmailUtils;
3405 mandeep.dh 38
import in.shop2020.utils.HelperService.Client;
39
import in.shop2020.utils.HelperServiceException;
3546 mandeep.dh 40
import in.shop2020.utils.ModelUtils;
3137 mandeep.dh 41
 
17083 manish.sha 42
import java.io.File;
3397 mandeep.dh 43
import java.text.ParseException;
5791 anupam.sin 44
import java.text.SimpleDateFormat;
3137 mandeep.dh 45
import java.util.ArrayList;
5791 anupam.sin 46
import java.util.Arrays;
3578 mandeep.dh 47
import java.util.Calendar;
3390 mandeep.dh 48
import java.util.Collections;
3405 mandeep.dh 49
import java.util.Date;
4490 anupam.sin 50
import java.util.HashMap;
3137 mandeep.dh 51
import java.util.List;
5909 amar.kumar 52
import java.util.Map;
3137 mandeep.dh 53
 
17083 manish.sha 54
import javax.mail.MessagingException;
55
 
4256 mandeep.dh 56
import net.htmlparser.jericho.Source;
57
 
3405 mandeep.dh 58
import org.apache.shiro.SecurityUtils;
3137 mandeep.dh 59
import org.apache.thrift.TException;
3546 mandeep.dh 60
import org.apache.thrift.transport.TTransportException;
3137 mandeep.dh 61
 
62
/**
63
 * @author mandeep
64
 * 
65
 */
66
public class TicketsController extends BaseController {
67
 
68
    /**
69
     * 
70
     */
71
    private static final long serialVersionUID = 1L;
72
 
73
    List<Ticket>              tickets          = new ArrayList<Ticket>();
14882 manish.sha 74
 
3405 mandeep.dh 75
    private String            customerEmailId;
3339 mandeep.dh 76
    private String            description;
77
    private String            assigneeEmailId;
78
    private String            priority;
79
    private String            category;
80
    private String            orderId;
3397 mandeep.dh 81
    private String[]          agentIds;
82
    private String            startTimestamp;
83
    private String            endTimestamp;
3137 mandeep.dh 84
 
3405 mandeep.dh 85
    private String            userId;
86
    private String            id;
87
    private String            activityDescription;
88
    private String            status;
89
    private String            activityType;
90
    private Ticket            ticket;
91
    private List<Activity>    activities;
92
    private String            subject;
93
    private String            body;
94
    private String            customerName;
95
    private String            customerMobileNumber;
3546 mandeep.dh 96
    private User              user;
97
    private String            orderStatus;
98
    private List<Order>       orders;
18341 amit.gupta 99
    private Map<Long, Order>       transactions;
18342 amit.gupta 100
	private Map<Long, Long>    transactionShipping;
101
    private Map<Long, Long>    transactionTotal;
4267 anupam.sin 102
    private List<Payment>     payments;
4020 mandeep.dh 103
    private String            escalate;
4241 anupam.sin 104
    private String            cancelReason;
4267 anupam.sin 105
    private String            transactionId;
5791 anupam.sin 106
    private String            pickupExtension;
5909 amar.kumar 107
    private Map<String, Long> ticketCategorycountMap;
7645 anupam.sin 108
    private String premises = "";
109
    private String closureType = "";
4438 anupam.sin 110
    private String paymentId;
16244 manish.sha 111
    private List<Agent> 	  crmAgents = new ArrayList<Agent>();
112
    private List<Agent>       pmAgents = new ArrayList<Agent>();
4438 anupam.sin 113
 
4490 anupam.sin 114
    private HashMap<String, String> allAttachmentsForTicket;
14882 manish.sha 115
 
116
    public static final List<TicketCategory> profitMandiTicketCategoryList = new ArrayList<TicketCategory>() {
117
        {
118
            add(TicketCategory.PROFITMANDI_CASHBACK);
119
            add(TicketCategory.PROFITMANDI_FEEDBACK);
120
            add(TicketCategory.PROFITMANDI_ORDER_NOT_SEEN);
121
            add(TicketCategory.PROFITMANDI_RECHARGE_ISSUE);
122
            add(TicketCategory.PROFITMANDI_OTHER);
123
        }
124
    };
4490 anupam.sin 125
 
3405 mandeep.dh 126
    public String index() {
127
        try {
128
            if (id != null && !id.isEmpty()) {
129
                SearchFilter searchFilter = new SearchFilter();
130
                crmServiceClient = new CRMClient().getClient();
131
                searchFilter.setTicketId(Long.parseLong(id));
132
                tickets = crmServiceClient.getTickets(searchFilter);
133
            }
134
        } catch (TException e) {
135
            log.error("Error while getting tickets", e);
136
            return EXCEPTION;
137
        }
138
 
139
        return INDEX;
140
    }
141
 
142
    public String edit() {
143
        try {
144
            long ticketId = Long.parseLong(id);
145
            SearchFilter searchFilter = new SearchFilter();
146
            searchFilter.setTicketId(ticketId);
147
            crmServiceClient = new CRMClient().getClient();
148
            ticket = crmServiceClient.getTickets(searchFilter).get(0);
149
            activities = crmServiceClient.getActivities(searchFilter);
4490 anupam.sin 150
            populateAttachments();
3405 mandeep.dh 151
            subject = createSubjectString(ticket);
152
 
153
            if (ticket.isSetCustomerId()) {
154
                userId = String.valueOf(ticket.getCustomerId());
3546 mandeep.dh 155
                userContextServiceClient = new UserClient().getClient();
156
 
157
                try {
158
                    user = userContextServiceClient.getUserById(ticket
159
                            .getCustomerId());
160
                } catch (UserContextException e) {
161
                    log.error("Could not fetch user details", e);
162
                }
3405 mandeep.dh 163
            }
164
 
165
            customerEmailId = ticket.getCustomerEmailId();
4689 anupam.sin 166
 
4277 anupam.sin 167
            if (TicketCategory.ORDER_CANCELLATION.equals(ticket.getCategory())) {
168
                log.info("Fetching orders for " + ticket.getCustomerId());
169
                orders = new ArrayList<Order>();
170
                transactionServiceClient = new TransactionClient().getClient();
4689 anupam.sin 171
                for (Order order : transactionServiceClient
172
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
173
                                Collections.singletonList(OrderStatus.CANCEL_REQUEST_RECEIVED))) {
174
                    log.info("Processing Order: " + order.getId());
4287 anupam.sin 175
                    orders.add(order);
176
                }
4277 anupam.sin 177
            }
3546 mandeep.dh 178
 
179
            if (TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())) {
180
                log.info("Fetching orders for " + ticket.getCustomerId());
181
                orders = new ArrayList<Order>();
18341 amit.gupta 182
                transactions = new HashMap<Long, Order>();
18343 amit.gupta 183
                transactionShipping = new HashMap<Long, Long>();
184
                transactionTotal = new HashMap<Long, Long>();
3546 mandeep.dh 185
                transactionServiceClient = new TransactionClient().getClient();
186
                for (Order order : transactionServiceClient
187
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
4663 rajveer 188
                                Collections.singletonList(OrderStatus.COD_VERIFICATION_PENDING))) {
3546 mandeep.dh 189
                    log.info("Processing Order: " + order);
190
                    if (order.isCod()) {
18341 amit.gupta 191
                    	transactions.put(order.getTransactionId(), order);
192
                    	if (transactionShipping.get(order.getTransactionId()) == null){
18342 amit.gupta 193
                    		transactionShipping.put(order.getTransactionId(), (long)order.getShippingCost());
18341 amit.gupta 194
                    	} else {
18342 amit.gupta 195
                    		transactionShipping.put(order.getTransactionId(), transactionShipping.get(order.getTransactionId()).longValue() + (long)order.getShippingCost());
18341 amit.gupta 196
                    	}
197
                    	if (transactionTotal.get(order.getTransactionId()) == null){
18342 amit.gupta 198
                    		transactionTotal.put(order.getTransactionId(), (long)order.getTotal_amount()-(long)order.getGvAmount());
18341 amit.gupta 199
                    	} else {
18342 amit.gupta 200
                    		transactionTotal.put(order.getTransactionId(), transactionTotal.get(order.getTransactionId()).longValue() + (long)order.getTotal_amount()-(long)order.getGvAmount());
18341 amit.gupta 201
                    	}
202
                    	transactions.put(order.getTransactionId(), order);
3546 mandeep.dh 203
                        orders.add(order);
204
                    }
205
                }
18341 amit.gupta 206
 
3546 mandeep.dh 207
            }
4689 anupam.sin 208
 
4490 anupam.sin 209
            if (TicketCategory.DOA_RECEIVED.equals(ticket.getCategory())) {
210
                log.info("Fetching orders for " + ticket.getCustomerId());
211
                orders = new ArrayList<Order>();
212
                transactionServiceClient = new TransactionClient().getClient();
213
                for (Order order : transactionServiceClient
214
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
215
                                Collections.singletonList(OrderStatus.DOA_REQUEST_RECEIVED))) {
216
                    log.info("Processing Order: " + order);
217
                    if (order != null) {
218
                        orders.add(order);
219
                    }
220
                }
221
            }
4689 anupam.sin 222
 
4490 anupam.sin 223
            if (TicketCategory.RETURN_FORM.equals(ticket.getCategory())) {
224
                log.info("Fetching orders for " + ticket.getCustomerId());
225
                orders = new ArrayList<Order>();
226
                transactionServiceClient = new TransactionClient().getClient();
227
                for (Order order : transactionServiceClient
228
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
229
                                Collections.singletonList(OrderStatus.RET_REQUEST_RECEIVED))) {
230
                    log.info("Processing Order: " + order);
231
                    if (order != null) {
232
                        orders.add(order);
233
                    }
234
                }
235
            }
3578 mandeep.dh 236
 
4267 anupam.sin 237
            if (TicketCategory.PAYMENT_FLAGGED.equals(ticket.getCategory())) {
238
                log.info("Fetching orders for " + ticket.getCustomerId());
239
                payments = new ArrayList<Payment>();
240
                in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
241
                transactionServiceClient = new TransactionClient().getClient();
242
                for (Transaction transaction : transactionServiceClient
243
                        .getTransactionsForCustomer(ticket.getCustomerId(), 0, 0, TransactionStatus.FLAGGED)) {
244
                    log.info("Processing Transaction: " + transaction);
245
                    for ( Payment payment : paymentClient.getPaymentForTxnId(transaction.getId())) {
246
                        if( payment.getStatus().equals(PaymentStatus.AUTHORIZED)) {
247
                            payments.add(payment);
248
                        }
249
                    }
250
                }
251
            }
252
 
3578 mandeep.dh 253
            if (TicketCategory.FAILED_PAYMENTS.equals(ticket.getCategory())) {
254
                log.info("Fetching orders for " + ticket.getCustomerId());
255
                orders = new ArrayList<Order>();
256
                in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
257
 
258
                long failedTransactionId = -1;
259
                long lastfailedTransactionTimestamp = -1;
260
                for (Payment payment : paymentClient.getPaymentsForUser(ticket.getCustomerId(), 0, getTomorrow().getTime(), PaymentStatus.FAILED, 0)) {
261
                    if (payment.getErrorTimestamp() > lastfailedTransactionTimestamp) {
262
                        failedTransactionId = payment.getMerchantTxnId();
263
                    }
264
                }
265
 
266
                transactionServiceClient = new TransactionClient().getClient();
267
                orders.addAll(transactionServiceClient.getOrdersForTransaction(failedTransactionId, ticket.getCustomerId()));
268
            }
4008 mandeep.dh 269
 
270
            if (TicketCategory.DELAYED_DELIVERY.equals(ticket.getCategory())) {
271
                log.info("Fetching orders for " + ticket.getCustomerId());
272
                orders = new ArrayList<Order>();
273
                transactionServiceClient = new TransactionClient().getClient();
274
 
275
                for (Order order : transactionServiceClient.getOrdersForCustomer(ticket.getCustomerId(), 0, 0, null)) {
276
                    if (order.getExpected_delivery_time() > order.getPromised_delivery_time() && order.getExpected_delivery_time() > new Date().getTime()) {
277
                        orders.add(order);
278
                    }
279
                }
280
            }
5791 anupam.sin 281
 
282
            if (TicketCategory.STORE_PICKUP.equals(ticket.getCategory())) {
283
                log.info("Fetching orders for " + ticket.getCustomerId());
284
                orders = new ArrayList<Order>();
285
                transactionServiceClient = new TransactionClient().getClient();
286
                for (Order order : transactionServiceClient
287
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
288
                                Collections.singletonList(OrderStatus.RECEIVED_AT_STORE))) {
289
                    log.info("Processing Order: " + order.getId());
290
                    orders.add(order);
291
                }
292
            }
293
 
3405 mandeep.dh 294
        } catch (TException e) {
3546 mandeep.dh 295
            log.error("Error loading edit page", e);
296
        } catch (NumberFormatException e) {
297
            log.error("Error parsing orderId", e);
298
        } catch (TransactionServiceException e) {
299
            log.error("Error fetching orders for " + ticket.getCustomerId(), e);
3578 mandeep.dh 300
        } catch (PaymentException e) {
301
            log.error("Error fetching payments for " + ticket.getCustomerId(), e);
3405 mandeep.dh 302
        }
303
 
304
        return EDIT;
305
    }
306
 
4490 anupam.sin 307
    private void populateAttachments() {
308
        allAttachmentsForTicket = new HashMap<String, String>();
309
        for (Activity activity : activities) {
310
            log.info("" + activity.getId());
311
            String attachment = activity.getAttachments();
312
            if (attachment != null && !attachment.isEmpty()) {
313
                log.info("" + attachment);
314
                String [] attachmentList = attachment.split(";");
315
                for (String attachmentName : attachmentList) {
316
                    if (attachmentName != null && !attachmentName.isEmpty()) {
317
                        log.info("" + attachmentName);
318
                        allAttachmentsForTicket.put(activity.getId() + "-" + attachmentName, attachmentName);
319
                    }
320
                }
321
            }
322
        }
323
    }
324
 
5791 anupam.sin 325
    public static void main(String[] args) throws TException {
326
        SearchFilter s = new SearchFilter();
327
//      s.setTicketId(200l);
328
//      s.setTicketAssigneeIds(null);
329
//      s.setTicketAssigneeIds(new ArrayList<Long>());
330
//      s.setActivityCreatorIds(Collections.singletonList(2l));
331
//      s.setEndTimestamp(new Date());
332
      //s.setTicketCategory(TicketCategory.STORE_PICKUP);
333
      s.setTicketId((long) 51345);
334
      in.shop2020.crm.CRMService.Client crmServiceClient = new CRMClient().getClient();
335
      Ticket ticket = crmServiceClient.getTickets(s).get(0);
336
      System.out.println(ticket.getCategory().name());
4490 anupam.sin 337
    }
338
 
3405 mandeep.dh 339
    private String createSubjectString(Ticket ticket) {
14882 manish.sha 340
    	if(!profitMandiTicketCategoryList.contains(ticket.getCategory())){
341
	        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId()
342
	                + " " + ticket.getCategory().name();
343
    	}else{
344
    		return CRMConstants.PROFIT_MANDI_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId()
345
            + " " + ticket.getCategory().name();
346
    	}
3405 mandeep.dh 347
    }
348
 
3578 mandeep.dh 349
    private Date getTomorrow() {
350
        Calendar calendar = Calendar.getInstance();
351
        calendar.setTime(new Date());
352
        calendar.add(Calendar.DAY_OF_MONTH, 1);
353
        return calendar.getTime();
354
    }
355
 
3339 mandeep.dh 356
    public String create() {
357
        try {
3546 mandeep.dh 358
            long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId)
359
                    .getId();
3339 mandeep.dh 360
            Ticket ticket = new Ticket();
361
            ticket.setDescription(description);
362
            ticket.setCreatorId(creatorId);
363
            ticket.setStatus(TicketStatus.OPEN);
364
            ticket.setPriority(TicketPriority.valueOf(priority));
365
            ticket.setCategory(TicketCategory.valueOf(category));
366
 
367
            Activity activity = new Activity();
368
            activity.setDescription("Creating Ticket");
369
            activity.setType(ActivityType.OTHER);
370
            activity.setTicketPriority(TicketPriority.valueOf(priority));
371
            activity.setTicketStatus(TicketStatus.OPEN);
372
            activity.setCreatorId(creatorId);
373
            activity.setTicketCategory(TicketCategory.valueOf(category));
374
            activity.setTicketDescription(description);
375
 
376
            if (orderId != null && !orderId.isEmpty()) {
377
                ticket.setOrderId(Long.parseLong(orderId));
378
            }
4490 anupam.sin 379
 
380
            if (TicketCategory.valueOf(category) == TicketCategory.DOA_RECEIVED) {
381
                transactionServiceClient = new TransactionClient().getClient();
382
                if (!transactionServiceClient.markOrderDoaRequestReceived(Long.parseLong(orderId))) {
383
                    throw new Exception("Order cannot be marked as DOA Received");
384
                }
385
                log.info("" + userId);
386
 
387
                Order order = transactionServiceClient.getOrder(Long.parseLong(orderId));
388
                log.info("In order table id is : " + order.getCustomer_id());
389
                if (userId == null || userId.isEmpty() || order.getCustomer_id() != Long.parseLong(userId)) {
390
                    throw new Exception("This order is not associated with this user Id");
391
                }
392
            }
393
 
394
            if (TicketCategory.valueOf(category) == TicketCategory.RETURN_FORM) {
395
                transactionServiceClient = new TransactionClient().getClient();
396
                if (!transactionServiceClient.markOrderReturnRequestReceived(Long.parseLong(orderId))) {
397
                    throw new Exception("Order cannot be marked as Return Requested");
398
                }
399
                log.info("" + userId);
400
 
401
                Order order = transactionServiceClient.getOrder(Long.parseLong(orderId));
402
                log.info("In order table id is : " + order.getCustomer_id());
403
                if (userId == null || userId.isEmpty() || order.getCustomer_id() != Long.parseLong(userId)) {
404
                    throw new Exception("This order is not associated with this user Id");
405
                }
406
            }
4681 amar.kumar 407
            if(body!=null && !body.isEmpty()){
408
            	String plainTextbody = new Source(body).getTextExtractor().toString();
409
            	ticket.setDescription(description + " : " + plainTextbody);
410
            }
4490 anupam.sin 411
 
3405 mandeep.dh 412
            if (userId != null && !userId.isEmpty()) {
413
                ticket.setCustomerId(Long.parseLong(userId));
414
                activity.setCustomerId(Long.parseLong(userId));
3546 mandeep.dh 415
            } else {
3390 mandeep.dh 416
                User user = null;
417
                userContextServiceClient = new UserClient().getClient();
418
                try {
3405 mandeep.dh 419
                    if (customerName != null && !customerName.isEmpty()) {
420
                        ticket.setCustomerName(customerName);
421
                        activity.setCustomerName(customerName);
422
                    }
423
 
424
                    if (customerEmailId != null && !customerEmailId.isEmpty()) {
425
                        ticket.setCustomerEmailId(customerEmailId);
426
                        activity.setCustomerEmailId(customerEmailId);
3546 mandeep.dh 427
                        user = userContextServiceClient
428
                                .getUserByEmail(customerEmailId);
3405 mandeep.dh 429
                    }
430
 
3546 mandeep.dh 431
                    if ((user == null || user.getUserId() == -1)
432
                            && customerMobileNumber != null
433
                            && !customerMobileNumber.isEmpty()) {
3405 mandeep.dh 434
                        ticket.setCustomerMobileNumber(customerMobileNumber);
435
                        activity.setCustomerMobileNumber(customerMobileNumber);
3546 mandeep.dh 436
                        user = userContextServiceClient
437
                                .getUserByMobileNumber(Long
438
                                        .parseLong(customerMobileNumber));
3405 mandeep.dh 439
                    }
3390 mandeep.dh 440
                } catch (UserContextException e) {
3546 mandeep.dh 441
                    log.error("Could not fetch user for: " + customerEmailId
442
                            + " " + customerMobileNumber + " " + customerName,
443
                            e);
3390 mandeep.dh 444
                }
3546 mandeep.dh 445
 
3390 mandeep.dh 446
                if (user != null && user.getUserId() != -1) {
447
                    ticket.setCustomerId(user.getUserId());
448
                    activity.setCustomerId(user.getUserId());
449
                }
3339 mandeep.dh 450
            }
451
 
452
            // handling null values appropriately
453
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
3546 mandeep.dh 454
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
455
                        .getId();
3339 mandeep.dh 456
                ticket.setAssigneeId(assigneeId);
457
                activity.setTicketAssigneeId(assigneeId);
458
            }
459
 
3546 mandeep.dh 460
            crmServiceClient = new CRMClient().getClient();
461
            id = String
462
                    .valueOf(crmServiceClient.insertTicket(ticket, activity));
3339 mandeep.dh 463
        } catch (TException e) {
464
            log.error("Error while creating ticket", e);
465
            return EXCEPTION;
4490 anupam.sin 466
        } catch (NumberFormatException e) {
467
            log.error("Error while parsing Order Id", e);
468
            return EXCEPTION;
469
        } catch (TransactionServiceException e) {
470
            log.error("Error while updating order status", e);
471
            return EXCEPTION;
472
        } catch (Exception e) {
473
            log.error(e.getMessage());
474
            return EXCEPTION;
3339 mandeep.dh 475
        }
476
 
3405 mandeep.dh 477
        return index();
3339 mandeep.dh 478
    }
479
 
3405 mandeep.dh 480
    public boolean isAssigneeEditable() {
8847 manish.sha 481
        return (SecurityUtils.getSubject().hasRole("TeamLead") || SecurityUtils.getSubject().hasRole("Outbound"));
3405 mandeep.dh 482
    }
483
 
3397 mandeep.dh 484
    public String searchTickets() throws ParseException {
3137 mandeep.dh 485
        try {
3397 mandeep.dh 486
            SearchFilter searchFilter = new SearchFilter();
3405 mandeep.dh 487
            if (userId != null && !userId.isEmpty()) {
488
                searchFilter.setCustomerId(Long.parseLong(userId));
489
            }
490
 
3397 mandeep.dh 491
            if (agentIds != null && agentIds.length != 0) {
492
                searchFilter.setTicketAssigneeIds(new ArrayList<Long>());
493
                for (String agentId : agentIds) {
3546 mandeep.dh 494
                    searchFilter.getTicketAssigneeIds().add(
495
                            CRMAuthorizingRealm.getAgent(agentId).getId());
3397 mandeep.dh 496
                }
497
            }
7595 kshitij.so 498
 
499
            //Start:- Added By Manish Sharma for Searching Tickets/Activities using  Mobile No. on 21-Jun-2013
500
            if(customerMobileNumber!=null && !customerMobileNumber.isEmpty()){
501
            	searchFilter.setCustomerMobileNumber(customerMobileNumber);
502
            }
503
            //End:- Added By Manish Sharma for Searching Tickets/Activities using  Mobile No. on 21-Jun-2013
504
 
3397 mandeep.dh 505
            if (startTimestamp != null && !startTimestamp.isEmpty()) {
3546 mandeep.dh 506
                searchFilter.setStartTimestamp(SDF.parse(startTimestamp)
507
                        .getTime());
3397 mandeep.dh 508
            }
509
 
510
            if (endTimestamp != null && !endTimestamp.isEmpty()) {
511
                searchFilter.setEndTimestamp(SDF.parse(endTimestamp).getTime());
512
            }
513
 
3422 mandeep.dh 514
            if (id != null && !id.isEmpty()) {
515
                searchFilter.setTicketId(Long.parseLong(id));
516
            }
517
 
3499 mandeep.dh 518
            if (status != null && !status.isEmpty()) {
3972 mandeep.dh 519
                searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
520
                searchFilter.getTicketStatuses().add(TicketStatus.valueOf(status));
521
                if (TicketStatus.OPEN.name().equals(status)) {
522
                    searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
523
                }
3499 mandeep.dh 524
            }
525
 
526
            if (category != null && !category.isEmpty()) {
3546 mandeep.dh 527
                searchFilter
528
                        .setTicketCategory(TicketCategory.valueOf(category));
3499 mandeep.dh 529
            }
530
 
3546 mandeep.dh 531
            crmServiceClient = new CRMClient().getClient();
3405 mandeep.dh 532
            tickets = crmServiceClient.getTickets(searchFilter);
3137 mandeep.dh 533
        } catch (TException e) {
534
            String errorString = "Error getting tickets for "
535
                    + currentAgentEmailId;
536
            log.error(errorString, e);
537
            addActionError(errorString);
538
        }
539
 
3405 mandeep.dh 540
        return index();
3137 mandeep.dh 541
    }
542
 
543
    public String getUnassignedTickets() {
544
        try {
16244 manish.sha 545
        	tickets = new ArrayList<Ticket>();
3546 mandeep.dh 546
            crmServiceClient = new CRMClient().getClient();
16244 manish.sha 547
            List<Ticket> unassignedTickets = crmServiceClient.getUnassignedTickets();
548
            for(Ticket unassignedTicket: unassignedTickets){
549
            	if(isSaholicAndProfitMandiAllowed()){
550
            		tickets.add(unassignedTicket);
551
            	}else if(isProfitMandiAgent()){
552
            		if(profitMandiTicketCategoryList.contains(unassignedTicket.getCategory())){
553
            			tickets.add(unassignedTicket);
554
            		}
555
            	}else{
556
            		if(!profitMandiTicketCategoryList.contains(unassignedTicket.getCategory())){
557
            			tickets.add(unassignedTicket);
558
            		}
559
            	}
560
            }
3137 mandeep.dh 561
        } catch (TException e) {
3339 mandeep.dh 562
            String errorString = "Error getting tickets for "
563
                    + currentAgentEmailId;
3137 mandeep.dh 564
            log.error(errorString, e);
565
            addActionError(errorString);
566
        }
567
 
3405 mandeep.dh 568
        return index();
3137 mandeep.dh 569
    }
570
 
3405 mandeep.dh 571
    public String update() {
17083 manish.sha 572
    	String commonDescription ="";
573
    	String addTo[]= new String[]{"amit.sirohi@shop2020.in","rajneesh.arora@saholic.com"};
3405 mandeep.dh 574
        try {
575
            long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId)
576
                    .getId();
577
 
3546 mandeep.dh 578
            SearchFilter searchFilter = new SearchFilter();
579
            searchFilter.setTicketId(Long.parseLong(id));
580
            crmServiceClient = new CRMClient().getClient();
581
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3405 mandeep.dh 582
            ticket.setDescription(description);
583
            ticket.setPriority(TicketPriority.valueOf(priority));
584
 
585
            // Update when a ticket is closed!
3578 mandeep.dh 586
            if (TicketStatus.CLOSED.name().equals(status) || TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())) {
3546 mandeep.dh 587
                if (TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())
588
                        && pendingCODOrders(ticket.getCustomerId())) {
589
                    addActionMessage("Cod orders pending for verification. Ticket can not be closed and its category cannot be changed.");
590
                } else {
591
                    ticket.setCategory(TicketCategory.valueOf(category));
592
                    ticket.setStatus(TicketStatus.valueOf(status));
593
                    ticket.setCloseDate(new Date().getTime());
594
                }
3405 mandeep.dh 595
            }
3546 mandeep.dh 596
            else {
597
                ticket.setCategory(TicketCategory.valueOf(category));
3578 mandeep.dh 598
                ticket.setStatus(TicketStatus.valueOf(status));
3546 mandeep.dh 599
            }
3405 mandeep.dh 600
 
601
            if (activityDescription == null || activityDescription.isEmpty()) {
4241 anupam.sin 602
                activityDescription = "Ticket fields updated";
3405 mandeep.dh 603
            }
604
 
605
            Activity activity = new Activity();
606
            activity.setDescription(activityDescription);
607
            activity.setType(ActivityType.valueOf(activityType));
3546 mandeep.dh 608
            activity.setTicketPriority(ticket.getPriority());
609
            activity.setTicketStatus(ticket.getStatus());
3405 mandeep.dh 610
            activity.setCreatorId(creatorId);
3546 mandeep.dh 611
            activity.setTicketCategory(ticket.getCategory());
612
            activity.setTicketDescription(ticket.getDescription());
3405 mandeep.dh 613
 
614
            if (userId != null && !userId.isEmpty()) {
615
                activity.setCustomerId(Long.parseLong(userId));
616
            }
617
 
4035 mandeep.dh 618
            // Handling null values appropriately
619
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
620
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
621
                        .getId();
622
                ticket.setAssigneeId(assigneeId);
623
                activity.setTicketAssigneeId(assigneeId);
624
            }
625
 
3405 mandeep.dh 626
            if (ActivityType.SEND_EMAIL_TO_CUSTOMER.equals(activity.getType())) {
627
                log.info("Sending mail");
628
                Client helperClient = new HelperClient().getClient();
14882 manish.sha 629
                if(!profitMandiTicketCategoryList.contains(ticket.getCategory())){
630
	                activity.setUserEmailId(helperClient.saveUserEmailForSending(
631
	                        Arrays.asList(customerEmailId), CRMConstants.CRM_EMAIL_SENDOR,
632
	                        subject, body, null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
633
                }else{
16524 manish.sha 634
                	try{
16642 manish.sha 635
                		sendMailToUser();          		
16524 manish.sha 636
 
637
                	} catch(Exception e){
16644 manish.sha 638
                		log.info("Error while sending mail to user:- "+customerEmailId+" ticket Id:- "+ticket.getId());
16524 manish.sha 639
                		log.error("Error while sending mail to user:- "+customerEmailId+" ticket Id:- "+ticket.getId(), e);
640
                	}
641
 
642
                	/*activity.setUserEmailId(helperClient.saveUserEmailForSending(
14882 manish.sha 643
	                        Arrays.asList(customerEmailId), CRMConstants.PROFIT_MANDI_EMAIL_SENDER,
16524 manish.sha 644
	                        subject, body, null, CRMConstants.PROFIT_MANDI_EMAIL_TYPE, null, null, 1));*/
14882 manish.sha 645
                }
3405 mandeep.dh 646
 
4256 mandeep.dh 647
                String plainTextbody = new Source(body).getTextExtractor().toString();
648
 
3405 mandeep.dh 649
                // We change activityType to OTHER when pop up box for email
650
                // closes
651
                activity.setDescription("Subject: " + subject + "\n\n"
4256 mandeep.dh 652
                        + "Body: " + plainTextbody);
4206 mandeep.dh 653
 
654
                String activityDesc = activity.getDescription();
655
                if (activityDesc.length() > CRMConstants.DESCRIPTION_MAX_WIDTH) {
656
                    activityDesc = activityDesc.substring(0, CRMConstants.DESCRIPTION_MAX_WIDTH);
657
                    activityDesc += "\n\nTHIS TEXT IS TRUNCATED. PLEASE VISIT INBOX TO SEE COMPLETE DETAILS.";
658
                }
659
 
660
                activity.setDescription(activityDesc);
3405 mandeep.dh 661
            }
662
 
4020 mandeep.dh 663
            if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
664
                log.info("Sending escalation mail");
16244 manish.sha 665
                if(escalate.startsWith("PM")){
666
                	PMEscalationMatrix escalation = CRMConstants.PMEscalationMatrix.valueOf(escalate);
667
                	List<Integer> escalationReceipients = escalation.getAgentIds();
668
 
669
                	List<String> toMailIds = new ArrayList<String>();
670
                    for (Integer agentId : escalationReceipients) {
671
                        toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
4020 mandeep.dh 672
 
16244 manish.sha 673
                        // Setting last agent as assignee
674
                        ticket.setAssigneeId(agentId);
675
                        activity.setTicketAssigneeId(agentId);
676
                    }
4034 mandeep.dh 677
 
16244 manish.sha 678
                    Client helperClient = new HelperClient().getClient();
679
                    String escalationMailSubject = createPMEscalationMailSubject(ticket, escalation);
680
                    String escalationMailBody = createEscalationMailBody(ticket);
16402 manish.sha 681
 
682
                    if(profitMandiTicketCategoryList.contains(ticket.getCategory())){
4020 mandeep.dh 683
 
16402 manish.sha 684
	                    activity.setUserEmailId(helperClient.saveUserEmailForSending(
685
	                            toMailIds, CRMConstants.PROFIT_MANDI_EMAIL_SENDER,
686
	                            escalationMailSubject, escalationMailBody,
687
	                            null, CRMConstants.PROFIT_MANDI_EMAIL_TYPE, null, null, 1));
688
                    }else{
689
                    	activity.setUserEmailId(helperClient.saveUserEmailForSending(
690
    	                        Arrays.asList(customerEmailId), CRMConstants.CRM_EMAIL_SENDOR,
691
    	                        subject, body, null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
692
                    }
4020 mandeep.dh 693
 
16244 manish.sha 694
                    // We change activityType to OTHER when pop up box for email
695
                    // closes
696
                    activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
697
                            + "Body: " + escalationMailBody);
698
                }else{
699
	                EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
700
	                List<Integer> escalationReceipients = escalation.getAgentIds();
701
 
702
	                List<String> toMailIds = new ArrayList<String>();
703
	                for (Integer agentId : escalationReceipients) {
704
	                    toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
705
 
706
	                    // Setting last agent as assignee
707
	                    ticket.setAssigneeId(agentId);
708
	                    activity.setTicketAssigneeId(agentId);
709
	                }
710
 
711
	                Client helperClient = new HelperClient().getClient();
712
	                String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
713
	                String escalationMailBody = createEscalationMailBody(ticket);
4020 mandeep.dh 714
 
16244 manish.sha 715
	                activity.setUserEmailId(helperClient.saveUserEmailForSending(
716
	                        toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
717
	                        escalationMailSubject, escalationMailBody,
718
	                        null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
719
 
720
	                // We change activityType to OTHER when pop up box for email
721
	                // closes
722
	                activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
723
	                        + "Body: " + escalationMailBody);
724
                }
4020 mandeep.dh 725
            }
17196 manish.sha 726
            if(isProfitMandiAgent()){
727
	            try{
728
	    	        if (ActivityType.RECEIVED_CALL_FROM_CUSTOMER.equals(activity.getType())) {
729
 
730
	    	        	commonDescription = "Received Call From Customer || Email Id- ";
731
		        		if (customerEmailId != null && !customerEmailId.isEmpty()) {
732
		        			commonDescription = commonDescription+customerEmailId;
733
		        		}
734
		        		if(customerMobileNumber != null
735
		                        && !customerMobileNumber.isEmpty()) {
736
		        			commonDescription = commonDescription+" & Mobile No:- "+customerMobileNumber;
737
		        		}
17198 manish.sha 738
		        		commonDescription = "PM Ticket: "+ commonDescription; 
17196 manish.sha 739
		        		sendMailtoManagersUsingGmailUtils(commonDescription, addTo, description);
740
	    	        }
741
	            }
742
	    	    catch(Exception e){
743
	    	    	e.printStackTrace();
744
	    	    	try{
745
	    	    		sendMailToManagers(commonDescription, addTo, description);
746
	    	    	}
747
	    	    	catch(Exception e1){
748
	    	    		e1.printStackTrace();
749
	    	    	}
750
	    	    }
17080 manish.sha 751
            }
4020 mandeep.dh 752
 
3405 mandeep.dh 753
            User user = null;
754
            userContextServiceClient = new UserClient().getClient();
755
            try {
756
                if (customerName != null && !customerName.isEmpty()) {
757
                    ticket.setCustomerName(customerName);
758
                    activity.setCustomerName(customerName);
759
                }
760
 
761
                if (customerEmailId != null && !customerEmailId.isEmpty()) {
762
                    ticket.setCustomerEmailId(customerEmailId);
763
                    activity.setCustomerEmailId(customerEmailId);
3546 mandeep.dh 764
                    user = userContextServiceClient
765
                            .getUserByEmail(customerEmailId);
3405 mandeep.dh 766
                }
767
 
3546 mandeep.dh 768
                if ((user == null || user.getUserId() == -1)
769
                        && customerMobileNumber != null
770
                        && !customerMobileNumber.isEmpty()) {
3405 mandeep.dh 771
                    ticket.setCustomerMobileNumber(customerMobileNumber);
772
                    activity.setCustomerMobileNumber(customerMobileNumber);
3546 mandeep.dh 773
                    user = userContextServiceClient.getUserByMobileNumber(Long
774
                            .parseLong(customerMobileNumber));
3405 mandeep.dh 775
                }
776
            } catch (UserContextException e) {
777
                log.error("Could not fetch user for: " + customerEmailId + " "
778
                        + customerMobileNumber + " " + customerName, e);
779
            }
3546 mandeep.dh 780
 
3405 mandeep.dh 781
            if (user != null && user.getUserId() != -1) {
782
                ticket.setCustomerId(user.getUserId());
783
                activity.setCustomerId(user.getUserId());
784
            }
785
 
786
            crmServiceClient = new CRMClient().getClient();
787
            crmServiceClient.updateTicket(ticket, activity);
788
        } catch (TException e) {
789
            log.error("Error while updating ticket", e);
790
            return EXCEPTION;
791
        } catch (HelperServiceException hse) {
792
            log.error("Error while sending mail", hse);
793
            return EXCEPTION;
794
        }
795
 
14882 manish.sha 796
        return INDEX;
3405 mandeep.dh 797
    }
798
 
16244 manish.sha 799
    private String createEscalationMailBody(Ticket ticket)
4020 mandeep.dh 800
    {
801
        return body + "<br />Please visit following URL to check ticket details.<br />" + 
802
            "http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
803
    }
804
 
805
    private String createEscalationMailSubject(Ticket ticket,
806
            EscalationMatrix escalation)
807
    {
808
        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
809
    }
16244 manish.sha 810
 
811
    private String createPMEscalationMailSubject(Ticket ticket,
812
            PMEscalationMatrix escalation)
813
    {
814
        return CRMConstants.PROFIT_MANDI_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
815
    }
4020 mandeep.dh 816
 
3546 mandeep.dh 817
    private boolean pendingCODOrders(long customerId) {
818
        try {
819
            log.info("Trying to fetch orders for " + customerId);
820
            transactionServiceClient = new TransactionClient().getClient();
821
            for (Order order : transactionServiceClient.getOrdersForCustomer(
822
                    customerId, 0, 0,
4663 rajveer 823
                    Collections.singletonList(OrderStatus.COD_VERIFICATION_PENDING))) {
3546 mandeep.dh 824
                log.info("Processing order: " + order.getId() + " with COD: " + order.isCod());
825
                if (order.isCod()) {
826
                    log.info("Returning true from pendingCODOrders() for " + customerId);
827
                    return true;
828
                }
829
            }
830
        } catch (TTransportException e) {
831
            log.error("Error while creating thrift client", e);
832
        } catch (TransactionServiceException e) {
833
            log.error("Error fetching orders", e);
834
        } catch (TException e) {
835
            log.error("Error fetching orders", e);
836
        }
837
 
838
        log.info("Returning false from pendingCODOrders() for " + customerId);
839
        return false;
840
    }
5791 anupam.sin 841
 
842
    public String extendExpiry() {
843
        try {
844
            log.info("order Id = " + orderId);
845
            log.info("pickup : " + pickupExtension);
846
            Attribute newAttribute = new Attribute();
847
            List<Attribute> attributes = new ArrayList<Attribute>();
848
            String extendedBy = "0";
849
            transactionServiceClient = new TransactionClient().getClient();
850
            attributes = transactionServiceClient.getAllAttributesForOrderId(Long.parseLong(orderId));
851
            for (Attribute attribute : attributes) {
852
                if (attribute.getName().equals("pickupExtension")) {
853
                    extendedBy = attribute.getValue();
854
                    break;
855
                }
856
            }
857
            log.info("ATTR = " + attributes);
858
            log.info("1");
859
            if (extendedBy.equals("0")) {
860
                newAttribute.setName("pickupExtension");
861
                newAttribute.setValue(pickupExtension);
862
                attributes.add(newAttribute);
863
                log.info("2");
864
            } else {
865
                Long totalExtension = Long.parseLong(extendedBy) + Long.parseLong(pickupExtension);
866
                for (Attribute attribute : attributes) {
867
                    if (attribute.getName().equals("pickupExtension")) {
868
                        attribute.setValue(totalExtension.toString());
869
                        log.info("3");
870
                    }
871
                }
872
            }
873
            transactionServiceClient = new TransactionClient().getClient();
874
            transactionServiceClient.setOrderAttributes(Long.parseLong(orderId), attributes);
5919 anupam.sin 875
 
876
            SearchFilter searchFilter = new SearchFilter();
877
            searchFilter.setTicketId(Long.parseLong(id));
878
            crmServiceClient = new CRMClient().getClient();
879
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
880
 
881
            // Inserting activity
882
            Activity activity = new Activity();
883
            activity.setDescription("Pickup extended by " + pickupExtension
884
                    + " Days.");
885
            activity.setType(ActivityType.OTHER);
886
            activity.setTicketPriority(ticket.getPriority());
887
            activity.setTicketStatus(ticket.getStatus());
888
            activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
889
            activity.setTicketCategory(ticket.getCategory());
890
            activity.setTicketDescription(ticket.getDescription());
891
            activity.setCustomerId(ticket.getCustomerId());
892
            activity.setTicketAssigneeId(ticket.getAssigneeId());
893
 
894
            crmServiceClient = new CRMClient().getClient();
895
            crmServiceClient.updateTicket(ticket, activity);
896
 
5917 anupam.sin 897
            //transactionServiceClient = new TransactionClient().getClient();
898
            //transactionServiceClient.enqueueExpiryExtensionEmail(orderId);
5791 anupam.sin 899
        } catch (NumberFormatException e) {
900
            e.printStackTrace();
901
        } catch (TException e) {
902
            e.printStackTrace();
903
        }
5917 anupam.sin 904
        return edit();
5791 anupam.sin 905
    }
906
 
907
    public String getPickupExpiryDate(long id, long deliveryTimestamp) {
908
        try {
909
            log.info("orderID" + id);
910
            log.info("Delivery Time : " + deliveryTimestamp);
911
            Date deliveryDate = new Date(deliveryTimestamp);
912
            Calendar cal = Calendar.getInstance();
913
            cal.setTime(deliveryDate);
914
 
915
            log.info("Orig Del Date :" + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
916
 
917
            cal.add(Calendar.DATE, 5);
918
 
919
            log.info("After adding 5 days" + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
920
 
921
            transactionServiceClient = new TransactionClient().getClient();
922
            List<Attribute> attributes = new ArrayList<Attribute>();
923
            String extendedBy = "0";
924
            attributes = transactionServiceClient.getAllAttributesForOrderId(id);
925
            for (Attribute attribute : attributes) {
926
                if (attribute.getName().equals("pickupExtension")) {
927
                    extendedBy = attribute.getValue();
928
                }
929
            }
930
            cal.add(Calendar.DATE, Integer.parseInt(extendedBy));
931
 
932
            log.info("Extended by" + extendedBy);
933
 
934
            log.info("Final : " + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
935
 
936
            SimpleDateFormat SDF = new SimpleDateFormat("dd MMM, yyyy");
937
            return SDF.format(cal.getTime());
938
 
939
        } catch (NumberFormatException e) {
940
            e.printStackTrace();
941
        } catch (TException e) {
942
            e.printStackTrace();
943
        }
944
        return "N/A";
945
    }
3546 mandeep.dh 946
 
4277 anupam.sin 947
    public String updateOrderStatus() {
948
        long creatorId;
949
        OrderStatus orderStatusEnum = null;
950
        try {
951
            creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
952
 
953
            if(orderStatus.equals("DENY_CANCEL_REQUEST")) {
954
                transactionServiceClient = new TransactionClient().getClient();
955
                transactionServiceClient.markOrderCancellationRequestDenied(Long.parseLong(orderId));
956
            } 
3546 mandeep.dh 957
 
4277 anupam.sin 958
            else {
3546 mandeep.dh 959
 
4277 anupam.sin 960
                orderStatusEnum = OrderStatus.valueOf(orderStatus);
961
                transactionServiceClient = new TransactionClient().getClient();
3578 mandeep.dh 962
 
4277 anupam.sin 963
                if (OrderStatus.SUBMITTED_FOR_PROCESSING.equals(orderStatusEnum)) {
964
                    transactionServiceClient.verifyOrder(Long.parseLong(orderId));
5348 anupam.sin 965
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 966
                }
4682 rajveer 967
                else if (OrderStatus.COD_VERIFICATION_FAILED.equals(orderStatusEnum)) {
4277 anupam.sin 968
                    transactionServiceClient.refundOrder(Long.parseLong(orderId), currentAgentEmailId, cancelReason);
5348 anupam.sin 969
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 970
                }
971
                else if (OrderStatus.CANCEL_REQUEST_CONFIRMED.equals(orderStatusEnum)) {
972
                    transactionServiceClient.markOrderCancellationRequestConfirmed(Long.parseLong(orderId));
973
                }
974
                else {
975
                    throw new UnsupportedOperationException("Cannot update status of orderId: " + orderId + " to: " + orderStatus);
976
                }
977
            }
978
 
979
            SearchFilter searchFilter = new SearchFilter();
980
            searchFilter.setTicketId(Long.parseLong(id));
981
            crmServiceClient = new CRMClient().getClient();
982
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3546 mandeep.dh 983
 
4277 anupam.sin 984
            // Inserting activity
985
            Activity activity = new Activity();
986
            activity.setDescription("Status updated for Order Id: " + orderId
987
                    + " to " + orderStatus + ", Reason: " + cancelReason + body);
988
            activity.setType(ActivityType.OTHER);
989
            activity.setTicketPriority(ticket.getPriority());
990
            activity.setTicketStatus(ticket.getStatus());
991
            activity.setCreatorId(creatorId);
992
            activity.setTicketCategory(ticket.getCategory());
993
            activity.setTicketDescription(ticket.getDescription());
994
            activity.setCustomerId(ticket.getCustomerId());
995
            activity.setTicketAssigneeId(ticket.getAssigneeId());
3546 mandeep.dh 996
 
4277 anupam.sin 997
            crmServiceClient = new CRMClient().getClient();
998
            crmServiceClient.updateTicket(ticket, activity);
3546 mandeep.dh 999
 
4277 anupam.sin 1000
        } catch (TException e) {
1001
            log.info("Thrift exception", e);
1002
        } catch (NumberFormatException e) {
1003
            log.info("Could not convert to long", e);
1004
        } catch (TransactionServiceException e) {
1005
            log.info("Transaction client exception", e);
1006
        }
1007
 
3546 mandeep.dh 1008
        return edit();
1009
    }
4277 anupam.sin 1010
 
3137 mandeep.dh 1011
    public User getUser(Long userId) {
1012
        User user = null;
1013
 
1014
        try {
3390 mandeep.dh 1015
            userContextServiceClient = new UserClient().getClient();
3137 mandeep.dh 1016
            user = userContextServiceClient.getUserById(userId);
1017
        } catch (UserContextException e) {
1018
            String errorString = "Could not fetch user for " + userId;
1019
            log.error(errorString, e);
1020
            addActionError(errorString);
1021
        } catch (TException e) {
1022
            String errorString = "Could not create client";
1023
            log.error(errorString, e);
1024
            addActionError(errorString);
1025
        }
1026
 
1027
        return user;
1028
    }
4267 anupam.sin 1029
 
4438 anupam.sin 1030
    public String allowPayment() {
1031
        try {
1032
            log.info("Allowing payment for paymentId = " + paymentId);
1033
            transactionServiceClient = new TransactionClient().getClient();
1034
            transactionServiceClient.markTransactionAsPaymentFlagRemoved(Long.parseLong(transactionId));
1035
            if (id != null && !id.isEmpty()) {
1036
                SearchFilter searchFilter = new SearchFilter();
1037
                crmServiceClient = new CRMClient().getClient();
1038
                searchFilter.setTicketId(Long.parseLong(id));
1039
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1040
                // Inserting activity
1041
                if(ticket != null) {
1042
                    Activity activity = new Activity();
1043
                    activity.setDescription("Flagged Payment allowed");
1044
                    activity.setType(ActivityType.OTHER);
1045
                    activity.setTicketPriority(ticket.getPriority());
1046
                    activity.setTicketStatus(ticket.getStatus());
1047
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1048
                    activity.setTicketCategory(ticket.getCategory());
1049
                    activity.setTicketDescription(ticket.getDescription());
1050
                    activity.setCustomerId(ticket.getCustomerId());
1051
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1052
 
1053
                    crmServiceClient = new CRMClient().getClient();
1054
                    crmServiceClient.updateTicket(ticket, activity);
1055
                }
1056
            }
1057
 
1058
        } catch (TException e) {
1059
            log.error("Error while getting tickets", e);
1060
            return EXCEPTION;
1061
        } catch (NumberFormatException e) {
1062
            log.error("Invalid ticket Id", e);
1063
            return EXCEPTION;
1064
        } catch (TransactionServiceException e) {
1065
            log.error("Error while marking transactions as Flag removed", e);
1066
            return EXCEPTION;
1067
        }
4267 anupam.sin 1068
        return edit();
1069
    }
1070
 
4490 anupam.sin 1071
    public String blockPayment() {
4438 anupam.sin 1072
        try {
1073
            log.info("Blocking payment for paymentId = " + paymentId);
1074
            transactionServiceClient = new TransactionClient().getClient();
1075
            transactionServiceClient.refundTransaction(Long.parseLong(transactionId), currentAgentEmailId, "FLAGGED_PAYMENT_CANCELLED");
1076
            if (id != null && !id.isEmpty()) {
1077
                SearchFilter searchFilter = new SearchFilter();
1078
                crmServiceClient = new CRMClient().getClient();
1079
                searchFilter.setTicketId(Long.parseLong(id));
1080
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1081
                // Inserting activity
1082
                if(ticket != null) {
1083
                    Activity activity = new Activity();
1084
                    activity.setDescription("Flagged Payment allowed");
1085
                    activity.setType(ActivityType.OTHER);
1086
                    activity.setTicketPriority(ticket.getPriority());
1087
                    activity.setTicketStatus(ticket.getStatus());
1088
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1089
                    activity.setTicketCategory(ticket.getCategory());
1090
                    activity.setTicketDescription(ticket.getDescription());
1091
                    activity.setCustomerId(ticket.getCustomerId());
1092
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1093
 
1094
                    crmServiceClient = new CRMClient().getClient();
1095
                    crmServiceClient.updateTicket(ticket, activity);
1096
                }
1097
            }
1098
 
1099
        } catch (TException e) {
1100
            log.error("Error while getting tickets", e);
1101
            return EXCEPTION;
1102
        } catch (NumberFormatException e) {
1103
            log.error("Invalid ticket Id", e);
1104
            return EXCEPTION;
1105
        } catch (TransactionServiceException e) {
1106
            log.error("Error while allowing flagged payment", e);
1107
            return EXCEPTION;
1108
        }
4267 anupam.sin 1109
        return edit();
1110
    }
4490 anupam.sin 1111
 
1112
    public String authorizeReturn() {
1113
        try {
1114
            log.info("Authorizing OrderId =" + orderId);
7645 anupam.sin 1115
            boolean isReship = false;
1116
            boolean fromStore  = false;
4490 anupam.sin 1117
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1118
            if(premises.equals("store")) {
1119
                fromStore = true;
1120
            }
1121
 
1122
            if(closureType.equals("reship")) {
1123
                isReship = true;
1124
            }
1125
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), true, fromStore, isReship);
4490 anupam.sin 1126
            if (id != null && !id.isEmpty()) {
1127
                SearchFilter searchFilter = new SearchFilter();
1128
                crmServiceClient = new CRMClient().getClient();
1129
                searchFilter.setTicketId(Long.parseLong(id));
1130
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1131
                // Inserting activity
1132
                if(ticket != null) {
1133
                    Activity activity = new Activity();
1134
                    activity.setDescription("Return Authorized");
1135
                    activity.setType(ActivityType.OTHER);
1136
                    activity.setTicketPriority(ticket.getPriority());
1137
                    activity.setTicketStatus(ticket.getStatus());
1138
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1139
                    activity.setTicketCategory(ticket.getCategory());
1140
                    activity.setTicketDescription(ticket.getDescription());
1141
                    activity.setCustomerId(ticket.getCustomerId());
1142
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
3137 mandeep.dh 1143
 
4490 anupam.sin 1144
                    crmServiceClient = new CRMClient().getClient();
1145
                    crmServiceClient.updateTicket(ticket, activity);
1146
                }
1147
            }
1148
 
1149
        } catch (TException e) {
1150
            log.error("Error while getting tickets", e);
1151
            return EXCEPTION;
1152
        } catch (NumberFormatException e) {
1153
            log.error("Invalid ticket Id", e);
1154
            return EXCEPTION;
1155
        } catch (TransactionServiceException e) {
1156
            log.error("Error while authorizing Return", e);
1157
            return EXCEPTION;
1158
        }
1159
        return edit();
1160
    }
1161
 
1162
    public String denyReturn() {
1163
        try {
1164
            log.info("Denying OrderId =" + orderId);
1165
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1166
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), false, false, false);
4490 anupam.sin 1167
            if (id != null && !id.isEmpty()) {
1168
                SearchFilter searchFilter = new SearchFilter();
1169
                crmServiceClient = new CRMClient().getClient();
1170
                searchFilter.setTicketId(Long.parseLong(id));
1171
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1172
                // Inserting activity
1173
                if(ticket != null) {
1174
                    Activity activity = new Activity();
1175
                    activity.setDescription("Return Denied");
1176
                    activity.setType(ActivityType.OTHER);
1177
                    activity.setTicketPriority(ticket.getPriority());
1178
                    activity.setTicketStatus(ticket.getStatus());
1179
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1180
                    activity.setTicketCategory(ticket.getCategory());
1181
                    activity.setTicketDescription(ticket.getDescription());
1182
                    activity.setCustomerId(ticket.getCustomerId());
1183
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1184
 
1185
                    crmServiceClient = new CRMClient().getClient();
1186
                    crmServiceClient.updateTicket(ticket, activity);
1187
                }
1188
            }
1189
 
1190
        } catch (TException e) {
1191
            log.error("Error while getting tickets", e);
1192
            return EXCEPTION;
1193
        } catch (NumberFormatException e) {
1194
            log.error("Invalid ticket Id", e);
1195
            return EXCEPTION;
1196
        } catch (TransactionServiceException e) {
1197
            log.error("Error while denying Return", e);
1198
            return EXCEPTION;
1199
        }
1200
        return edit();
1201
    }
1202
 
1203
    public String authorizeDOA() {
1204
        try {
1205
            log.info("Authorizing OrderId =" + orderId);
7645 anupam.sin 1206
            boolean isReship = false;
1207
            boolean fromStore  = false;
4490 anupam.sin 1208
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1209
            if(premises.equals("store")) {
1210
                fromStore = true;
1211
            }
1212
 
1213
            if(closureType.equals("reship")) {
1214
                isReship = true;
1215
            }
1216
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), true, fromStore, isReship);
4490 anupam.sin 1217
            if (id != null && !id.isEmpty()) {
1218
                SearchFilter searchFilter = new SearchFilter();
1219
                crmServiceClient = new CRMClient().getClient();
1220
                searchFilter.setTicketId(Long.parseLong(id));
1221
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1222
                // Inserting activity
1223
                if(ticket != null) {
1224
                    Activity activity = new Activity();
1225
                    activity.setDescription("DOA Authorized");
1226
                    activity.setType(ActivityType.OTHER);
1227
                    activity.setTicketPriority(ticket.getPriority());
1228
                    activity.setTicketStatus(ticket.getStatus());
1229
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1230
                    activity.setTicketCategory(ticket.getCategory());
1231
                    activity.setTicketDescription(ticket.getDescription());
1232
                    activity.setCustomerId(ticket.getCustomerId());
1233
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1234
 
1235
                    crmServiceClient = new CRMClient().getClient();
1236
                    crmServiceClient.updateTicket(ticket, activity);
1237
                }
1238
            }
1239
 
1240
        } catch (TException e) {
1241
            log.error("Error while getting tickets", e);
1242
            return EXCEPTION;
1243
        } catch (NumberFormatException e) {
1244
            log.error("Invalid ticket Id", e);
1245
            return EXCEPTION;
1246
        } catch (TransactionServiceException e) {
1247
            log.error("Error while authorizing DOA", e);
1248
            return EXCEPTION;
1249
        }
1250
        return edit();
1251
    }
1252
 
1253
    public String denyDOA() {
1254
        try {
1255
            log.info("Denying OrderId =" + orderId);
1256
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1257
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), false, false, false);
4490 anupam.sin 1258
            if (id != null && !id.isEmpty()) {
1259
                SearchFilter searchFilter = new SearchFilter();
1260
                crmServiceClient = new CRMClient().getClient();
1261
                searchFilter.setTicketId(Long.parseLong(id));
1262
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1263
                // Inserting activity
1264
                if(ticket != null) {
1265
                    Activity activity = new Activity();
1266
                    activity.setDescription("DOA Denied");
1267
                    activity.setType(ActivityType.OTHER);
1268
                    activity.setTicketPriority(ticket.getPriority());
1269
                    activity.setTicketStatus(ticket.getStatus());
1270
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1271
                    activity.setTicketCategory(ticket.getCategory());
1272
                    activity.setTicketDescription(ticket.getDescription());
1273
                    activity.setCustomerId(ticket.getCustomerId());
1274
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1275
 
1276
                    crmServiceClient = new CRMClient().getClient();
1277
                    crmServiceClient.updateTicket(ticket, activity);
1278
                }
1279
            }
1280
 
1281
        } catch (TException e) {
1282
            log.error("Error while getting tickets", e);
1283
            return EXCEPTION;
1284
        } catch (NumberFormatException e) {
1285
            log.error("Invalid ticket Id", e);
1286
            return EXCEPTION;
1287
        } catch (TransactionServiceException e) {
1288
            log.error("Error while denying DOA", e);
1289
            return EXCEPTION;
1290
        }
1291
        return edit();
1292
    }
5407 amar.kumar 1293
 
14882 manish.sha 1294
    public String loadProfitMandiTickets() throws ParseException {
1295
    	try {
1296
            SearchFilter searchFilter = new SearchFilter();
1297
            searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
1298
            searchFilter.getTicketStatuses().add(TicketStatus.OPEN);
1299
            searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
1300
            crmServiceClient = new CRMClient().getClient();
1301
            tickets = new ArrayList<Ticket>();
16244 manish.sha 1302
            searchFilter.setTicketCategoryList(profitMandiTicketCategoryList);
14882 manish.sha 1303
            tickets.addAll(crmServiceClient.getTickets(searchFilter));
1304
        } catch (TException e) {
1305
            String errorString = "Error getting tickets for "
1306
                    + currentAgentEmailId;
1307
            log.error(errorString, e);
1308
            addActionError(errorString);
1309
        }
1310
    	return index();
1311
    }
1312
 
5909 amar.kumar 1313
    public String getAllOpenTickets() {
1314
    	try {
1315
    		ticketCategorycountMap= new HashMap<String, Long>();
1316
            crmServiceClient = new CRMClient().getClient();
1317
            ticketCategorycountMap = crmServiceClient.getOpenTicketsMap();
1318
        } catch (TException e) {
1319
            String errorString = "Error getting tickets for "
1320
                    + currentAgentEmailId;
1321
            log.error(errorString, e);
1322
            addActionError(errorString);
1323
        }
1324
        return OPEN;
1325
    }
1326
 
5407 amar.kumar 1327
    public double getCustomerTrustLevel(long userId) {
1328
    	try {
1329
			userContextServiceClient = new UserClient().getClient();
1330
			return userContextServiceClient.getTrustLevel(userId);
1331
		} catch (TException e) {
1332
			log.info("Exception while getting trustLevel for " +
1333
					"userId " + userId);
1334
		}
1335
		return 0;
1336
    }
4490 anupam.sin 1337
 
4020 mandeep.dh 1338
    public EscalationMatrix[] getEscalationMatrix () {
1339
        return CRMConstants.EscalationMatrix.values();
1340
    }
16244 manish.sha 1341
 
1342
    public PMEscalationMatrix[] getPMEscalationMatrix () {
1343
        return CRMConstants.PMEscalationMatrix.values();
1344
    }
4020 mandeep.dh 1345
 
3546 mandeep.dh 1346
    public String getAddress(Order order) {
1347
        return ModelUtils.extractAddressFromOrder(order);
1348
    }
1349
 
1350
    public String getProductName(LineItem lineItem) {
4008 mandeep.dh 1351
        return ModelUtils.extractProductNameFromLineItem(lineItem) + " " + lineItem.getColor();
3546 mandeep.dh 1352
    }
1353
 
3405 mandeep.dh 1354
    public ActivityType[] getActivityTypes() {
1355
        return ActivityType.values();
1356
    }
1357
 
1358
    public TicketStatus[] getTicketStatuses() {
1359
        return TicketStatus.values();
1360
    }
1361
 
3390 mandeep.dh 1362
    public Agent getAgent(long agentId) throws TException {
1363
        return CRMAuthorizingRealm.getAgent(agentId);
3137 mandeep.dh 1364
    }
1365
 
3339 mandeep.dh 1366
    public List<Agent> getAllAgents() {
16244 manish.sha 1367
    	List<Agent> allagents = CRMAuthorizingRealm.getAgents();
1368
    	List<Agent> requiredAgents = new ArrayList<Agent>();
1369
    	if(isSaholicAndProfitMandiAllowed()){
1370
    		return allagents;
1371
    	} else if(isProfitMandiAgent()){
1372
    		for(Agent agent: allagents){
1373
    			if(agent.isIs_pmCrmUser()){
1374
    				requiredAgents.add(agent);
1375
    			}
1376
    		}
1377
    		return requiredAgents;
1378
    	} else{
1379
    		for(Agent agent: allagents){
1380
    			if(!agent.isIs_pmCrmUser()||agent.isIs_allAssignable()){
1381
    				requiredAgents.add(agent);
1382
    			}
1383
    		}
1384
    		return requiredAgents;
1385
    	}
3339 mandeep.dh 1386
    }
1387
 
16248 manish.sha 1388
    public List<TicketCategory> getTicketCategories() {
1389
    	List<TicketCategory> allCategories = Arrays.asList(TicketCategory.values());
1390
    	List<TicketCategory> requiredCategories = new ArrayList<TicketCategory>();
1391
    	if(isSaholicAndProfitMandiAllowed()){
1392
    		return allCategories;
1393
    	}else if(isProfitMandiAgent()){
1394
    		for(TicketCategory tkCategory: allCategories){
1395
    			if(profitMandiTicketCategoryList.contains(tkCategory)){
1396
    				requiredCategories.add(tkCategory);
1397
    			}
1398
    		}
1399
    		return requiredCategories;
1400
    	}else{
1401
    		for(TicketCategory tkCategory: allCategories){
1402
    			if(!profitMandiTicketCategoryList.contains(tkCategory)){
1403
    				requiredCategories.add(tkCategory);
1404
    			}
1405
    		}
1406
    		return requiredCategories;
1407
    	}
3339 mandeep.dh 1408
    }
16642 manish.sha 1409
 
1410
    private void sendMailToUser() throws SendGridException{
16645 manish.sha 1411
    	log.info("Sending mail to user:- "+customerEmailId);
16642 manish.sha 1412
    	SendGrid sendgrid = new SendGrid("profitmandi", "pma20aug");
1413
		SendGrid.Email email = new SendGrid.Email();
1414
		email.setFrom(CRMConstants.PROFIT_MANDI_EMAIL_SENDER);
1415
		email.setFromName("ProfitMandi");
1416
		email.addTo(customerEmailId);
1417
		email.addBcc("backup@saholic.com");
1418
		email.setSubject(subject);
16655 manish.sha 1419
		email.setHtml(body);
16649 manish.sha 1420
		log.info("Mail Body:- "+body);
16650 manish.sha 1421
		sendgrid.send(email);
1422
		log.info("Mail sent to user:- "+customerEmailId);
16642 manish.sha 1423
    }
17080 manish.sha 1424
 
1425
    private void sendMailToManagers(String subject, String[] addTo, String body) throws SendGridException{
1426
    	SendGrid sendgrid = new SendGrid("profitmandi", "pma20aug");
1427
		SendGrid.Email email = new SendGrid.Email();
1428
		email.setFrom(CRMConstants.PROFIT_MANDI_EMAIL_SENDER);
1429
		email.setFromName("ProfitMandi");
1430
		email.addTo(addTo);
1431
		email.addBcc("backup@saholic.com");
1432
		email.setSubject(subject);
1433
		email.setHtml(body);
1434
		log.info("Mail Body:- "+body);
1435
		sendgrid.send(email);
1436
		log.info("Mail sent to user:- "+addTo);
1437
    }
17083 manish.sha 1438
 
1439
    public void sendMailtoManagersUsingGmailUtils(String subject, String[] addTo, String body) throws MessagingException{
1440
    	GmailUtils mailer = new GmailUtils();
1441
		mailer.sendSSLMessage(addTo, subject, body, "build-staging@shop2020.in", "shop2020", new ArrayList<File>());
1442
    }
3339 mandeep.dh 1443
 
1444
    public TicketPriority[] getTicketPriorities() {
1445
        return TicketPriority.values();
1446
    }
1447
 
3137 mandeep.dh 1448
    public List<Ticket> getTickets() {
1449
        return tickets;
1450
    }
1451
 
1452
    public void setTickets(List<Ticket> tickets) {
1453
        this.tickets = tickets;
1454
    }
3339 mandeep.dh 1455
 
3405 mandeep.dh 1456
    public String getCustomerEmailId() {
1457
        return customerEmailId;
3339 mandeep.dh 1458
    }
1459
 
3405 mandeep.dh 1460
    public void setCustomerEmailId(String customerEmailId) {
1461
        this.customerEmailId = customerEmailId;
3339 mandeep.dh 1462
    }
1463
 
1464
    public String getDescription() {
1465
        return description;
1466
    }
1467
 
1468
    public void setDescription(String description) {
1469
        this.description = description;
1470
    }
1471
 
1472
    public String getAssigneeEmailId() {
1473
        return assigneeEmailId;
1474
    }
1475
 
1476
    public void setAssigneeEmailId(String assigneeEmailId) {
1477
        this.assigneeEmailId = assigneeEmailId;
1478
    }
1479
 
1480
    public String getPriority() {
1481
        return priority;
1482
    }
1483
 
1484
    public void setPriority(String priority) {
1485
        this.priority = priority;
1486
    }
1487
 
1488
    public String getCategory() {
1489
        return category;
1490
    }
1491
 
1492
    public void setCategory(String category) {
1493
        this.category = category;
1494
    }
1495
 
1496
    public String getOrderId() {
1497
        return orderId;
1498
    }
1499
 
1500
    public void setOrderId(String orderId) {
1501
        this.orderId = orderId;
1502
    }
3397 mandeep.dh 1503
 
1504
    public String[] getAgentIds() {
1505
        return agentIds;
1506
    }
1507
 
1508
    public void setAgentIds(String[] agentIds) {
1509
        this.agentIds = agentIds;
1510
    }
1511
 
1512
    public String getStartTimestamp() {
1513
        return startTimestamp;
1514
    }
1515
 
1516
    public void setStartTimestamp(String startTimestamp) {
1517
        this.startTimestamp = startTimestamp;
1518
    }
1519
 
1520
    public String getEndTimestamp() {
1521
        return endTimestamp;
1522
    }
1523
 
1524
    public void setEndTimestamp(String endTimestamp) {
1525
        this.endTimestamp = endTimestamp;
1526
    }
3405 mandeep.dh 1527
 
1528
    public String getUserId() {
1529
        return userId;
1530
    }
1531
 
1532
    public void setUserId(String userId) {
1533
        this.userId = userId;
1534
    }
1535
 
1536
    public String getId() {
1537
        return id;
1538
    }
1539
 
1540
    public void setId(String id) {
1541
        this.id = id;
1542
    }
1543
 
1544
    public String getActivityDescription() {
1545
        return activityDescription;
1546
    }
1547
 
1548
    public void setActivityDescription(String activityDescription) {
1549
        this.activityDescription = activityDescription;
1550
    }
1551
 
1552
    public String getStatus() {
1553
        return status;
1554
    }
1555
 
1556
    public void setStatus(String status) {
1557
        this.status = status;
1558
    }
1559
 
1560
    public String getActivityType() {
1561
        return activityType;
1562
    }
1563
 
1564
    public void setActivityType(String activityType) {
1565
        this.activityType = activityType;
1566
    }
1567
 
1568
    public Ticket getTicket() {
1569
        return ticket;
1570
    }
1571
 
1572
    public void setTicket(Ticket ticket) {
1573
        this.ticket = ticket;
1574
    }
1575
 
1576
    public List<Activity> getActivities() {
1577
        return activities;
1578
    }
1579
 
1580
    public void setActivities(List<Activity> activities) {
1581
        this.activities = activities;
1582
    }
1583
 
1584
    public String getSubject() {
1585
        return subject;
1586
    }
1587
 
1588
    public void setSubject(String subject) {
1589
        this.subject = subject;
1590
    }
1591
 
1592
    public String getBody() {
1593
        return body;
1594
    }
1595
 
1596
    public void setBody(String body) {
1597
        this.body = body;
1598
    }
1599
 
1600
    public String getCustomerName() {
1601
        return customerName;
1602
    }
1603
 
1604
    public void setCustomerName(String customerName) {
1605
        this.customerName = customerName;
1606
    }
1607
 
1608
    public String getCustomerMobileNumber() {
1609
        return customerMobileNumber;
1610
    }
1611
 
1612
    public void setCustomerMobileNumber(String customerMobileNumber) {
1613
        this.customerMobileNumber = customerMobileNumber;
1614
    }
3546 mandeep.dh 1615
 
1616
    public User getUser() {
1617
        return user;
1618
    }
1619
 
1620
    public void setUser(User user) {
1621
        this.user = user;
1622
    }
1623
 
1624
    public String getOrderStatus() {
1625
        return orderStatus;
1626
    }
1627
 
1628
    public void setOrderStatus(String orderStatus) {
1629
        this.orderStatus = orderStatus;
1630
    }
1631
 
1632
    public List<Order> getOrders() {
1633
        return orders;
1634
    }
1635
 
1636
    public void setOrders(List<Order> orders) {
1637
        this.orders = orders;
1638
    }
4020 mandeep.dh 1639
 
1640
    public String getEscalate() {
1641
        return escalate;
1642
    }
1643
 
1644
    public void setEscalate(String escalate) {
1645
        this.escalate = escalate;
1646
    }
4241 anupam.sin 1647
 
1648
    public String getCancelReason() {
1649
        return cancelReason;
1650
    }
1651
 
1652
    public void setCancelReason(String cancelReason) {
1653
        this.cancelReason = cancelReason;
1654
    }
4267 anupam.sin 1655
 
1656
    public List<Payment> getPayments() {
1657
        return payments;
1658
    }
1659
 
1660
    public void setPayments(List<Payment> payments) {
1661
        this.payments = payments;
1662
    }
1663
 
1664
    public String getTransactionId() {
1665
        return transactionId;
1666
    }
1667
 
1668
    public void setTransactionId(String transactionId) {
1669
        this.transactionId = transactionId;
1670
    }
4438 anupam.sin 1671
 
1672
    public String getPaymentId() {
1673
        return paymentId;
1674
    }
1675
 
1676
    public void setPaymentId(String paymentId) {
1677
        this.paymentId = paymentId;
1678
    }
4490 anupam.sin 1679
 
1680
    public HashMap<String, String> getAllAttachmentsForTicket() {
1681
        return allAttachmentsForTicket;
1682
    }
1683
 
1684
    public void setAllAttachmentsForTicket(HashMap<String, String> allAttachmentsForTicket) {
1685
        this.allAttachmentsForTicket = allAttachmentsForTicket;
1686
    }
5791 anupam.sin 1687
 
1688
    public String getPickupExtension() {
1689
        return pickupExtension;
1690
    }
1691
 
1692
    public void setPickupExtension(String pickupExtension) {
1693
        this.pickupExtension = pickupExtension;
1694
    }
5909 amar.kumar 1695
 
1696
	public Map<String, Long> getTicketCategorycountMap() {
1697
		return ticketCategorycountMap;
1698
	}
1699
 
1700
	public void setTicketCategorycountMap(
1701
			Map<String, Long> ticketCategorycountMap) {
1702
		this.ticketCategorycountMap = ticketCategorycountMap;
1703
	}
7645 anupam.sin 1704
 
1705
    public String getPremises() {
1706
        return premises;
1707
    }
1708
 
1709
    public void setPremises(String premises) {
1710
        this.premises = premises;
1711
    }
1712
 
1713
    public String getClosureType() {
1714
        return closureType;
1715
    }
1716
 
1717
    public void setClosureType(String closureType) {
1718
        this.closureType = closureType;
1719
    }
18341 amit.gupta 1720
 
1721
    public Map<Long, Order> getTransactions() {
1722
		return transactions;
1723
	}
1724
 
1725
	public void setTransactions(Map<Long, Order> transactions) {
1726
		this.transactions = transactions;
1727
	}
1728
 
18342 amit.gupta 1729
	public Map<Long, Long> getTransactionShipping() {
18341 amit.gupta 1730
		return transactionShipping;
1731
	}
1732
 
18342 amit.gupta 1733
	public void setTransactionShipping(Map<Long, Long> transactionShipping) {
18341 amit.gupta 1734
		this.transactionShipping = transactionShipping;
1735
	}
1736
 
18342 amit.gupta 1737
	public Map<Long, Long> getTransactionTotal() {
18341 amit.gupta 1738
		return transactionTotal;
1739
	}
1740
 
18342 amit.gupta 1741
	public void setTransactionTotal(Map<Long, Long> transactionTotal) {
18341 amit.gupta 1742
		this.transactionTotal = transactionTotal;
1743
	}
3137 mandeep.dh 1744
}