Subversion Repositories SmartDukaan

Rev

Rev 5348 | Rev 5791 | 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;
3405 mandeep.dh 33
import in.shop2020.utils.HelperService.Client;
34
import in.shop2020.utils.HelperServiceException;
3546 mandeep.dh 35
import in.shop2020.utils.ModelUtils;
3137 mandeep.dh 36
 
3397 mandeep.dh 37
import java.text.ParseException;
3137 mandeep.dh 38
import java.util.ArrayList;
3578 mandeep.dh 39
import java.util.Calendar;
3390 mandeep.dh 40
import java.util.Collections;
3405 mandeep.dh 41
import java.util.Date;
4490 anupam.sin 42
import java.util.HashMap;
3137 mandeep.dh 43
import java.util.List;
44
 
4256 mandeep.dh 45
import net.htmlparser.jericho.Source;
46
 
3405 mandeep.dh 47
import org.apache.shiro.SecurityUtils;
3137 mandeep.dh 48
import org.apache.thrift.TException;
3546 mandeep.dh 49
import org.apache.thrift.transport.TTransportException;
3137 mandeep.dh 50
 
51
/**
52
 * @author mandeep
53
 * 
54
 */
55
public class TicketsController extends BaseController {
56
 
57
    /**
58
     * 
59
     */
60
    private static final long serialVersionUID = 1L;
61
 
62
    List<Ticket>              tickets          = new ArrayList<Ticket>();
3405 mandeep.dh 63
    private String            customerEmailId;
3339 mandeep.dh 64
    private String            description;
65
    private String            assigneeEmailId;
66
    private String            priority;
67
    private String            category;
68
    private String            orderId;
3397 mandeep.dh 69
    private String[]          agentIds;
70
    private String            startTimestamp;
71
    private String            endTimestamp;
3137 mandeep.dh 72
 
3405 mandeep.dh 73
    private String            userId;
74
    private String            id;
75
    private String            activityDescription;
76
    private String            status;
77
    private String            activityType;
78
    private Ticket            ticket;
79
    private List<Activity>    activities;
80
    private String            subject;
81
    private String            body;
82
    private String            customerName;
83
    private String            customerMobileNumber;
3546 mandeep.dh 84
    private User              user;
85
    private String            orderStatus;
86
    private List<Order>       orders;
4267 anupam.sin 87
    private List<Payment>     payments;
4020 mandeep.dh 88
    private String            escalate;
4241 anupam.sin 89
    private String            cancelReason;
4267 anupam.sin 90
    private String            transactionId;
3405 mandeep.dh 91
 
4438 anupam.sin 92
    private String paymentId;
93
 
4490 anupam.sin 94
    private HashMap<String, String> allAttachmentsForTicket;
95
 
3405 mandeep.dh 96
    public String index() {
97
        try {
98
            if (id != null && !id.isEmpty()) {
99
                SearchFilter searchFilter = new SearchFilter();
100
                crmServiceClient = new CRMClient().getClient();
101
                searchFilter.setTicketId(Long.parseLong(id));
102
                tickets = crmServiceClient.getTickets(searchFilter);
103
            }
104
        } catch (TException e) {
105
            log.error("Error while getting tickets", e);
106
            return EXCEPTION;
107
        }
108
 
109
        return INDEX;
110
    }
111
 
112
    public String edit() {
113
        try {
114
            long ticketId = Long.parseLong(id);
115
            SearchFilter searchFilter = new SearchFilter();
116
            searchFilter.setTicketId(ticketId);
117
            crmServiceClient = new CRMClient().getClient();
118
            ticket = crmServiceClient.getTickets(searchFilter).get(0);
119
            activities = crmServiceClient.getActivities(searchFilter);
4490 anupam.sin 120
            populateAttachments();
3405 mandeep.dh 121
            subject = createSubjectString(ticket);
122
 
123
            if (ticket.isSetCustomerId()) {
124
                userId = String.valueOf(ticket.getCustomerId());
3546 mandeep.dh 125
                userContextServiceClient = new UserClient().getClient();
126
 
127
                try {
128
                    user = userContextServiceClient.getUserById(ticket
129
                            .getCustomerId());
130
                } catch (UserContextException e) {
131
                    log.error("Could not fetch user details", e);
132
                }
3405 mandeep.dh 133
            }
134
 
135
            customerEmailId = ticket.getCustomerEmailId();
4689 anupam.sin 136
 
4277 anupam.sin 137
            if (TicketCategory.ORDER_CANCELLATION.equals(ticket.getCategory())) {
138
                log.info("Fetching orders for " + ticket.getCustomerId());
139
                orders = new ArrayList<Order>();
140
                transactionServiceClient = new TransactionClient().getClient();
4689 anupam.sin 141
                for (Order order : transactionServiceClient
142
                        .getOrdersForCustomer(ticket.getCustomerId(), 0, 0,
143
                                Collections.singletonList(OrderStatus.CANCEL_REQUEST_RECEIVED))) {
144
                    log.info("Processing Order: " + order.getId());
4287 anupam.sin 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
            }
4689 anupam.sin 162
 
4490 anupam.sin 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
            }
4689 anupam.sin 176
 
4490 anupam.sin 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));
5348 anupam.sin 687
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 688
                }
