Subversion Repositories SmartDukaan

Rev

Rev 4681 | Rev 4689 | 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;
3546 mandeep.dh 14
import in.shop2020.model.v1.order.LineItem;
15
import in.shop2020.model.v1.order.Order;
16
import in.shop2020.model.v1.order.OrderStatus;
4267 anupam.sin 17
import in.shop2020.model.v1.order.Transaction;
3546 mandeep.dh 18
import in.shop2020.model.v1.order.TransactionServiceException;
4267 anupam.sin 19
import in.shop2020.model.v1.order.TransactionStatus;
3137 mandeep.dh 20
import in.shop2020.model.v1.user.User;
21
import in.shop2020.model.v1.user.UserContextException;
3578 mandeep.dh 22
import in.shop2020.payments.Payment;
23
import in.shop2020.payments.PaymentException;
24
import in.shop2020.payments.PaymentStatus;
3390 mandeep.dh 25
import in.shop2020.serving.auth.CRMAuthorizingRealm;
26
import in.shop2020.thrift.clients.CRMClient;
3405 mandeep.dh 27
import in.shop2020.thrift.clients.HelperClient;
3578 mandeep.dh 28
import in.shop2020.thrift.clients.PaymentClient;
3546 mandeep.dh 29
import in.shop2020.thrift.clients.TransactionClient;
3390 mandeep.dh 30
import in.shop2020.thrift.clients.UserClient;
3405 mandeep.dh 31
import in.shop2020.util.CRMConstants;
4020 mandeep.dh 32
import in.shop2020.util.CRMConstants.EscalationMatrix;
4241 anupam.sin 33
import in.shop2020.util.CRMConstants.CODCancelMatrix;
3405 mandeep.dh 34
import in.shop2020.utils.HelperService.Client;
35
import in.shop2020.utils.HelperServiceException;
3546 mandeep.dh 36
import in.shop2020.utils.ModelUtils;
3137 mandeep.dh 37
 
3397 mandeep.dh 38
import java.text.ParseException;
3137 mandeep.dh 39
import java.util.ArrayList;
3578 mandeep.dh 40
import java.util.Calendar;
3390 mandeep.dh 41
import java.util.Collections;
3405 mandeep.dh 42
import java.util.Date;
4490 anupam.sin 43
import java.util.HashMap;
3137 mandeep.dh 44
import java.util.List;
45
 
4256 mandeep.dh 46
import net.htmlparser.jericho.Source;
47
 
3405 mandeep.dh 48
import org.apache.shiro.SecurityUtils;
3137 mandeep.dh 49
import org.apache.thrift.TException;
3546 mandeep.dh 50
import org.apache.thrift.transport.TTransportException;
3137 mandeep.dh 51
 
52
/**
53
 * @author mandeep
54
 * 
55
 */
56
public class TicketsController extends BaseController {
57
 
58
    /**
59
     * 
60
     */
61
    private static final long serialVersionUID = 1L;
62
 
63
    List<Ticket>              tickets          = new ArrayList<Ticket>();
3405 mandeep.dh 64
    private String            customerEmailId;
3339 mandeep.dh 65
    private String            description;
66
    private String            assigneeEmailId;
67
    private String            priority;
68
    private String            category;
69
    private String            orderId;
3397 mandeep.dh 70
    private String[]          agentIds;
71
    private String            startTimestamp;
72
    private String            endTimestamp;
3137 mandeep.dh 73
 
3405 mandeep.dh 74
    private String            userId;
75
    private String            id;
76
    private String            activityDescription;
77
    private String            status;
78
    private String            activityType;
79
    private Ticket            ticket;
80
    private List<Activity>    activities;
81
    private String            subject;
82
    private String            body;
83
    private String            customerName;
84
    private String            customerMobileNumber;
3546 mandeep.dh 85
    private User              user;
86
    private String            orderStatus;
87
    private List<Order>       orders;
4267 anupam.sin 88
    private List<Payment>     payments;
4020 mandeep.dh 89
    private String            escalate;
4241 anupam.sin 90
    private String            cancelReason;
4267 anupam.sin 91
    private String            transactionId;
3405 mandeep.dh 92
 
4438 anupam.sin 93
    private String paymentId;
94
 
4490 anupam.sin 95
    private HashMap<String, String> allAttachmentsForTicket;
96
 
3405 mandeep.dh 97
    public String index() {
98
        try {
99
            if (id != null && !id.isEmpty()) {
100
                SearchFilter searchFilter = new SearchFilter();
101
                crmServiceClient = new CRMClient().getClient();
102
                searchFilter.setTicketId(Long.parseLong(id));
103
                tickets = crmServiceClient.getTickets(searchFilter);
104
            }
105
        } catch (TException e) {
106
            log.error("Error while getting tickets", e);
107
            return EXCEPTION;
108
        }
109
 
110
        return INDEX;
111
    }
112
 
113
    public String edit() {
114
        try {
115
            long ticketId = Long.parseLong(id);
116
            SearchFilter searchFilter = new SearchFilter();
117
            searchFilter.setTicketId(ticketId);
118
            crmServiceClient = new CRMClient().getClient();
119
            ticket = crmServiceClient.getTickets(searchFilter).get(0);
120
            activities = crmServiceClient.getActivities(searchFilter);
4490 anupam.sin 121
            populateAttachments();
3405 mandeep.dh 122
            subject = createSubjectString(ticket);
123
 
124
            if (ticket.isSetCustomerId()) {
125
                userId = String.valueOf(ticket.getCustomerId());
3546 mandeep.dh 126
                userContextServiceClient = new UserClient().getClient();
127
 
128
                try {
129
                    user = userContextServiceClient.getUserById(ticket
130
                            .getCustomerId());
131
                } catch (UserContextException e) {
132
                    log.error("Could not fetch user details", e);
133
                }
3405 mandeep.dh 134
            }
135
 
136
            customerEmailId = ticket.getCustomerEmailId();
4277 anupam.sin 137
 
138
            if (TicketCategory.ORDER_CANCELLATION.equals(ticket.getCategory())) {
139
                log.info("Fetching orders for " + ticket.getCustomerId());
140
                orders = new ArrayList<Order>();
141
                transactionServiceClient = new TransactionClient().getClient();
142
                Order order = transactionServiceClient.getOrder(ticket.getOrderId());
143
                log.info("Processing Order: " + order);
4287 anupam.sin 144
                if(OrderStatus.CANCEL_REQUEST_RECEIVED.equals(order.getStatus())) {
145
                    orders.add(order);
146
                }
4277 anupam.sin 147
            }
3546 mandeep.dh 148
 
149
            if (TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())) {
150
                log.info("Fetching orders for " + ticket.getCustomerId());
151
                orders = new ArrayList<Order>();
152
                transactionServiceClient = new TransactionClient().getClient();
153
                for (Order order : transactionServiceClient
154
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
4663 rajveer 155
                                Collections.singletonList(OrderStatus.COD_VERIFICATION_PENDING))) {
3546 mandeep.dh 156
                    log.info("Processing Order: " + order);
157
                    if (order.isCod()) {
158
                        orders.add(order);
159
                    }
160
                }
161
            }
4490 anupam.sin 162
 
163
            if (TicketCategory.DOA_RECEIVED.equals(ticket.getCategory())) {
164
                log.info("Fetching orders for " + ticket.getCustomerId());
165
                orders = new ArrayList<Order>();
166
                transactionServiceClient = new TransactionClient().getClient();
167
                for (Order order : transactionServiceClient
168
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
169
                                Collections.singletonList(OrderStatus.DOA_REQUEST_RECEIVED))) {
170
                    log.info("Processing Order: " + order);
171
                    if (order != null) {
172
                        orders.add(order);
173
                    }
174
                }
175
            }
