Subversion Repositories SmartDukaan

Rev

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