4682 rajveer 689
                else if (OrderStatus.COD_VERIFICATION_FAILED.equals(orderStatusEnum)) {
4277 anupam.sin 690
                    transactionServiceClient.refundOrder(Long.parseLong(orderId), currentAgentEmailId, cancelReason);
5348 anupam.sin 691
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 692
                }
693
                else if (OrderStatus.CANCEL_REQUEST_CONFIRMED.equals(orderStatusEnum)) {
694
                    transactionServiceClient.markOrderCancellationRequestConfirmed(Long.parseLong(orderId));
695
                }
696
                else {
697
                    throw new UnsupportedOperationException("Cannot update status of orderId: " + orderId + " to: " + orderStatus);
698
                }
699
            }
700
 
701
            SearchFilter searchFilter = new SearchFilter();
702
            searchFilter.setTicketId(Long.parseLong(id));
703
            crmServiceClient = new CRMClient().getClient();
704
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3546 mandeep.dh 705
 
4277 anupam.sin 706
            // Inserting activity
707
            Activity activity = new Activity();
708
            activity.setDescription("Status updated for Order Id: " + orderId
709
                    + " to " + orderStatus + ", Reason: " + cancelReason + body);
710
            activity.setType(ActivityType.OTHER);
711
            activity.setTicketPriority(ticket.getPriority());
712
            activity.setTicketStatus(ticket.getStatus());
713
            activity.setCreatorId(creatorId);
714
            activity.setTicketCategory(ticket.getCategory());
715
            activity.setTicketDescription(ticket.getDescription());
716
            activity.setCustomerId(ticket.getCustomerId());
717
            activity.setTicketAssigneeId(ticket.getAssigneeId());
3546 mandeep.dh 718
 
4277 anupam.sin 719
            crmServiceClient = new CRMClient().getClient();
720
            crmServiceClient.updateTicket(ticket, activity);
3546 mandeep.dh 721
 
4277 anupam.sin 722
        } catch (TException e) {
723
            log.info("Thrift exception", e);
724
        } catch (NumberFormatException e) {
725
            log.info("Could not convert to long", e);
726
        } catch (TransactionServiceException e) {
727
            log.info("Transaction client exception", e);
728
        }
729
 
3546 mandeep.dh 730
        return edit();
731
    }
4277 anupam.sin 732
 