176
 
177
            if (TicketCategory.RETURN_FORM.equals(ticket.getCategory())) {
178
                log.info("Fetching orders for " + ticket.getCustomerId());
179
                orders = new ArrayList<Order>();
180
                transactionServiceClient = new TransactionClient().getClient();
181
                for (Order order : transactionServiceClient
182
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
183
                                Collections.singletonList(OrderStatus.RET_REQUEST_RECEIVED))) {
184
                    log.info("Processing Order: " + order);
185
                    if (order != null) {
186
                        orders.add(order);
187
                    }
188
                }
189
            }
3578 mandeep.dh 190
 
4267 anupam.sin 191
            if (TicketCategory.PAYMENT_FLAGGED.equals(ticket.getCategory())) {
192
                log.info("Fetching orders for " + ticket.getCustomerId());
193
                payments = new ArrayList<Payment>();
194
                in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
195
                transactionServiceClient = new TransactionClient().getClient();
196
                for (Transaction transaction : transactionServiceClient
197
                        .getTransactionsForCustomer(ticket.getCustomerId(), 0, 0, TransactionStatus.FLAGGED)) {
198
                    log.info("Processing Transaction: " + transaction);
199
                    for ( Payment payment : paymentClient.getPaymentForTxnId(transaction.getId())) {
200
                        if( payment.getStatus().equals(PaymentStatus.AUTHORIZED)) {
201
                            payments.add(payment);
202
                        }
203
                    }
204
                }
205
            }
206
 
3578 mandeep.dh 207
            if (TicketCategory.FAILED_PAYMENTS.equals(ticket.getCategory())) {
208
                log.info("Fetching orders for " + ticket.getCustomerId());
209
                orders = new ArrayList<Order>();
210
                in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
211
 
212
                long failedTransactionId = -1;
213
                long lastfailedTransactionTimestamp = -1;
214
                for (Payment payment : paymentClient.getPaymentsForUser(ticket.getCustomerId(), 0, getTomorrow().getTime(), PaymentStatus.FAILED, 0)) {
215
                    if (payment.getErrorTimestamp() > lastfailedTransactionTimestamp) {
216
                        failedTransactionId = payment.getMerchantTxnId();
217
                    }
218
                }
219
 
220
                transactionServiceClient = new TransactionClient().getClient();
221
                orders.addAll(transactionServiceClient.getOrdersForTransaction(failedTransactionId, ticket.getCustomerId()));
222
            }
4008 mandeep.dh 223
 
224
            if (TicketCategory.DELAYED_DELIVERY.equals(ticket.getCategory())) {
225
                log.info("Fetching orders for " + ticket.getCustomerId());
226
                orders = new ArrayList<Order>();
227
                transactionServiceClient = new TransactionClient().getClient();
228
 
229
                for (Order order : transactionServiceClient.getOrdersForCustomer(ticket.getCustomerId(), 0, 0, null)) {
230
                    if (order.getExpected_delivery_time() > order.getPromised_delivery_time() && order.getExpected_delivery_time() > new Date().getTime()) {
231
                        orders.add(order);
232
                    }
233
                }
234
            }
3405 mandeep.dh 235
        } catch (TException e) {
3546 mandeep.dh 236
            log.error("Error loading edit page", e);
237
        } catch (NumberFormatException e) {
238
            log.error("Error parsing orderId", e);
239
        } catch (TransactionServiceException e) {
240
            log.error("Error fetching orders for " + ticket.getCustomerId(), e);
3578 mandeep.dh 241
        } catch (PaymentException e) {
242
            log.error("Error fetching payments for " + ticket.getCustomerId(), e);
3405 mandeep.dh 243
        }
244
 
245
        return EDIT;
246
    }
247
 
4490 anupam.sin 248
    private void populateAttachments() {
249
        allAttachmentsForTicket = new HashMap<String, String>();
250
        for (Activity activity : activities) {
251
            log.info("" + activity.getId());
252
            String attachment = activity.getAttachments();
253
            if (attachment != null && !attachment.isEmpty()) {
254
                log.info("" + attachment);
255
                String [] attachmentList = attachment.split(";");
256
                for (String attachmentName : attachmentList) {
257
                    if (attachmentName != null && !attachmentName.isEmpty()) {
258
                        log.info("" + attachmentName);
259
                        allAttachmentsForTicket.put(activity.getId() + "-" + attachmentName, attachmentName);
260
                    }
261
                }
262
            }
263
        }
264
    }
265
 
266
    public static void main(String[] args) {
267
        TicketsController tc = new TicketsController();
268
        Integer i = new Integer(14215);
269
        tc.id = i.toString();
270
        tc.populateAttachments();
271
    }
272
 
3405 mandeep.dh 273
    private String createSubjectString(Ticket ticket) {
274
        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId()
275
                + " " + ticket.getCategory().name();
276
    }
277
 
3578 mandeep.dh 278
    private Date getTomorrow() {
279
        Calendar calendar = Calendar.getInstance();
280
        calendar.setTime(new Date());
281
        calendar.add(Calendar.DAY_OF_MONTH, 1);
282
        return calendar.getTime();
283
    }
284
 
