Subversion Repositories SmartDukaan

Rev

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