3137 mandeep.dh 733
    public User getUser(Long userId) {
734
        User user = null;
735
 
736
        try {
3390 mandeep.dh 737
            userContextServiceClient = new UserClient().getClient();
3137 mandeep.dh 738
            user = userContextServiceClient.getUserById(userId);
739
        } catch (UserContextException e) {
740
            String errorString = "Could not fetch user for " + userId;
741
            log.error(errorString, e);
742
            addActionError(errorString);
743
        } catch (TException e) {
744
            String errorString = "Could not create client";
745
            log.error(errorString, e);
746
            addActionError(errorString);
747
        }
748
 
749
        return user;
750
    }
4267 anupam.sin 751
 
4438 anupam.sin 752
    public String allowPayment() {
753
        try {
754
            log.info("Allowing payment for paymentId = " + paymentId);
755
            transactionServiceClient = new TransactionClient().getClient();
756
            transactionServiceClient.markTransactionAsPaymentFlagRemoved(Long.parseLong(transactionId));
757
            if (id != null && !id.isEmpty()) {
758
                SearchFilter searchFilter = new SearchFilter();
759
                crmServiceClient = new CRMClient().getClient();
760
                searchFilter.setTicketId(Long.parseLong(id));
761
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
762
                // Inserting activity
763
                if(ticket != null) {
764
                    Activity activity = new Activity();
765
                    activity.setDescription("Flagged Payment allowed");
766
                    activity.setType(ActivityType.OTHER);
767
                    activity.setTicketPriority(ticket.getPriority());
768
                    activity.setTicketStatus(ticket.getStatus());
769
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
770
                    activity.setTicketCategory(ticket.getCategory());
771
                    activity.setTicketDescription(ticket.getDescription());
772
                    activity.setCustomerId(ticket.getCustomerId());
773
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
774
 
775
                    crmServiceClient = new CRMClient().getClient();
776
                    crmServiceClient.updateTicket(ticket, activity);
777
                }
778
            }
779
 
780
        } catch (TException e) {
781
            log.error("Error while getting tickets", e);
782
            return EXCEPTION;
783
        } catch (NumberFormatException e) {
784
            log.error("Invalid ticket Id", e);
785
            return EXCEPTION;
786
        } catch (TransactionServiceException e) {
787
            log.error("Error while marking transactions as Flag removed", e);
788
            return EXCEPTION;
789
        }
4267 anupam.sin 790
        return edit();
791
    }
792
 
4490 anupam.sin 793
    public String blockPayment() {
4438 anupam.sin 794
        try {
795
            log.info("Blocking payment for paymentId = " + paymentId);
796
            transactionServiceClient = new TransactionClient().getClient();
797
            transactionServiceClient.refundTransaction(Long.parseLong(transactionId), currentAgentEmailId, "FLAGGED_PAYMENT_CANCELLED");
798
            if (id != null && !id.isEmpty()) {
799
                SearchFilter searchFilter = new SearchFilter();
800
                crmServiceClient = new CRMClient().getClient();
801
                searchFilter.setTicketId(Long.parseLong(id));
802
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
803
                // Inserting activity
804
                if(ticket != null) {
805
                    Activity activity = new Activity();
806
                    activity.setDescription("Flagged Payment allowed");
807
                    activity.setType(ActivityType.OTHER);
808
                    activity.setTicketPriority(ticket.getPriority());
809
                    activity.setTicketStatus(ticket.getStatus());
810
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
811
                    activity.setTicketCategory(ticket.getCategory());
812
                    activity.setTicketDescription(ticket.getDescription());
813
                    activity.setCustomerId(ticket.getCustomerId());
814
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
815
 
816
                    crmServiceClient = new CRMClient().getClient();
817
                    crmServiceClient.updateTicket(ticket, activity);
818
                }
819
            }
820
 
821
        } catch (TException e) {
822
            log.error("Error while getting tickets", e);
823
            return EXCEPTION;
824
        } catch (NumberFormatException e) {
825
            log.error("Invalid ticket Id", e);
826
            return EXCEPTION;
827
        } catch (TransactionServiceException e) {
828
            log.error("Error while allowing flagged payment", e);
829
            return EXCEPTION;
830
        }
4267 anupam.sin 831
        return edit();
832
    }