3339 mandeep.dh 285
    public String create() {
286
        try {
3546 mandeep.dh 287
            long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId)
288
                    .getId();
3339 mandeep.dh 289
            Ticket ticket = new Ticket();
290
            ticket.setDescription(description);
291
            ticket.setCreatorId(creatorId);
292
            ticket.setStatus(TicketStatus.OPEN);
293
            ticket.setPriority(TicketPriority.valueOf(priority));
294
            ticket.setCategory(TicketCategory.valueOf(category));
295
 
296
            Activity activity = new Activity();
297
            activity.setDescription("Creating Ticket");
298
            activity.setType(ActivityType.OTHER);
299
            activity.setTicketPriority(TicketPriority.valueOf(priority));
300
            activity.setTicketStatus(TicketStatus.OPEN);
301
            activity.setCreatorId(creatorId);
302
            activity.setTicketCategory(TicketCategory.valueOf(category));
303
            activity.setTicketDescription(description);
304
 
305
            if (orderId != null && !orderId.isEmpty()) {
306
                ticket.setOrderId(Long.parseLong(orderId));
307
            }
4490 anupam.sin 308
 
309
            if (TicketCategory.valueOf(category) == TicketCategory.DOA_RECEIVED) {
310
                transactionServiceClient = new TransactionClient().getClient();
311
                if (!transactionServiceClient.markOrderDoaRequestReceived(Long.parseLong(orderId))) {
312
                    throw new Exception("Order cannot be marked as DOA Received");
313
                }
314
                log.info("" + userId);
315
 
316
                Order order = transactionServiceClient.getOrder(Long.parseLong(orderId));
317
                log.info("In order table id is : " + order.getCustomer_id());
318
                if (userId == null || userId.isEmpty() || order.getCustomer_id() != Long.parseLong(userId)) {
319
                    throw new Exception("This order is not associated with this user Id");
320
                }
321
            }
322
 
323
            if (TicketCategory.valueOf(category) == TicketCategory.RETURN_FORM) {
324
                transactionServiceClient = new TransactionClient().getClient();
325
                if (!transactionServiceClient.markOrderReturnRequestReceived(Long.parseLong(orderId))) {
326
                    throw new Exception("Order cannot be marked as Return Requested");
327
                }
328
                log.info("" + userId);
329
 
330
                Order order = transactionServiceClient.getOrder(Long.parseLong(orderId));
331
                log.info("In order table id is : " + order.getCustomer_id());
332
                if (userId == null || userId.isEmpty() || order.getCustomer_id() != Long.parseLong(userId)) {
333
                    throw new Exception("This order is not associated with this user Id");
334
                }
335
            }
4681 amar.kumar 336
            if(body!=null && !body.isEmpty()){
337
            	String plainTextbody = new Source(body).getTextExtractor().toString();
338
            	ticket.setDescription(description + " : " + plainTextbody);
339
            }
4490 anupam.sin 340
 
3405 mandeep.dh 341
            if (userId != null && !userId.isEmpty()) {
342
                ticket.setCustomerId(Long.parseLong(userId));
343
                activity.setCustomerId(Long.parseLong(userId));
3546 mandeep.dh 344
            } else {
3390 mandeep.dh 345
                User user = null;
346
                userContextServiceClient = new UserClient().getClient();
347
                try {
3405 mandeep.dh 348
                    if (customerName != null && !customerName.isEmpty()) {
349
                        ticket.setCustomerName(customerName);
350
                        activity.setCustomerName(customerName);
351
                    }
352
 
353
                    if (customerEmailId != null && !customerEmailId.isEmpty()) {
354
                        ticket.setCustomerEmailId(customerEmailId);
355
                        activity.setCustomerEmailId(customerEmailId);
3546 mandeep.dh 356
                        user = userContextServiceClient
357
                                .getUserByEmail(customerEmailId);
3405 mandeep.dh 358
                    }
359
 
3546 mandeep.dh 360
                    if ((user == null || user.getUserId() == -1)
361
                            && customerMobileNumber != null
362
                            && !customerMobileNumber.isEmpty()) {
3405 mandeep.dh 363
                        ticket.setCustomerMobileNumber(customerMobileNumber);
364
                        activity.setCustomerMobileNumber(customerMobileNumber);
3546 mandeep.dh 365
                        user = userContextServiceClient
366
                                .getUserByMobileNumber(Long
367
                                        .parseLong(customerMobileNumber));
3405 mandeep.dh 368
                    }
3390 mandeep.dh 369
                } catch (UserContextException e) {
3546 mandeep.dh 370
                    log.error("Could not fetch user for: " + customerEmailId
371
                            + " " + customerMobileNumber + " " + customerName,
372
                            e);
3390 mandeep.dh 373
                }
3546 mandeep.dh 374
 
3390 mandeep.dh 375
                if (user != null && user.getUserId() != -1) {
376
                    ticket.setCustomerId(user.getUserId());
377
                    activity.setCustomerId(user.getUserId());
378
                }
3339 mandeep.dh 379
            }
380
 
381
            // handling null values appropriately
382
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
3546 mandeep.dh 383
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
384
                        .getId();
3339 mandeep.dh 385
                ticket.setAssigneeId(assigneeId);
386
                activity.setTicketAssigneeId(assigneeId);
387
            }
388
 
3546 mandeep.dh 389
            crmServiceClient = new CRMClient().getClient();
390
            id = String
391
                    .valueOf(crmServiceClient.insertTicket(ticket, activity));
3339 mandeep.dh 392
        } catch (TException e) {
393
            log.error("Error while creating ticket", e);
394
            return EXCEPTION;
4490 anupam.sin 395
        } catch (NumberFormatException e) {
396
            log.error("Error while parsing Order Id", e);
397
            return EXCEPTION;
398
        } catch (TransactionServiceException e) {
399
            log.error("Error while updating order status", e);
400
            return EXCEPTION;
401
        } catch (Exception e) {
402
            log.error(e.getMessage());
403
            return EXCEPTION;
3339 mandeep.dh 404
        }
405
 
3405 mandeep.dh 406
        return index();
3339 mandeep.dh 407
    }
408
 
3405 mandeep.dh 409
    public boolean isAssigneeEditable() {
410
        return SecurityUtils.getSubject().hasRole("TeamLead");
411
    }
412
 