4490 anupam.sin 833
 
834
    public String authorizeReturn() {
835
        try {
836
            log.info("Authorizing OrderId =" + orderId);
837
            transactionServiceClient = new TransactionClient().getClient();
838
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), true);
839
            if (id != null && !id.isEmpty()) {
840
                SearchFilter searchFilter = new SearchFilter();
841
                crmServiceClient = new CRMClient().getClient();
842
                searchFilter.setTicketId(Long.parseLong(id));
843
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
844
                // Inserting activity
845
                if(ticket != null) {
846
                    Activity activity = new Activity();
847
                    activity.setDescription("Return Authorized");
848
                    activity.setType(ActivityType.OTHER);
849
                    activity.setTicketPriority(ticket.getPriority());
850
                    activity.setTicketStatus(ticket.getStatus());
851
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
852
                    activity.setTicketCategory(ticket.getCategory());
853
                    activity.setTicketDescription(ticket.getDescription());
854
                    activity.setCustomerId(ticket.getCustomerId());
855
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
3137 mandeep.dh 856
 
4490 anupam.sin 857
                    crmServiceClient = new CRMClient().getClient();
858
                    crmServiceClient.updateTicket(ticket, activity);
859
                }
860
            }
861
 
862
        } catch (TException e) {
863
            log.error("Error while getting tickets", e);
864
            return EXCEPTION;
865
        } catch (NumberFormatException e) {
866
            log.error("Invalid ticket Id", e);
867
            return EXCEPTION;
868
        } catch (TransactionServiceException e) {
869
            log.error("Error while authorizing Return", e);
870
            return EXCEPTION;
871
        }
872
        return edit();
873
    }
874
 
875
    public String denyReturn() {
876
        try {
877
            log.info("Denying OrderId =" + orderId);
878
            transactionServiceClient = new TransactionClient().getClient();
879
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), false);
880
            if (id != null && !id.isEmpty()) {
881
                SearchFilter searchFilter = new SearchFilter();
882
                crmServiceClient = new CRMClient().getClient();
883
                searchFilter.setTicketId(Long.parseLong(id));
884
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
885
                // Inserting activity
886
                if(ticket != null) {
887
                    Activity activity = new Activity();
888
                    activity.setDescription("Return Denied");
889
                    activity.setType(ActivityType.OTHER);
890
                    activity.setTicketPriority(ticket.getPriority());
891
                    activity.setTicketStatus(ticket.getStatus());
892
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
893
                    activity.setTicketCategory(ticket.getCategory());
894
                    activity.setTicketDescription(ticket.getDescription());
895
                    activity.setCustomerId(ticket.getCustomerId());
896
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
897
 
898
                    crmServiceClient = new CRMClient().getClient();
899
                    crmServiceClient.updateTicket(ticket, activity);
900
                }
901
            }
902
 
903
        } catch (TException e) {
904
            log.error("Error while getting tickets", e);
905
            return EXCEPTION;
906
        } catch (NumberFormatException e) {
907
            log.error("Invalid ticket Id", e);
908
            return EXCEPTION;
909
        } catch (TransactionServiceException e) {
910
            log.error("Error while denying Return", e);
911
            return EXCEPTION;
912
        }
913
        return edit();
914
    }
915
 