3397 mandeep.dh 413
    public String searchTickets() throws ParseException {
3137 mandeep.dh 414
        try {
3397 mandeep.dh 415
            SearchFilter searchFilter = new SearchFilter();
3405 mandeep.dh 416
            if (userId != null && !userId.isEmpty()) {
417
                searchFilter.setCustomerId(Long.parseLong(userId));
418
            }
419
 
3397 mandeep.dh 420
            if (agentIds != null && agentIds.length != 0) {
421
                searchFilter.setTicketAssigneeIds(new ArrayList<Long>());
422
                for (String agentId : agentIds) {
3546 mandeep.dh 423
                    searchFilter.getTicketAssigneeIds().add(
424
                            CRMAuthorizingRealm.getAgent(agentId).getId());
3397 mandeep.dh 425
                }
426
            }
3137 mandeep.dh 427
 
3397 mandeep.dh 428
            if (startTimestamp != null && !startTimestamp.isEmpty()) {
3546 mandeep.dh 429
                searchFilter.setStartTimestamp(SDF.parse(startTimestamp)
430
                        .getTime());
3397 mandeep.dh 431
            }
432
 
433
            if (endTimestamp != null && !endTimestamp.isEmpty()) {
434
                searchFilter.setEndTimestamp(SDF.parse(endTimestamp).getTime());
435
            }
436
 
3422 mandeep.dh 437
            if (id != null && !id.isEmpty()) {
438
                searchFilter.setTicketId(Long.parseLong(id));
439
            }
440
 
3499 mandeep.dh 441
            if (status != null && !status.isEmpty()) {
3972 mandeep.dh 442
                searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
443
                searchFilter.getTicketStatuses().add(TicketStatus.valueOf(status));
444
                if (TicketStatus.OPEN.name().equals(status)) {
445
                    searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
446
                }
3499 mandeep.dh 447
            }
448
 
449
            if (category != null && !category.isEmpty()) {
3546 mandeep.dh 450
                searchFilter
451
                        .setTicketCategory(TicketCategory.valueOf(category));
3499 mandeep.dh 452
            }
453
 
3546 mandeep.dh 454
            crmServiceClient = new CRMClient().getClient();
3405 mandeep.dh 455
            tickets = crmServiceClient.getTickets(searchFilter);
3137 mandeep.dh 456
        } catch (TException e) {
457
            String errorString = "Error getting tickets for "
458
                    + currentAgentEmailId;
459
            log.error(errorString, e);
460
            addActionError(errorString);
461
        }
462
 
3405 mandeep.dh 463
        return index();
3137 mandeep.dh 464
    }
465
 
466
    public String getUnassignedTickets() {
467
        try {
3546 mandeep.dh 468
            crmServiceClient = new CRMClient().getClient();
3137 mandeep.dh 469
            tickets = crmServiceClient.getUnassignedTickets();
470
        } catch (TException e) {
3339 mandeep.dh 471
            String errorString = "Error getting tickets for "
472
                    + currentAgentEmailId;
3137 mandeep.dh 473
            log.error(errorString, e);
474
            addActionError(errorString);
475
        }
476
 
3405 mandeep.dh 477
        return index();
3137 mandeep.dh 478
    }
479
 
3405 mandeep.dh 480
    public String update() {
481
        try {
482
            long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId)
483
                    .getId();
484
 
3546 mandeep.dh 485
            SearchFilter searchFilter = new SearchFilter();
486
            searchFilter.setTicketId(Long.parseLong(id));
487
            crmServiceClient = new CRMClient().getClient();
488
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3405 mandeep.dh 489
            ticket.setDescription(description);
490
            ticket.setPriority(TicketPriority.valueOf(priority));
491
 
492
            // Update when a ticket is closed!
3578 mandeep.dh 493
            if (TicketStatus.CLOSED.name().equals(status) || TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())) {
3546 mandeep.dh 494
                if (TicketCategory.COD_VERIFICATION.equals(ticket.getCategory())
495
                        && pendingCODOrders(ticket.getCustomerId())) {
496
                    addActionMessage("Cod orders pending for verification. Ticket can not be closed and its category cannot be changed.");
497
                } else {
498
                    ticket.setCategory(TicketCategory.valueOf(category));
499
                    ticket.setStatus(TicketStatus.valueOf(status));
500
                    ticket.setCloseDate(new Date().getTime());
501
                }
3405 mandeep.dh 502
            }
3546 mandeep.dh 503
            else {
504
                ticket.setCategory(TicketCategory.valueOf(category));
3578 mandeep.dh 505
                ticket.setStatus(TicketStatus.valueOf(status));
3546 mandeep.dh 506
            }
3405 mandeep.dh 507
 
508
            if (activityDescription == null || activityDescription.isEmpty()) {
4241 anupam.sin 509
                activityDescription = "Ticket fields updated";
3405 mandeep.dh 510
            }
511
 
512
            Activity activity = new Activity();
513
            activity.setDescription(activityDescription);
514
            activity.setType(ActivityType.valueOf(activityType));
3546 mandeep.dh 515
            activity.setTicketPriority(ticket.getPriority());
516
            activity.setTicketStatus(ticket.getStatus());
3405 mandeep.dh 517
            activity.setCreatorId(creatorId);
3546 mandeep.dh 518
            activity.setTicketCategory(ticket.getCategory());
519
            activity.setTicketDescription(ticket.getDescription());
3405 mandeep.dh 520
 
521
            if (userId != null && !userId.isEmpty()) {
522
                activity.setCustomerId(Long.parseLong(userId));
523
            }
524
 
4035 mandeep.dh 525
            // Handling null values appropriately
526
            if (assigneeEmailId != null && !assigneeEmailId.isEmpty()) {
527
                long assigneeId = CRMAuthorizingRealm.getAgent(assigneeEmailId)
528
                        .getId();
529
                ticket.setAssigneeId(assigneeId);
530
                activity.setTicketAssigneeId(assigneeId);
531
            }
532
 
3405 mandeep.dh 533
            if (ActivityType.SEND_EMAIL_TO_CUSTOMER.equals(activity.getType())) {
534
                log.info("Sending mail");
535
                Client helperClient = new HelperClient().getClient();
536
                activity.setUserEmailId(helperClient.saveUserEmailForSending(
3546 mandeep.dh 537
                        customerEmailId, CRMConstants.CRM_EMAIL_SENDOR,
538
                        subject, body, null, CRMConstants.CRM_EMAIL_TYPE));
3405 mandeep.dh 539
 
4256 mandeep.dh 540
                String plainTextbody = new Source(body).getTextExtractor().toString();
541
 
3405 mandeep.dh 542
                // We change activityType to OTHER when pop up box for email
543
                // closes
544
                activity.setDescription("Subject: " + subject + "\n\n"
4256 mandeep.dh 545
                        + "Body: " + plainTextbody);
4206 mandeep.dh 546
 
547
                String activityDesc = activity.getDescription();
548
                if (activityDesc.length() > CRMConstants.DESCRIPTION_MAX_WIDTH) {
549
                    activityDesc = activityDesc.substring(0, CRMConstants.DESCRIPTION_MAX_WIDTH);
550
                    activityDesc += "\n\nTHIS TEXT IS TRUNCATED. PLEASE VISIT INBOX TO SEE COMPLETE DETAILS.";
551
                }
552
 
553
                activity.setDescription(activityDesc);
3405 mandeep.dh 554
            }
555
 
4020 mandeep.dh 556
            if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
557
                log.info("Sending escalation mail");
558
                EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
559
                List<Integer> escalationReceipients = escalation.getAgentIds();
560
 
561
                String toMailIds = "";
562
                for (Integer agentId : escalationReceipients) {
563
                    toMailIds += CRMAuthorizingRealm.getAgent(agentId).getEmailId() + ";";
4034 mandeep.dh 564
 
565
                    // Setting last agent as assignee
566
                    ticket.setAssigneeId(agentId);
567
                    activity.setTicketAssigneeId(agentId);
4020 mandeep.dh 568
                }
569
 
570
                Client helperClient = new HelperClient().getClient();
571
                String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
572
                String escalationMailBody = createEscalationMailBody(ticket, escalation);
573
 
574
                activity.setUserEmailId(helperClient.saveUserEmailForSending(
575
                        toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
576
                        escalationMailSubject, escalationMailBody,
577
                        null, CRMConstants.CRM_EMAIL_TYPE));
578
 
579
                // We change activityType to OTHER when pop up box for email
580
                // closes
581
                activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
582
                        + "Body: " + escalationMailBody);
583
            }
584
 
3405 mandeep.dh 585
            User user = null;
586
            userContextServiceClient = new UserClient().getClient();
587
            try {
588
                if (customerName != null && !customerName.isEmpty()) {
589
                    ticket.setCustomerName(customerName);
590
                    activity.setCustomerName(customerName);
591
                }
592
 
593
                if (customerEmailId != null && !customerEmailId.isEmpty()) {
594
                    ticket.setCustomerEmailId(customerEmailId);
595
                    activity.setCustomerEmailId(customerEmailId);
3546 mandeep.dh 596
                    user = userContextServiceClient
597
                            .getUserByEmail(customerEmailId);
3405 mandeep.dh 598
                }
599
 
3546 mandeep.dh 600
                if ((user == null || user.getUserId() == -1)
601
                        && customerMobileNumber != null
602
                        && !customerMobileNumber.isEmpty()) {
3405 mandeep.dh 603
                    ticket.setCustomerMobileNumber(customerMobileNumber);
604
                    activity.setCustomerMobileNumber(customerMobileNumber);
3546 mandeep.dh 605
                    user = userContextServiceClient.getUserByMobileNumber(Long
606
                            .parseLong(customerMobileNumber));
3405 mandeep.dh 607
                }
608
            } catch (UserContextException e) {
609
                log.error("Could not fetch user for: " + customerEmailId + " "
610
                        + customerMobileNumber + " " + customerName, e);
611
            }
3546 mandeep.dh 612
 
3405 mandeep.dh 613
            if (user != null && user.getUserId() != -1) {
614
                ticket.setCustomerId(user.getUserId());
615
                activity.setCustomerId(user.getUserId());
616
            }
617
 
618
            crmServiceClient = new CRMClient().getClient();
619
            crmServiceClient.updateTicket(ticket, activity);
620
        } catch (TException e) {
621
            log.error("Error while updating ticket", e);
622
            return EXCEPTION;
623
        } catch (HelperServiceException hse) {
624
            log.error("Error while sending mail", hse);
625
            return EXCEPTION;
626
        }
627
 
628
        return index();
629
    }
630
 
4020 mandeep.dh 631
    private String createEscalationMailBody(Ticket ticket,
632
            EscalationMatrix escalation)
633
    {
634
        return body + "<br />Please visit following URL to check ticket details.<br />" + 
635
            "http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
636
    }
637
 
638
    private String createEscalationMailSubject(Ticket ticket,
639
            EscalationMatrix escalation)
640
    {
641
        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
642
    }
643
 
3546 mandeep.dh 644
    private boolean pendingCODOrders(long customerId) {
645
        try {
646
            log.info("Trying to fetch orders for " + customerId);
647
            transactionServiceClient = new TransactionClient().getClient();
648
            for (Order order : transactionServiceClient.getOrdersForCustomer(
649
                    customerId, 0, 0,
4663 rajveer 650
                    Collections.singletonList(OrderStatus.COD_VERIFICATION_PENDING))) {
3546 mandeep.dh 651
                log.info("Processing order: " + order.getId() + " with COD: " + order.isCod());
652
                if (order.isCod()) {
653
                    log.info("Returning true from pendingCODOrders() for " + customerId);
654
                    return true;
655
                }
656
            }
657
        } catch (TTransportException e) {
658
            log.error("Error while creating thrift client", e);
659
        } catch (TransactionServiceException e) {
660
            log.error("Error fetching orders", e);
661
        } catch (TException e) {
662
            log.error("Error fetching orders", e);
663
        }
664
 
665
        log.info("Returning false from pendingCODOrders() for " + customerId);
666
        return false;
667
    }
668
 
4277 anupam.sin 669
    public String updateOrderStatus() {
670
        long creatorId;
671
        OrderStatus orderStatusEnum = null;
672
        try {
673
            creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
674
 
675
            if(orderStatus.equals("DENY_CANCEL_REQUEST")) {
676
                transactionServiceClient = new TransactionClient().getClient();
677
                transactionServiceClient.markOrderCancellationRequestDenied(Long.parseLong(orderId));
678
            } 
3546 mandeep.dh 679
 
4277 anupam.sin 680
            else {
3546 mandeep.dh 681
 
4277 anupam.sin 682
                orderStatusEnum = OrderStatus.valueOf(orderStatus);
683
                transactionServiceClient = new TransactionClient().getClient();
3578 mandeep.dh 684
 
4277 anupam.sin 685
                if (OrderStatus.SUBMITTED_FOR_PROCESSING.equals(orderStatusEnum)) {
686
                    transactionServiceClient.verifyOrder(Long.parseLong(orderId));
687
                }
4682 rajveer 688
                else if (OrderStatus.COD_VERIFICATION_FAILED.equals(orderStatusEnum)) {
4277 anupam.sin 689
                    transactionServiceClient.refundOrder(Long.parseLong(orderId), currentAgentEmailId, cancelReason);
690
                }
691
                else if (OrderStatus.CANCEL_REQUEST_CONFIRMED.equals(orderStatusEnum)) {
692
                    transactionServiceClient.markOrderCancellationRequestConfirmed(Long.parseLong(orderId));
693
                }
694
                else {
695
                    throw new UnsupportedOperationException("Cannot update status of orderId: " + orderId + " to: " + orderStatus);
696
                }
697
            }
698
 
699
            SearchFilter searchFilter = new SearchFilter();
700
            searchFilter.setTicketId(Long.parseLong(id));
701
            crmServiceClient = new CRMClient().getClient();
702
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3546 mandeep.dh 703
 
4277 anupam.sin 704
            // Inserting activity
705
            Activity activity = new Activity();
706
            activity.setDescription("Status updated for Order Id: " + orderId
707
                    + " to " + orderStatus + ", Reason: " + cancelReason + body);
708
            activity.setType(ActivityType.OTHER);
709
            activity.setTicketPriority(ticket.getPriority());
710
            activity.setTicketStatus(ticket.getStatus());
711
            activity.setCreatorId(creatorId);
712
            activity.setTicketCategory(ticket.getCategory());
713
            activity.setTicketDescription(ticket.getDescription());
714
            activity.setCustomerId(ticket.getCustomerId());
715
            activity.setTicketAssigneeId(ticket.getAssigneeId());
3546 mandeep.dh 716
 
4277 anupam.sin 717
            crmServiceClient = new CRMClient().getClient();
718
            crmServiceClient.updateTicket(ticket, activity);
3546 mandeep.dh 719
 
4277 anupam.sin 720
        } catch (TException e) {
721
            log.info("Thrift exception", e);
722
        } catch (NumberFormatException e) {
723
            log.info("Could not convert to long", e);
724
        } catch (TransactionServiceException e) {
725
            log.info("Transaction client exception", e);
726
        }
727
 
3546 mandeep.dh 728
        return edit();
729
    }