916
    public String authorizeDOA() {
917
        try {
918
            log.info("Authorizing OrderId =" + orderId);
919
            transactionServiceClient = new TransactionClient().getClient();
920
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), true);
921
            if (id != null && !id.isEmpty()) {
922
                SearchFilter searchFilter = new SearchFilter();
923
                crmServiceClient = new CRMClient().getClient();
924
                searchFilter.setTicketId(Long.parseLong(id));
925
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
926
                // Inserting activity
927
                if(ticket != null) {
928
                    Activity activity = new Activity();
929
                    activity.setDescription("DOA Authorized");
930
                    activity.setType(ActivityType.OTHER);
931
                    activity.setTicketPriority(ticket.getPriority());
932
                    activity.setTicketStatus(ticket.getStatus());
933
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
934
                    activity.setTicketCategory(ticket.getCategory());
935
                    activity.setTicketDescription(ticket.getDescription());
936
                    activity.setCustomerId(ticket.getCustomerId());
937
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
938
 
939
                    crmServiceClient = new CRMClient().getClient();
940
                    crmServiceClient.updateTicket(ticket, activity);
941
                }
942
            }
943
 
944
        } catch (TException e) {
945
            log.error("Error while getting tickets", e);
946
            return EXCEPTION;
947
        } catch (NumberFormatException e) {
948
            log.error("Invalid ticket Id", e);
949
            return EXCEPTION;
950
        } catch (TransactionServiceException e) {
951
            log.error("Error while authorizing DOA", e);
952
            return EXCEPTION;
953
        }
954
        return edit();
955
    }
956
 
957
    public String denyDOA() {
958
        try {
959
            log.info("Denying OrderId =" + orderId);
960
            transactionServiceClient = new TransactionClient().getClient();
961
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), false);
962
            if (id != null && !id.isEmpty()) {
963
                SearchFilter searchFilter = new SearchFilter();
964
                crmServiceClient = new CRMClient().getClient();
965
                searchFilter.setTicketId(Long.parseLong(id));
966
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
967
                // Inserting activity
968
                if(ticket != null) {
969
                    Activity activity = new Activity();
970
                    activity.setDescription("DOA Denied");
971
                    activity.setType(ActivityType.OTHER);
972
                    activity.setTicketPriority(ticket.getPriority());
973
                    activity.setTicketStatus(ticket.getStatus());
974
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
975
                    activity.setTicketCategory(ticket.getCategory());
976
                    activity.setTicketDescription(ticket.getDescription());
977
                    activity.setCustomerId(ticket.getCustomerId());
978
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
979
 
980
                    crmServiceClient = new CRMClient().getClient();
981
                    crmServiceClient.updateTicket(ticket, activity);
982
                }
983
            }
984
 
985
        } catch (TException e) {
986
            log.error("Error while getting tickets", e);
987
            return EXCEPTION;
988
        } catch (NumberFormatException e) {
989
            log.error("Invalid ticket Id", e);
990
            return EXCEPTION;
991
        } catch (TransactionServiceException e) {
992
            log.error("Error while denying DOA", e);
993
            return EXCEPTION;
994
        }
995
        return edit();
996
    }
5407 amar.kumar 997
 
998
    public double getCustomerTrustLevel(long userId) {
999
    	try {
1000
			userContextServiceClient = new UserClient().getClient();
1001
			return userContextServiceClient.getTrustLevel(userId);
1002
		} catch (TException e) {
1003
			log.info("Exception while getting trustLevel for " +
1004
					"userId " + userId);
1005
		}
1006
		return 0;
1007
    }
4490 anupam.sin 1008
 
4020 mandeep.dh 1009
    public EscalationMatrix[] getEscalationMatrix () {
1010
        return CRMConstants.EscalationMatrix.values();
1011
    }
1012
 
3546 mandeep.dh 1013
    public String getAddress(Order order) {
1014
        return ModelUtils.extractAddressFromOrder(order);
1015
    }
1016
 
1017
    public String getProductName(LineItem lineItem) {
4008 mandeep.dh 1018
        return ModelUtils.extractProductNameFromLineItem(lineItem) + " " + lineItem.getColor();
3546 mandeep.dh 1019
    }
1020
 
3405 mandeep.dh 1021
    public ActivityType[] getActivityTypes() {
1022
        return ActivityType.values();
1023
    }