4277 anupam.sin 730
 
3137 mandeep.dh 731
    public User getUser(Long userId) {
732
        User user = null;
733
 
734
        try {
3390 mandeep.dh 735
            userContextServiceClient = new UserClient().getClient();
3137 mandeep.dh 736
            user = userContextServiceClient.getUserById(userId);
737
        } catch (UserContextException e) {
738
            String errorString = "Could not fetch user for " + userId;
739
            log.error(errorString, e);
740
            addActionError(errorString);
741
        } catch (TException e) {
742
            String errorString = "Could not create client";
743
            log.error(errorString, e);
744
            addActionError(errorString);
745
        }
746
 
747
        return user;
748
    }
4267 anupam.sin 749
 
4438 anupam.sin 750
    public String allowPayment() {
751
        try {
752
            log.info("Allowing payment for paymentId = " + paymentId);
753
            transactionServiceClient = new TransactionClient().getClient();
754
            transactionServiceClient.markTransactionAsPaymentFlagRemoved(Long.parseLong(transactionId));
755
            if (id != null && !id.isEmpty()) {
756
                SearchFilter searchFilter = new SearchFilter();
757
                crmServiceClient = new CRMClient().getClient();
758
                searchFilter.setTicketId(Long.parseLong(id));
759
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
760
                // Inserting activity
761
                if(ticket != null) {
762
                    Activity activity = new Activity();
763
                    activity.setDescription("Flagged Payment allowed");
764
                    activity.setType(ActivityType.OTHER);
765
                    activity.setTicketPriority(ticket.getPriority());
766
                    activity.setTicketStatus(ticket.getStatus());
767
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
768
                    activity.setTicketCategory(ticket.getCategory());
769
                    activity.setTicketDescription(ticket.getDescription());
770
                    activity.setCustomerId(ticket.getCustomerId());
771
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
772
 
773
                    crmServiceClient = new CRMClient().getClient();
774
                    crmServiceClient.updateTicket(ticket, activity);
775
                }
776
            }
777
 
778
        } catch (TException e) {
779
            log.error("Error while getting tickets", e);
780
            return EXCEPTION;
781
        } catch (NumberFormatException e) {
782
            log.error("Invalid ticket Id", e);
783
            return EXCEPTION;
784
        } catch (TransactionServiceException e) {
785
            log.error("Error while marking transactions as Flag removed", e);
786
            return EXCEPTION;
787
        }
4267 anupam.sin 788
        return edit();
789
    }
790
 
4490 anupam.sin 791
    public String blockPayment() {
4438 anupam.sin 792
        try {
793
            log.info("Blocking payment for paymentId = " + paymentId);
794
            transactionServiceClient = new TransactionClient().getClient();
795
            transactionServiceClient.refundTransaction(Long.parseLong(transactionId), currentAgentEmailId, "FLAGGED_PAYMENT_CANCELLED");
796
            if (id != null && !id.isEmpty()) {
797
                SearchFilter searchFilter = new SearchFilter();
798
                crmServiceClient = new CRMClient().getClient();
799
                searchFilter.setTicketId(Long.parseLong(id));
800
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
801
                // Inserting activity
802
                if(ticket != null) {
803
                    Activity activity = new Activity();
804
                    activity.setDescription("Flagged Payment allowed");
805
                    activity.setType(ActivityType.OTHER);
806
                    activity.setTicketPriority(ticket.getPriority());
807
                    activity.setTicketStatus(ticket.getStatus());
808
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
809
                    activity.setTicketCategory(ticket.getCategory());
810
                    activity.setTicketDescription(ticket.getDescription());
811
                    activity.setCustomerId(ticket.getCustomerId());
812
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
813
 
814
                    crmServiceClient = new CRMClient().getClient();
815
                    crmServiceClient.updateTicket(ticket, activity);
816
                }
817
            }
818
 
819
        } catch (TException e) {
820
            log.error("Error while getting tickets", e);
821
            return EXCEPTION;
822
        } catch (NumberFormatException e) {
823
            log.error("Invalid ticket Id", e);
824
            return EXCEPTION;
825
        } catch (TransactionServiceException e) {
826
            log.error("Error while allowing flagged payment", e);
827
            return EXCEPTION;
828
        }
4267 anupam.sin 829
        return edit();
830
    }
4490 anupam.sin 831
 
832
    public String authorizeReturn() {
833
        try {
834
            log.info("Authorizing OrderId =" + orderId);
835
            transactionServiceClient = new TransactionClient().getClient();
836
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), true);
837
            if (id != null && !id.isEmpty()) {
838
                SearchFilter searchFilter = new SearchFilter();
839
                crmServiceClient = new CRMClient().getClient();
840
                searchFilter.setTicketId(Long.parseLong(id));
841
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
842
                // Inserting activity
843
                if(ticket != null) {
844
                    Activity activity = new Activity();
845
                    activity.setDescription("Return Authorized");
846
                    activity.setType(ActivityType.OTHER);
847
                    activity.setTicketPriority(ticket.getPriority());
848
                    activity.setTicketStatus(ticket.getStatus());
849
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
850
                    activity.setTicketCategory(ticket.getCategory());
851
                    activity.setTicketDescription(ticket.getDescription());
852
                    activity.setCustomerId(ticket.getCustomerId());
853
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
3137 mandeep.dh 854
 
4490 anupam.sin 855
                    crmServiceClient = new CRMClient().getClient();
856
                    crmServiceClient.updateTicket(ticket, activity);
857
                }
858
            }
859
 
860
        } catch (TException e) {
861
            log.error("Error while getting tickets", e);
862
            return EXCEPTION;
863
        } catch (NumberFormatException e) {
864
            log.error("Invalid ticket Id", e);
865
            return EXCEPTION;
866
        } catch (TransactionServiceException e) {
867
            log.error("Error while authorizing Return", e);
868
            return EXCEPTION;
869
        }
870
        return edit();
871
    }
872
 
873
    public String denyReturn() {
874
        try {
875
            log.info("Denying OrderId =" + orderId);
876
            transactionServiceClient = new TransactionClient().getClient();
877
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), false);
878
            if (id != null && !id.isEmpty()) {
879
                SearchFilter searchFilter = new SearchFilter();
880
                crmServiceClient = new CRMClient().getClient();
881
                searchFilter.setTicketId(Long.parseLong(id));
882
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
883
                // Inserting activity
884
                if(ticket != null) {
885
                    Activity activity = new Activity();
886
                    activity.setDescription("Return Denied");
887
                    activity.setType(ActivityType.OTHER);
888
                    activity.setTicketPriority(ticket.getPriority());
889
                    activity.setTicketStatus(ticket.getStatus());
890
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
891
                    activity.setTicketCategory(ticket.getCategory());
892
                    activity.setTicketDescription(ticket.getDescription());
893
                    activity.setCustomerId(ticket.getCustomerId());
894
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
895
 
896
                    crmServiceClient = new CRMClient().getClient();
897
                    crmServiceClient.updateTicket(ticket, activity);
898
                }
899
            }
900
 
901
        } catch (TException e) {
902
            log.error("Error while getting tickets", e);
903
            return EXCEPTION;
904
        } catch (NumberFormatException e) {
905
            log.error("Invalid ticket Id", e);
906
            return EXCEPTION;
907
        } catch (TransactionServiceException e) {
908
            log.error("Error while denying Return", e);
909
            return EXCEPTION;
910
        }
911
        return edit();
912
    }
913
 
914
    public String authorizeDOA() {
915
        try {
916
            log.info("Authorizing OrderId =" + orderId);
917
            transactionServiceClient = new TransactionClient().getClient();
918
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), true);
919
            if (id != null && !id.isEmpty()) {
920
                SearchFilter searchFilter = new SearchFilter();
921
                crmServiceClient = new CRMClient().getClient();
922
                searchFilter.setTicketId(Long.parseLong(id));
923
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
924
                // Inserting activity
925
                if(ticket != null) {
926
                    Activity activity = new Activity();
927
                    activity.setDescription("DOA Authorized");
928
                    activity.setType(ActivityType.OTHER);
929
                    activity.setTicketPriority(ticket.getPriority());
930
                    activity.setTicketStatus(ticket.getStatus());
931
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
932
                    activity.setTicketCategory(ticket.getCategory());
933
                    activity.setTicketDescription(ticket.getDescription());
934
                    activity.setCustomerId(ticket.getCustomerId());
935
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
936
 
937
                    crmServiceClient = new CRMClient().getClient();
938
                    crmServiceClient.updateTicket(ticket, activity);
939
                }
940
            }
941
 
942
        } catch (TException e) {
943
            log.error("Error while getting tickets", e);
944
            return EXCEPTION;
945
        } catch (NumberFormatException e) {
946
            log.error("Invalid ticket Id", e);
947
            return EXCEPTION;
948
        } catch (TransactionServiceException e) {
949
            log.error("Error while authorizing DOA", e);
950
            return EXCEPTION;
951
        }
952
        return edit();
953
    }
954
 
955
    public String denyDOA() {
956
        try {
957
            log.info("Denying OrderId =" + orderId);
958
            transactionServiceClient = new TransactionClient().getClient();
959
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), false);
960
            if (id != null && !id.isEmpty()) {
961
                SearchFilter searchFilter = new SearchFilter();
962
                crmServiceClient = new CRMClient().getClient();
963
                searchFilter.setTicketId(Long.parseLong(id));
964
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
965
                // Inserting activity
966
                if(ticket != null) {
967
                    Activity activity = new Activity();
968
                    activity.setDescription("DOA Denied");
969
                    activity.setType(ActivityType.OTHER);
970
                    activity.setTicketPriority(ticket.getPriority());
971
                    activity.setTicketStatus(ticket.getStatus());
972
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
973
                    activity.setTicketCategory(ticket.getCategory());
974
                    activity.setTicketDescription(ticket.getDescription());
975
                    activity.setCustomerId(ticket.getCustomerId());
976
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
977
 
978
                    crmServiceClient = new CRMClient().getClient();
979
                    crmServiceClient.updateTicket(ticket, activity);
980
                }
981
            }
982
 
983
        } catch (TException e) {
984
            log.error("Error while getting tickets", e);
985
            return EXCEPTION;
986
        } catch (NumberFormatException e) {
987
            log.error("Invalid ticket Id", e);
988
            return EXCEPTION;
989
        } catch (TransactionServiceException e) {
990
            log.error("Error while denying DOA", e);
991
            return EXCEPTION;
992
        }
993
        return edit();
994
    }
995
 
4020 mandeep.dh 996
    public EscalationMatrix[] getEscalationMatrix () {
997
        return CRMConstants.EscalationMatrix.values();
998
    }
999
 
4241 anupam.sin 1000
    public CODCancelMatrix[] getCODCancelMatrix () {
1001
        return CRMConstants.CODCancelMatrix.values();
1002
    }
1003
 
3546 mandeep.dh 1004
    public String getAddress(Order order) {
1005
        return ModelUtils.extractAddressFromOrder(order);
1006
    }
1007
 
1008
    public String getProductName(LineItem lineItem) {
4008 mandeep.dh 1009
        return ModelUtils.extractProductNameFromLineItem(lineItem) + " " + lineItem.getColor();
3546 mandeep.dh 1010
    }
1011
 
3405 mandeep.dh 1012
    public ActivityType[] getActivityTypes() {
1013
        return ActivityType.values();
1014
    }
1015
 
1016
    public TicketStatus[] getTicketStatuses() {
1017
        return TicketStatus.values();
1018
    }
1019
 
3390 mandeep.dh 1020
    public Agent getAgent(long agentId) throws TException {
1021
        return CRMAuthorizingRealm.getAgent(agentId);
3137 mandeep.dh 1022
    }
1023
 
3339 mandeep.dh 1024
    public List<Agent> getAllAgents() {
3390 mandeep.dh 1025
        return CRMAuthorizingRealm.getAgents();
3339 mandeep.dh 1026
    }
1027
 
1028
    public TicketCategory[] getTicketCategories() {
1029
        return TicketCategory.values();
1030
    }
1031
 
1032
    public TicketPriority[] getTicketPriorities() {
1033
        return TicketPriority.values();
1034
    }
1035
 
3137 mandeep.dh 1036
    public List<Ticket> getTickets() {
1037
        return tickets;
1038
    }