1024
 
1025
    public TicketStatus[] getTicketStatuses() {
1026
        return TicketStatus.values();
1027
    }
1028
 
3390 mandeep.dh 1029
    public Agent getAgent(long agentId) throws TException {
1030
        return CRMAuthorizingRealm.getAgent(agentId);
3137 mandeep.dh 1031
    }
1032
 
3339 mandeep.dh 1033
    public List<Agent> getAllAgents() {
3390 mandeep.dh 1034
        return CRMAuthorizingRealm.getAgents();
3339 mandeep.dh 1035
    }
1036
 
1037
    public TicketCategory[] getTicketCategories() {
1038
        return TicketCategory.values();
1039
    }
1040
 
1041
    public TicketPriority[] getTicketPriorities() {
1042
        return TicketPriority.values();
1043
    }
1044
 
3137 mandeep.dh 1045
    public List<Ticket> getTickets() {
1046
        return tickets;
1047
    }
1048
 
1049
    public void setTickets(List<Ticket> tickets) {
1050
        this.tickets = tickets;
1051
    }
3339 mandeep.dh 1052
 
3405 mandeep.dh 1053
    public String getCustomerEmailId() {
1054
        return customerEmailId;
3339 mandeep.dh 1055
    }
1056
 
3405 mandeep.dh 1057
    public void setCustomerEmailId(String customerEmailId) {
1058
        this.customerEmailId = customerEmailId;
3339 mandeep.dh 1059
    }
1060
 
1061
    public String getDescription() {
1062
        return description;
1063
    }
1064
 
1065
    public void setDescription(String description) {
1066
        this.description = description;
1067
    }
1068
 
1069
    public String getAssigneeEmailId() {
1070
        return assigneeEmailId;
1071
    }
1072
 
1073
    public void setAssigneeEmailId(String assigneeEmailId) {
1074
        this.assigneeEmailId = assigneeEmailId;
1075
    }
1076
 
1077
    public String getPriority() {
1078
        return priority;
1079
    }
1080
 
1081
    public void setPriority(String priority) {
1082
        this.priority = priority;
1083
    }
1084
 
1085
    public String getCategory() {
1086
        return category;
1087
    }
1088
 
1089
    public void setCategory(String category) {
1090
        this.category = category;
1091
    }
1092
 
1093
    public String getOrderId() {
1094
        return orderId;
1095
    }
1096
 
1097
    public void setOrderId(String orderId) {
1098
        this.orderId = orderId;
1099
    }
3397 mandeep.dh 1100
 
1101
    public String[] getAgentIds() {
1102
        return agentIds;
1103
    }
1104
 
1105
    public void setAgentIds(String[] agentIds) {
1106
        this.agentIds = agentIds;
1107
    }
1108
 
1109
    public String getStartTimestamp() {
1110
        return startTimestamp;
1111
    }
1112
 
1113
    public void setStartTimestamp(String startTimestamp) {
1114
        this.startTimestamp = startTimestamp;
1115
    }
1116
 
1117
    public String getEndTimestamp() {
1118
        return endTimestamp;
1119
    }
1120
 
1121
    public void setEndTimestamp(String endTimestamp) {
1122
        this.endTimestamp = endTimestamp;
1123
    }
3405 mandeep.dh 1124
 
1125
    public String getUserId() {
1126
        return userId;
1127
    }
1128
 
1129
    public void setUserId(String userId) {
1130
        this.userId = userId;
1131
    }
1132
 
1133
    public String getId() {
1134
        return id;
1135
    }
1136
 
1137
    public void setId(String id) {
1138
        this.id = id;
1139
    }
1140
 
1141
    public String getActivityDescription() {
1142
        return activityDescription;
1143
    }
1144
 
1145
    public void setActivityDescription(String activityDescription) {
1146
        this.activityDescription = activityDescription;
1147
    }
1148
 