1039
 
1040
    public void setTickets(List<Ticket> tickets) {
1041
        this.tickets = tickets;
1042
    }
3339 mandeep.dh 1043
 
3405 mandeep.dh 1044
    public String getCustomerEmailId() {
1045
        return customerEmailId;
3339 mandeep.dh 1046
    }
1047
 
3405 mandeep.dh 1048
    public void setCustomerEmailId(String customerEmailId) {
1049
        this.customerEmailId = customerEmailId;
3339 mandeep.dh 1050
    }
1051
 
1052
    public String getDescription() {
1053
        return description;
1054
    }
1055
 
1056
    public void setDescription(String description) {
1057
        this.description = description;
1058
    }
1059
 
1060
    public String getAssigneeEmailId() {
1061
        return assigneeEmailId;
1062
    }
1063
 
1064
    public void setAssigneeEmailId(String assigneeEmailId) {
1065
        this.assigneeEmailId = assigneeEmailId;
1066
    }
1067
 
1068
    public String getPriority() {
1069
        return priority;
1070
    }
1071
 
1072
    public void setPriority(String priority) {
1073
        this.priority = priority;
1074
    }
1075
 
1076
    public String getCategory() {
1077
        return category;
1078
    }
1079
 
1080
    public void setCategory(String category) {
1081
        this.category = category;
1082
    }
1083
 
1084
    public String getOrderId() {
1085
        return orderId;
1086
    }
1087
 
1088
    public void setOrderId(String orderId) {
1089
        this.orderId = orderId;
1090
    }
3397 mandeep.dh 1091
 
1092
    public String[] getAgentIds() {
1093
        return agentIds;
1094
    }
1095
 
1096
    public void setAgentIds(String[] agentIds) {
1097
        this.agentIds = agentIds;
1098
    }
1099
 
1100
    public String getStartTimestamp() {
1101
        return startTimestamp;
1102
    }
1103
 
1104
    public void setStartTimestamp(String startTimestamp) {
1105
        this.startTimestamp = startTimestamp;
1106
    }
1107
 
1108
    public String getEndTimestamp() {
1109
        return endTimestamp;
1110
    }
1111
 
1112
    public void setEndTimestamp(String endTimestamp) {
1113
        this.endTimestamp = endTimestamp;
1114
    }
3405 mandeep.dh 1115
 
1116
    public String getUserId() {
1117
        return userId;
1118
    }
1119
 
1120
    public void setUserId(String userId) {
1121
        this.userId = userId;
1122
    }
1123
 
1124
    public String getId() {
1125
        return id;
1126
    }
1127
 
1128
    public void setId(String id) {
1129
        this.id = id;
1130
    }
1131
 
1132
    public String getActivityDescription() {
1133
        return activityDescription;
1134
    }
1135
 
1136
    public void setActivityDescription(String activityDescription) {
1137
        this.activityDescription = activityDescription;
1138
    }
1139
 
1140
    public String getStatus() {
1141
        return status;
1142
    }
1143
 
1144
    public void setStatus(String status) {
1145
        this.status = status;
1146
    }
1147
 
1148
    public String getActivityType() {
1149
        return activityType;
1150
    }
1151
 
1152
    public void setActivityType(String activityType) {
1153
        this.activityType = activityType;
1154
    }
1155
 
1156
    public Ticket getTicket() {
1157
        return ticket;
1158
    }
1159
 
1160
    public void setTicket(Ticket ticket) {
1161
        this.ticket = ticket;
1162
    }
1163
 
1164
    public List<Activity> getActivities() {
1165
        return activities;
1166
    }
1167
 
1168
    public void setActivities(List<Activity> activities) {
1169
        this.activities = activities;
1170
    }
1171
 
1172
    public String getSubject() {
1173
        return subject;
1174
    }
1175
 
1176
    public void setSubject(String subject) {
1177
        this.subject = subject;
1178
    }
1179
 
1180
    public String getBody() {
1181
        return body;
1182
    }
1183
 
1184
    public void setBody(String body) {
1185
        this.body = body;
1186
    }
1187
 
1188
    public String getCustomerName() {
1189
        return customerName;
1190
    }
1191
 
1192
    public void setCustomerName(String customerName) {
1193
        this.customerName = customerName;
1194
    }
1195
 
1196
    public String getCustomerMobileNumber() {
1197
        return customerMobileNumber;
1198
    }
1199
 
1200
    public void setCustomerMobileNumber(String customerMobileNumber) {
1201
        this.customerMobileNumber = customerMobileNumber;
1202
    }
3546 mandeep.dh 1203
 
1204
    public User getUser() {
1205
        return user;
1206
    }
1207
 
1208
    public void setUser(User user) {
1209
        this.user = user;
1210
    }
1211
 
1212
    public String getOrderStatus() {
1213
        return orderStatus;
1214
    }
1215
 
1216
    public void setOrderStatus(String orderStatus) {
1217
        this.orderStatus = orderStatus;
1218
    }
1219
 
1220
    public List<Order> getOrders() {
1221
        return orders;
1222
    }
1223
 
1224
    public void setOrders(List<Order> orders) {
1225
        this.orders = orders;
1226
    }
4020 mandeep.dh 1227
 
1228
    public String getEscalate() {
1229
        return escalate;
1230
    }
1231
 
1232
    public void setEscalate(String escalate) {
1233
        this.escalate = escalate;
1234
    }
4241 anupam.sin 1235
 
1236
    public String getCancelReason() {
1237
        return cancelReason;
1238
    }
1239
 
1240
    public void setCancelReason(String cancelReason) {
1241
        this.cancelReason = cancelReason;
1242
    }
4267 anupam.sin 1243
 
1244
    public List<Payment> getPayments() {
1245
        return payments;
1246
    }
1247
 
1248
    public void setPayments(List<Payment> payments) {
1249
        this.payments = payments;
1250
    }
1251
 
1252
    public String getTransactionId() {
1253
        return transactionId;
1254
    }
1255
 
1256
    public void setTransactionId(String transactionId) {
1257
        this.transactionId = transactionId;
1258
    }
4438 anupam.sin 1259
 
1260
    public String getPaymentId() {
1261
        return paymentId;
1262
    }
1263
 
1264
    public void setPaymentId(String paymentId) {
1265
        this.paymentId = paymentId;
1266
    }
4490 anupam.sin 1267
 
1268
    public HashMap<String, String> getAllAttachmentsForTicket() {
1269
        return allAttachmentsForTicket;
1270
    }
1271
 
1272
    public void setAllAttachmentsForTicket(HashMap<String, String> allAttachmentsForTicket) {
1273
        this.allAttachmentsForTicket = allAttachmentsForTicket;
1274
    }
3137 mandeep.dh 1275
}