1149
    public String getStatus() {
1150
        return status;
1151
    }
1152
 
1153
    public void setStatus(String status) {
1154
        this.status = status;
1155
    }
1156
 
1157
    public String getActivityType() {
1158
        return activityType;
1159
    }
1160
 
1161
    public void setActivityType(String activityType) {
1162
        this.activityType = activityType;
1163
    }
1164
 
1165
    public Ticket getTicket() {
1166
        return ticket;
1167
    }
1168
 
1169
    public void setTicket(Ticket ticket) {
1170
        this.ticket = ticket;
1171
    }
1172
 
1173
    public List<Activity> getActivities() {
1174
        return activities;
1175
    }
1176
 
1177
    public void setActivities(List<Activity> activities) {
1178
        this.activities = activities;
1179
    }
1180
 
1181
    public String getSubject() {
1182
        return subject;
1183
    }
1184
 
1185
    public void setSubject(String subject) {
1186
        this.subject = subject;
1187
    }
1188
 
1189
    public String getBody() {
1190
        return body;
1191
    }
1192
 
1193
    public void setBody(String body) {
1194
        this.body = body;
1195
    }
1196
 
1197
    public String getCustomerName() {
1198
        return customerName;
1199
    }
1200
 
1201
    public void setCustomerName(String customerName) {
1202
        this.customerName = customerName;
1203
    }
1204
 
1205
    public String getCustomerMobileNumber() {
1206
        return customerMobileNumber;
1207
    }
1208
 
1209
    public void setCustomerMobileNumber(String customerMobileNumber) {
1210
        this.customerMobileNumber = customerMobileNumber;
1211
    }
3546 mandeep.dh 1212
 
1213
    public User getUser() {
1214
        return user;
1215
    }
1216
 
1217
    public void setUser(User user) {
1218
        this.user = user;
1219
    }
1220
 
1221
    public String getOrderStatus() {
1222
        return orderStatus;
1223
    }
1224
 
1225
    public void setOrderStatus(String orderStatus) {
1226
        this.orderStatus = orderStatus;
1227
    }
1228
 
1229
    public List<Order> getOrders() {
1230
        return orders;
1231
    }
1232
 
1233
    public void setOrders(List<Order> orders) {
1234
        this.orders = orders;
1235
    }
4020 mandeep.dh 1236
 
1237
    public String getEscalate() {
1238
        return escalate;
1239
    }
1240
 
1241
    public void setEscalate(String escalate) {
1242
        this.escalate = escalate;
1243
    }
4241 anupam.sin 1244
 
1245
    public String getCancelReason() {
1246
        return cancelReason;
1247
    }
1248
 
1249
    public void setCancelReason(String cancelReason) {
1250
        this.cancelReason = cancelReason;
1251
    }
4267 anupam.sin 1252
 
1253
    public List<Payment> getPayments() {
1254
        return payments;
1255
    }
1256
 
1257
    public void setPayments(List<Payment> payments) {
1258
        this.payments = payments;
1259
    }
1260
 
1261
    public String getTransactionId() {
1262
        return transactionId;
1263
    }
1264
 
1265
    public void setTransactionId(String transactionId) {
1266
        this.transactionId = transactionId;
1267
    }
4438 anupam.sin 1268
 
1269
    public String getPaymentId() {
1270
        return paymentId;
1271
    }
1272
 
1273
    public void setPaymentId(String paymentId) {
1274
        this.paymentId = paymentId;
1275
    }
4490 anupam.sin 1276
 
1277
    public HashMap<String, String> getAllAttachmentsForTicket() {
1278
        return allAttachmentsForTicket;
1279
    }
1280
 
1281
    public void setAllAttachmentsForTicket(HashMap<String, String> allAttachmentsForTicket) {
1282
        this.allAttachmentsForTicket = allAttachmentsForTicket;
1283
    }
3137 mandeep.dh 1284
}