Subversion Repositories SmartDukaan

Rev

Rev 16530 | Rev 16642 | 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);
16530 manish.sha 614
                		email.setFromName("ProfitMandi");
16524 manish.sha 615
                		email.addTo(customerEmailId);
616
                		email.addBcc("backup@saholic.com");
617
                		email.setSubject(subject);
16532 manish.sha 618
                		email.setHtml("<pre>"+body+"<pre>");
16524 manish.sha 619
                		sendgrid.send(email);                		
620
 
621
                	} catch(Exception e){
622
                		log.error("Error while sending mail to user:- "+customerEmailId+" ticket Id:- "+ticket.getId(), e);
623
                	}
624
 
625
                	/*activity.setUserEmailId(helperClient.saveUserEmailForSending(
14882 manish.sha 626
	                        Arrays.asList(customerEmailId), CRMConstants.PROFIT_MANDI_EMAIL_SENDER,
16524 manish.sha 627
	                        subject, body, null, CRMConstants.PROFIT_MANDI_EMAIL_TYPE, null, null, 1));*/
14882 manish.sha 628
                }
3405 mandeep.dh 629
 
4256 mandeep.dh 630
                String plainTextbody = new Source(body).getTextExtractor().toString();
631
 
3405 mandeep.dh 632
                // We change activityType to OTHER when pop up box for email
633
                // closes
634
                activity.setDescription("Subject: " + subject + "\n\n"
4256 mandeep.dh 635
                        + "Body: " + plainTextbody);
4206 mandeep.dh 636
 
637
                String activityDesc = activity.getDescription();
638
                if (activityDesc.length() > CRMConstants.DESCRIPTION_MAX_WIDTH) {
639
                    activityDesc = activityDesc.substring(0, CRMConstants.DESCRIPTION_MAX_WIDTH);
640
                    activityDesc += "\n\nTHIS TEXT IS TRUNCATED. PLEASE VISIT INBOX TO SEE COMPLETE DETAILS.";
641
                }
642
 
643
                activity.setDescription(activityDesc);
3405 mandeep.dh 644
            }
645
 
4020 mandeep.dh 646
            if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
647
                log.info("Sending escalation mail");
16244 manish.sha 648
                if(escalate.startsWith("PM")){
649
                	PMEscalationMatrix escalation = CRMConstants.PMEscalationMatrix.valueOf(escalate);
650
                	List<Integer> escalationReceipients = escalation.getAgentIds();
651
 
652
                	List<String> toMailIds = new ArrayList<String>();
653
                    for (Integer agentId : escalationReceipients) {
654
                        toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
4020 mandeep.dh 655
 
16244 manish.sha 656
                        // Setting last agent as assignee
657
                        ticket.setAssigneeId(agentId);
658
                        activity.setTicketAssigneeId(agentId);
659
                    }
4034 mandeep.dh 660
 
16244 manish.sha 661
                    Client helperClient = new HelperClient().getClient();
662
                    String escalationMailSubject = createPMEscalationMailSubject(ticket, escalation);
663
                    String escalationMailBody = createEscalationMailBody(ticket);
16402 manish.sha 664
 
665
                    if(profitMandiTicketCategoryList.contains(ticket.getCategory())){
4020 mandeep.dh 666
 
16402 manish.sha 667
	                    activity.setUserEmailId(helperClient.saveUserEmailForSending(
668
	                            toMailIds, CRMConstants.PROFIT_MANDI_EMAIL_SENDER,
669
	                            escalationMailSubject, escalationMailBody,
670
	                            null, CRMConstants.PROFIT_MANDI_EMAIL_TYPE, null, null, 1));
671
                    }else{
672
                    	activity.setUserEmailId(helperClient.saveUserEmailForSending(
673
    	                        Arrays.asList(customerEmailId), CRMConstants.CRM_EMAIL_SENDOR,
674
    	                        subject, body, null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
675
                    }
4020 mandeep.dh 676
 
16244 manish.sha 677
                    // We change activityType to OTHER when pop up box for email
678
                    // closes
679
                    activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
680
                            + "Body: " + escalationMailBody);
681
                }else{
682
	                EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
683
	                List<Integer> escalationReceipients = escalation.getAgentIds();
684
 
685
	                List<String> toMailIds = new ArrayList<String>();
686
	                for (Integer agentId : escalationReceipients) {
687
	                    toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
688
 
689
	                    // Setting last agent as assignee
690
	                    ticket.setAssigneeId(agentId);
691
	                    activity.setTicketAssigneeId(agentId);
692
	                }
693
 
694
	                Client helperClient = new HelperClient().getClient();
695
	                String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
696
	                String escalationMailBody = createEscalationMailBody(ticket);
4020 mandeep.dh 697
 
16244 manish.sha 698
	                activity.setUserEmailId(helperClient.saveUserEmailForSending(
699
	                        toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
700
	                        escalationMailSubject, escalationMailBody,
701
	                        null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
702
 
703
	                // We change activityType to OTHER when pop up box for email
704
	                // closes
705
	                activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
706
	                        + "Body: " + escalationMailBody);
707
                }
4020 mandeep.dh 708
            }
709
 
3405 mandeep.dh 710
            User user = null;
711
            userContextServiceClient = new UserClient().getClient();
712
            try {
713
                if (customerName != null && !customerName.isEmpty()) {
714
                    ticket.setCustomerName(customerName);
715
                    activity.setCustomerName(customerName);
716
                }
717
 
718
                if (customerEmailId != null && !customerEmailId.isEmpty()) {
719
                    ticket.setCustomerEmailId(customerEmailId);
720
                    activity.setCustomerEmailId(customerEmailId);
3546 mandeep.dh 721
                    user = userContextServiceClient
722
                            .getUserByEmail(customerEmailId);
3405 mandeep.dh 723
                }
724
 
3546 mandeep.dh 725
                if ((user == null || user.getUserId() == -1)
726
                        && customerMobileNumber != null
727
                        && !customerMobileNumber.isEmpty()) {
3405 mandeep.dh 728
                    ticket.setCustomerMobileNumber(customerMobileNumber);
729
                    activity.setCustomerMobileNumber(customerMobileNumber);
3546 mandeep.dh 730
                    user = userContextServiceClient.getUserByMobileNumber(Long
731
                            .parseLong(customerMobileNumber));
3405 mandeep.dh 732
                }
733
            } catch (UserContextException e) {
734
                log.error("Could not fetch user for: " + customerEmailId + " "
735
                        + customerMobileNumber + " " + customerName, e);
736
            }
3546 mandeep.dh 737
 
3405 mandeep.dh 738
            if (user != null && user.getUserId() != -1) {
739
                ticket.setCustomerId(user.getUserId());
740
                activity.setCustomerId(user.getUserId());
741
            }
742
 
743
            crmServiceClient = new CRMClient().getClient();
744
            crmServiceClient.updateTicket(ticket, activity);
745
        } catch (TException e) {
746
            log.error("Error while updating ticket", e);
747
            return EXCEPTION;
748
        } catch (HelperServiceException hse) {
749
            log.error("Error while sending mail", hse);
750
            return EXCEPTION;
751
        }
752
 
14882 manish.sha 753
        return INDEX;
3405 mandeep.dh 754
    }
755
 
16244 manish.sha 756
    private String createEscalationMailBody(Ticket ticket)
4020 mandeep.dh 757
    {
758
        return body + "<br />Please visit following URL to check ticket details.<br />" + 
759
            "http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
760
    }
761
 
762
    private String createEscalationMailSubject(Ticket ticket,
763
            EscalationMatrix escalation)
764
    {
765
        return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
766
    }
16244 manish.sha 767
 
768
    private String createPMEscalationMailSubject(Ticket ticket,
769
            PMEscalationMatrix escalation)
770
    {
771
        return CRMConstants.PROFIT_MANDI_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
772
    }
4020 mandeep.dh 773
 
3546 mandeep.dh 774
    private boolean pendingCODOrders(long customerId) {
775
        try {
776
            log.info("Trying to fetch orders for " + customerId);
777
            transactionServiceClient = new TransactionClient().getClient();
778
            for (Order order : transactionServiceClient.getOrdersForCustomer(
779
                    customerId, 0, 0,
4663 rajveer 780
                    Collections.singletonList(OrderStatus.COD_VERIFICATION_PENDING))) {
3546 mandeep.dh 781
                log.info("Processing order: " + order.getId() + " with COD: " + order.isCod());
782
                if (order.isCod()) {
783
                    log.info("Returning true from pendingCODOrders() for " + customerId);
784
                    return true;
785
                }
786
            }
787
        } catch (TTransportException e) {
788
            log.error("Error while creating thrift client", e);
789
        } catch (TransactionServiceException e) {
790
            log.error("Error fetching orders", e);
791
        } catch (TException e) {
792
            log.error("Error fetching orders", e);
793
        }
794
 
795
        log.info("Returning false from pendingCODOrders() for " + customerId);
796
        return false;
797
    }
5791 anupam.sin 798
 
799
    public String extendExpiry() {
800
        try {
801
            log.info("order Id = " + orderId);
802
            log.info("pickup : " + pickupExtension);
803
            Attribute newAttribute = new Attribute();
804
            List<Attribute> attributes = new ArrayList<Attribute>();
805
            String extendedBy = "0";
806
            transactionServiceClient = new TransactionClient().getClient();
807
            attributes = transactionServiceClient.getAllAttributesForOrderId(Long.parseLong(orderId));
808
            for (Attribute attribute : attributes) {
809
                if (attribute.getName().equals("pickupExtension")) {
810
                    extendedBy = attribute.getValue();
811
                    break;
812
                }
813
            }
814
            log.info("ATTR = " + attributes);
815
            log.info("1");
816
            if (extendedBy.equals("0")) {
817
                newAttribute.setName("pickupExtension");
818
                newAttribute.setValue(pickupExtension);
819
                attributes.add(newAttribute);
820
                log.info("2");
821
            } else {
822
                Long totalExtension = Long.parseLong(extendedBy) + Long.parseLong(pickupExtension);
823
                for (Attribute attribute : attributes) {
824
                    if (attribute.getName().equals("pickupExtension")) {
825
                        attribute.setValue(totalExtension.toString());
826
                        log.info("3");
827
                    }
828
                }
829
            }
830
            transactionServiceClient = new TransactionClient().getClient();
831
            transactionServiceClient.setOrderAttributes(Long.parseLong(orderId), attributes);
5919 anupam.sin 832
 
833
            SearchFilter searchFilter = new SearchFilter();
834
            searchFilter.setTicketId(Long.parseLong(id));
835
            crmServiceClient = new CRMClient().getClient();
836
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
837
 
838
            // Inserting activity
839
            Activity activity = new Activity();
840
            activity.setDescription("Pickup extended by " + pickupExtension
841
                    + " Days.");
842
            activity.setType(ActivityType.OTHER);
843
            activity.setTicketPriority(ticket.getPriority());
844
            activity.setTicketStatus(ticket.getStatus());
845
            activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
846
            activity.setTicketCategory(ticket.getCategory());
847
            activity.setTicketDescription(ticket.getDescription());
848
            activity.setCustomerId(ticket.getCustomerId());
849
            activity.setTicketAssigneeId(ticket.getAssigneeId());
850
 
851
            crmServiceClient = new CRMClient().getClient();
852
            crmServiceClient.updateTicket(ticket, activity);
853
 
5917 anupam.sin 854
            //transactionServiceClient = new TransactionClient().getClient();
855
            //transactionServiceClient.enqueueExpiryExtensionEmail(orderId);
5791 anupam.sin 856
        } catch (NumberFormatException e) {
857
            e.printStackTrace();
858
        } catch (TException e) {
859
            e.printStackTrace();
860
        }
5917 anupam.sin 861
        return edit();
5791 anupam.sin 862
    }
863
 
864
    public String getPickupExpiryDate(long id, long deliveryTimestamp) {
865
        try {
866
            log.info("orderID" + id);
867
            log.info("Delivery Time : " + deliveryTimestamp);
868
            Date deliveryDate = new Date(deliveryTimestamp);
869
            Calendar cal = Calendar.getInstance();
870
            cal.setTime(deliveryDate);
871
 
872
            log.info("Orig Del Date :" + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
873
 
874
            cal.add(Calendar.DATE, 5);
875
 
876
            log.info("After adding 5 days" + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
877
 
878
            transactionServiceClient = new TransactionClient().getClient();
879
            List<Attribute> attributes = new ArrayList<Attribute>();
880
            String extendedBy = "0";
881
            attributes = transactionServiceClient.getAllAttributesForOrderId(id);
882
            for (Attribute attribute : attributes) {
883
                if (attribute.getName().equals("pickupExtension")) {
884
                    extendedBy = attribute.getValue();
885
                }
886
            }
887
            cal.add(Calendar.DATE, Integer.parseInt(extendedBy));
888
 
889
            log.info("Extended by" + extendedBy);
890
 
891
            log.info("Final : " + cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR));
892
 
893
            SimpleDateFormat SDF = new SimpleDateFormat("dd MMM, yyyy");
894
            return SDF.format(cal.getTime());
895
 
896
        } catch (NumberFormatException e) {
897
            e.printStackTrace();
898
        } catch (TException e) {
899
            e.printStackTrace();
900
        }
901
        return "N/A";
902
    }
3546 mandeep.dh 903
 
4277 anupam.sin 904
    public String updateOrderStatus() {
905
        long creatorId;
906
        OrderStatus orderStatusEnum = null;
907
        try {
908
            creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
909
 
910
            if(orderStatus.equals("DENY_CANCEL_REQUEST")) {
911
                transactionServiceClient = new TransactionClient().getClient();
912
                transactionServiceClient.markOrderCancellationRequestDenied(Long.parseLong(orderId));
913
            } 
3546 mandeep.dh 914
 
4277 anupam.sin 915
            else {
3546 mandeep.dh 916
 
4277 anupam.sin 917
                orderStatusEnum = OrderStatus.valueOf(orderStatus);
918
                transactionServiceClient = new TransactionClient().getClient();
3578 mandeep.dh 919
 
4277 anupam.sin 920
                if (OrderStatus.SUBMITTED_FOR_PROCESSING.equals(orderStatusEnum)) {
921
                    transactionServiceClient.verifyOrder(Long.parseLong(orderId));
5348 anupam.sin 922
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 923
                }
4682 rajveer 924
                else if (OrderStatus.COD_VERIFICATION_FAILED.equals(orderStatusEnum)) {
4277 anupam.sin 925
                    transactionServiceClient.refundOrder(Long.parseLong(orderId), currentAgentEmailId, cancelReason);
5348 anupam.sin 926
                    transactionServiceClient.updateCODAgent(currentAgentEmailId, Long.parseLong(orderId));
4277 anupam.sin 927
                }
928
                else if (OrderStatus.CANCEL_REQUEST_CONFIRMED.equals(orderStatusEnum)) {
929
                    transactionServiceClient.markOrderCancellationRequestConfirmed(Long.parseLong(orderId));
930
                }
931
                else {
932
                    throw new UnsupportedOperationException("Cannot update status of orderId: " + orderId + " to: " + orderStatus);
933
                }
934
            }
935
 
936
            SearchFilter searchFilter = new SearchFilter();
937
            searchFilter.setTicketId(Long.parseLong(id));
938
            crmServiceClient = new CRMClient().getClient();
939
            Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
3546 mandeep.dh 940
 
4277 anupam.sin 941
            // Inserting activity
942
            Activity activity = new Activity();
943
            activity.setDescription("Status updated for Order Id: " + orderId
944
                    + " to " + orderStatus + ", Reason: " + cancelReason + body);
945
            activity.setType(ActivityType.OTHER);
946
            activity.setTicketPriority(ticket.getPriority());
947
            activity.setTicketStatus(ticket.getStatus());
948
            activity.setCreatorId(creatorId);
949
            activity.setTicketCategory(ticket.getCategory());
950
            activity.setTicketDescription(ticket.getDescription());
951
            activity.setCustomerId(ticket.getCustomerId());
952
            activity.setTicketAssigneeId(ticket.getAssigneeId());
3546 mandeep.dh 953
 
4277 anupam.sin 954
            crmServiceClient = new CRMClient().getClient();
955
            crmServiceClient.updateTicket(ticket, activity);
3546 mandeep.dh 956
 
4277 anupam.sin 957
        } catch (TException e) {
958
            log.info("Thrift exception", e);
959
        } catch (NumberFormatException e) {
960
            log.info("Could not convert to long", e);
961
        } catch (TransactionServiceException e) {
962
            log.info("Transaction client exception", e);
963
        }
964
 
3546 mandeep.dh 965
        return edit();
966
    }
4277 anupam.sin 967
 
3137 mandeep.dh 968
    public User getUser(Long userId) {
969
        User user = null;
970
 
971
        try {
3390 mandeep.dh 972
            userContextServiceClient = new UserClient().getClient();
3137 mandeep.dh 973
            user = userContextServiceClient.getUserById(userId);
974
        } catch (UserContextException e) {
975
            String errorString = "Could not fetch user for " + userId;
976
            log.error(errorString, e);
977
            addActionError(errorString);
978
        } catch (TException e) {
979
            String errorString = "Could not create client";
980
            log.error(errorString, e);
981
            addActionError(errorString);
982
        }
983
 
984
        return user;
985
    }
4267 anupam.sin 986
 
4438 anupam.sin 987
    public String allowPayment() {
988
        try {
989
            log.info("Allowing payment for paymentId = " + paymentId);
990
            transactionServiceClient = new TransactionClient().getClient();
991
            transactionServiceClient.markTransactionAsPaymentFlagRemoved(Long.parseLong(transactionId));
992
            if (id != null && !id.isEmpty()) {
993
                SearchFilter searchFilter = new SearchFilter();
994
                crmServiceClient = new CRMClient().getClient();
995
                searchFilter.setTicketId(Long.parseLong(id));
996
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
997
                // Inserting activity
998
                if(ticket != null) {
999
                    Activity activity = new Activity();
1000
                    activity.setDescription("Flagged Payment allowed");
1001
                    activity.setType(ActivityType.OTHER);
1002
                    activity.setTicketPriority(ticket.getPriority());
1003
                    activity.setTicketStatus(ticket.getStatus());
1004
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1005
                    activity.setTicketCategory(ticket.getCategory());
1006
                    activity.setTicketDescription(ticket.getDescription());
1007
                    activity.setCustomerId(ticket.getCustomerId());
1008
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1009
 
1010
                    crmServiceClient = new CRMClient().getClient();
1011
                    crmServiceClient.updateTicket(ticket, activity);
1012
                }
1013
            }
1014
 
1015
        } catch (TException e) {
1016
            log.error("Error while getting tickets", e);
1017
            return EXCEPTION;
1018
        } catch (NumberFormatException e) {
1019
            log.error("Invalid ticket Id", e);
1020
            return EXCEPTION;
1021
        } catch (TransactionServiceException e) {
1022
            log.error("Error while marking transactions as Flag removed", e);
1023
            return EXCEPTION;
1024
        }
4267 anupam.sin 1025
        return edit();
1026
    }
1027
 
4490 anupam.sin 1028
    public String blockPayment() {
4438 anupam.sin 1029
        try {
1030
            log.info("Blocking payment for paymentId = " + paymentId);
1031
            transactionServiceClient = new TransactionClient().getClient();
1032
            transactionServiceClient.refundTransaction(Long.parseLong(transactionId), currentAgentEmailId, "FLAGGED_PAYMENT_CANCELLED");
1033
            if (id != null && !id.isEmpty()) {
1034
                SearchFilter searchFilter = new SearchFilter();
1035
                crmServiceClient = new CRMClient().getClient();
1036
                searchFilter.setTicketId(Long.parseLong(id));
1037
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1038
                // Inserting activity
1039
                if(ticket != null) {
1040
                    Activity activity = new Activity();
1041
                    activity.setDescription("Flagged Payment allowed");
1042
                    activity.setType(ActivityType.OTHER);
1043
                    activity.setTicketPriority(ticket.getPriority());
1044
                    activity.setTicketStatus(ticket.getStatus());
1045
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1046
                    activity.setTicketCategory(ticket.getCategory());
1047
                    activity.setTicketDescription(ticket.getDescription());
1048
                    activity.setCustomerId(ticket.getCustomerId());
1049
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1050
 
1051
                    crmServiceClient = new CRMClient().getClient();
1052
                    crmServiceClient.updateTicket(ticket, activity);
1053
                }
1054
            }
1055
 
1056
        } catch (TException e) {
1057
            log.error("Error while getting tickets", e);
1058
            return EXCEPTION;
1059
        } catch (NumberFormatException e) {
1060
            log.error("Invalid ticket Id", e);
1061
            return EXCEPTION;
1062
        } catch (TransactionServiceException e) {
1063
            log.error("Error while allowing flagged payment", e);
1064
            return EXCEPTION;
1065
        }
4267 anupam.sin 1066
        return edit();
1067
    }
4490 anupam.sin 1068
 
1069
    public String authorizeReturn() {
1070
        try {
1071
            log.info("Authorizing OrderId =" + orderId);
7645 anupam.sin 1072
            boolean isReship = false;
1073
            boolean fromStore  = false;
4490 anupam.sin 1074
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1075
            if(premises.equals("store")) {
1076
                fromStore = true;
1077
            }
1078
 
1079
            if(closureType.equals("reship")) {
1080
                isReship = true;
1081
            }
1082
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), true, fromStore, isReship);
4490 anupam.sin 1083
            if (id != null && !id.isEmpty()) {
1084
                SearchFilter searchFilter = new SearchFilter();
1085
                crmServiceClient = new CRMClient().getClient();
1086
                searchFilter.setTicketId(Long.parseLong(id));
1087
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1088
                // Inserting activity
1089
                if(ticket != null) {
1090
                    Activity activity = new Activity();
1091
                    activity.setDescription("Return Authorized");
1092
                    activity.setType(ActivityType.OTHER);
1093
                    activity.setTicketPriority(ticket.getPriority());
1094
                    activity.setTicketStatus(ticket.getStatus());
1095
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1096
                    activity.setTicketCategory(ticket.getCategory());
1097
                    activity.setTicketDescription(ticket.getDescription());
1098
                    activity.setCustomerId(ticket.getCustomerId());
1099
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
3137 mandeep.dh 1100
 
4490 anupam.sin 1101
                    crmServiceClient = new CRMClient().getClient();
1102
                    crmServiceClient.updateTicket(ticket, activity);
1103
                }
1104
            }
1105
 
1106
        } catch (TException e) {
1107
            log.error("Error while getting tickets", e);
1108
            return EXCEPTION;
1109
        } catch (NumberFormatException e) {
1110
            log.error("Invalid ticket Id", e);
1111
            return EXCEPTION;
1112
        } catch (TransactionServiceException e) {
1113
            log.error("Error while authorizing Return", e);
1114
            return EXCEPTION;
1115
        }
1116
        return edit();
1117
    }
1118
 
1119
    public String denyReturn() {
1120
        try {
1121
            log.info("Denying OrderId =" + orderId);
1122
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1123
            transactionServiceClient.markOrderReturnRequestAuthorized(Long.parseLong(orderId), false, false, false);
4490 anupam.sin 1124
            if (id != null && !id.isEmpty()) {
1125
                SearchFilter searchFilter = new SearchFilter();
1126
                crmServiceClient = new CRMClient().getClient();
1127
                searchFilter.setTicketId(Long.parseLong(id));
1128
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1129
                // Inserting activity
1130
                if(ticket != null) {
1131
                    Activity activity = new Activity();
1132
                    activity.setDescription("Return Denied");
1133
                    activity.setType(ActivityType.OTHER);
1134
                    activity.setTicketPriority(ticket.getPriority());
1135
                    activity.setTicketStatus(ticket.getStatus());
1136
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1137
                    activity.setTicketCategory(ticket.getCategory());
1138
                    activity.setTicketDescription(ticket.getDescription());
1139
                    activity.setCustomerId(ticket.getCustomerId());
1140
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1141
 
1142
                    crmServiceClient = new CRMClient().getClient();
1143
                    crmServiceClient.updateTicket(ticket, activity);
1144
                }
1145
            }
1146
 
1147
        } catch (TException e) {
1148
            log.error("Error while getting tickets", e);
1149
            return EXCEPTION;
1150
        } catch (NumberFormatException e) {
1151
            log.error("Invalid ticket Id", e);
1152
            return EXCEPTION;
1153
        } catch (TransactionServiceException e) {
1154
            log.error("Error while denying Return", e);
1155
            return EXCEPTION;
1156
        }
1157
        return edit();
1158
    }
1159
 
1160
    public String authorizeDOA() {
1161
        try {
1162
            log.info("Authorizing OrderId =" + orderId);
7645 anupam.sin 1163
            boolean isReship = false;
1164
            boolean fromStore  = false;
4490 anupam.sin 1165
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1166
            if(premises.equals("store")) {
1167
                fromStore = true;
1168
            }
1169
 
1170
            if(closureType.equals("reship")) {
1171
                isReship = true;
1172
            }
1173
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), true, fromStore, isReship);
4490 anupam.sin 1174
            if (id != null && !id.isEmpty()) {
1175
                SearchFilter searchFilter = new SearchFilter();
1176
                crmServiceClient = new CRMClient().getClient();
1177
                searchFilter.setTicketId(Long.parseLong(id));
1178
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1179
                // Inserting activity
1180
                if(ticket != null) {
1181
                    Activity activity = new Activity();
1182
                    activity.setDescription("DOA Authorized");
1183
                    activity.setType(ActivityType.OTHER);
1184
                    activity.setTicketPriority(ticket.getPriority());
1185
                    activity.setTicketStatus(ticket.getStatus());
1186
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1187
                    activity.setTicketCategory(ticket.getCategory());
1188
                    activity.setTicketDescription(ticket.getDescription());
1189
                    activity.setCustomerId(ticket.getCustomerId());
1190
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1191
 
1192
                    crmServiceClient = new CRMClient().getClient();
1193
                    crmServiceClient.updateTicket(ticket, activity);
1194
                }
1195
            }
1196
 
1197
        } catch (TException e) {
1198
            log.error("Error while getting tickets", e);
1199
            return EXCEPTION;
1200
        } catch (NumberFormatException e) {
1201
            log.error("Invalid ticket Id", e);
1202
            return EXCEPTION;
1203
        } catch (TransactionServiceException e) {
1204
            log.error("Error while authorizing DOA", e);
1205
            return EXCEPTION;
1206
        }
1207
        return edit();
1208
    }
1209
 
1210
    public String denyDOA() {
1211
        try {
1212
            log.info("Denying OrderId =" + orderId);
1213
            transactionServiceClient = new TransactionClient().getClient();
7645 anupam.sin 1214
            transactionServiceClient.markOrderDoaRequestAuthorized(Long.parseLong(orderId), false, false, false);
4490 anupam.sin 1215
            if (id != null && !id.isEmpty()) {
1216
                SearchFilter searchFilter = new SearchFilter();
1217
                crmServiceClient = new CRMClient().getClient();
1218
                searchFilter.setTicketId(Long.parseLong(id));
1219
                Ticket ticket = crmServiceClient.getTickets(searchFilter).get(0);
1220
                // Inserting activity
1221
                if(ticket != null) {
1222
                    Activity activity = new Activity();
1223
                    activity.setDescription("DOA Denied");
1224
                    activity.setType(ActivityType.OTHER);
1225
                    activity.setTicketPriority(ticket.getPriority());
1226
                    activity.setTicketStatus(ticket.getStatus());
1227
                    activity.setCreatorId(CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId());
1228
                    activity.setTicketCategory(ticket.getCategory());
1229
                    activity.setTicketDescription(ticket.getDescription());
1230
                    activity.setCustomerId(ticket.getCustomerId());
1231
                    activity.setTicketAssigneeId(ticket.getAssigneeId());
1232
 
1233
                    crmServiceClient = new CRMClient().getClient();
1234
                    crmServiceClient.updateTicket(ticket, activity);
1235
                }
1236
            }
1237
 
1238
        } catch (TException e) {
1239
            log.error("Error while getting tickets", e);
1240
            return EXCEPTION;
1241
        } catch (NumberFormatException e) {
1242
            log.error("Invalid ticket Id", e);
1243
            return EXCEPTION;
1244
        } catch (TransactionServiceException e) {
1245
            log.error("Error while denying DOA", e);
1246
            return EXCEPTION;
1247
        }
1248
        return edit();
1249
    }
5407 amar.kumar 1250
 
14882 manish.sha 1251
    public String loadProfitMandiTickets() throws ParseException {
1252
    	try {
1253
            SearchFilter searchFilter = new SearchFilter();
1254
            searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
1255
            searchFilter.getTicketStatuses().add(TicketStatus.OPEN);
1256
            searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
1257
            crmServiceClient = new CRMClient().getClient();
1258
            tickets = new ArrayList<Ticket>();
16244 manish.sha 1259
            searchFilter.setTicketCategoryList(profitMandiTicketCategoryList);
14882 manish.sha 1260
            tickets.addAll(crmServiceClient.getTickets(searchFilter));
1261
        } catch (TException e) {
1262
            String errorString = "Error getting tickets for "
1263
                    + currentAgentEmailId;
1264
            log.error(errorString, e);
1265
            addActionError(errorString);
1266
        }
1267
    	return index();
1268
    }
1269
 
5909 amar.kumar 1270
    public String getAllOpenTickets() {
1271
    	try {
1272
    		ticketCategorycountMap= new HashMap<String, Long>();
1273
            crmServiceClient = new CRMClient().getClient();
1274
            ticketCategorycountMap = crmServiceClient.getOpenTicketsMap();
1275
        } catch (TException e) {
1276
            String errorString = "Error getting tickets for "
1277
                    + currentAgentEmailId;
1278
            log.error(errorString, e);
1279
            addActionError(errorString);
1280
        }
1281
        return OPEN;
1282
    }
1283
 
5407 amar.kumar 1284
    public double getCustomerTrustLevel(long userId) {
1285
    	try {
1286
			userContextServiceClient = new UserClient().getClient();
1287
			return userContextServiceClient.getTrustLevel(userId);
1288
		} catch (TException e) {
1289
			log.info("Exception while getting trustLevel for " +
1290
					"userId " + userId);
1291
		}
1292
		return 0;
1293
    }
4490 anupam.sin 1294
 
4020 mandeep.dh 1295
    public EscalationMatrix[] getEscalationMatrix () {
1296
        return CRMConstants.EscalationMatrix.values();
1297
    }
16244 manish.sha 1298
 
1299
    public PMEscalationMatrix[] getPMEscalationMatrix () {
1300
        return CRMConstants.PMEscalationMatrix.values();
1301
    }
4020 mandeep.dh 1302
 
3546 mandeep.dh 1303
    public String getAddress(Order order) {
1304
        return ModelUtils.extractAddressFromOrder(order);
1305
    }
1306
 
1307
    public String getProductName(LineItem lineItem) {
4008 mandeep.dh 1308
        return ModelUtils.extractProductNameFromLineItem(lineItem) + " " + lineItem.getColor();
3546 mandeep.dh 1309
    }
1310
 
3405 mandeep.dh 1311
    public ActivityType[] getActivityTypes() {
1312
        return ActivityType.values();
1313
    }
1314
 
1315
    public TicketStatus[] getTicketStatuses() {
1316
        return TicketStatus.values();
1317
    }
1318
 
3390 mandeep.dh 1319
    public Agent getAgent(long agentId) throws TException {
1320
        return CRMAuthorizingRealm.getAgent(agentId);
3137 mandeep.dh 1321
    }
1322
 
3339 mandeep.dh 1323
    public List<Agent> getAllAgents() {
16244 manish.sha 1324
    	List<Agent> allagents = CRMAuthorizingRealm.getAgents();
1325
    	List<Agent> requiredAgents = new ArrayList<Agent>();
1326
    	if(isSaholicAndProfitMandiAllowed()){
1327
    		return allagents;
1328
    	} else if(isProfitMandiAgent()){
1329
    		for(Agent agent: allagents){
1330
    			if(agent.isIs_pmCrmUser()){
1331
    				requiredAgents.add(agent);
1332
    			}
1333
    		}
1334
    		return requiredAgents;
1335
    	} else{
1336
    		for(Agent agent: allagents){
1337
    			if(!agent.isIs_pmCrmUser()||agent.isIs_allAssignable()){
1338
    				requiredAgents.add(agent);
1339
    			}
1340
    		}
1341
    		return requiredAgents;
1342
    	}
3339 mandeep.dh 1343
    }
1344
 
16248 manish.sha 1345
    public List<TicketCategory> getTicketCategories() {
1346
    	List<TicketCategory> allCategories = Arrays.asList(TicketCategory.values());
1347
    	List<TicketCategory> requiredCategories = new ArrayList<TicketCategory>();
1348
    	if(isSaholicAndProfitMandiAllowed()){
1349
    		return allCategories;
1350
    	}else if(isProfitMandiAgent()){
1351
    		for(TicketCategory tkCategory: allCategories){
1352
    			if(profitMandiTicketCategoryList.contains(tkCategory)){
1353
    				requiredCategories.add(tkCategory);
1354
    			}
1355
    		}
1356
    		return requiredCategories;
1357
    	}else{
1358
    		for(TicketCategory tkCategory: allCategories){
1359
    			if(!profitMandiTicketCategoryList.contains(tkCategory)){
1360
    				requiredCategories.add(tkCategory);
1361
    			}
1362
    		}
1363
    		return requiredCategories;
1364
    	}
3339 mandeep.dh 1365
    }
1366
 
1367
    public TicketPriority[] getTicketPriorities() {
1368
        return TicketPriority.values();
1369
    }
1370
 
3137 mandeep.dh 1371
    public List<Ticket> getTickets() {
1372
        return tickets;
1373
    }
1374
 
1375
    public void setTickets(List<Ticket> tickets) {
1376
        this.tickets = tickets;
1377
    }
3339 mandeep.dh 1378
 
3405 mandeep.dh 1379
    public String getCustomerEmailId() {
1380
        return customerEmailId;
3339 mandeep.dh 1381
    }
1382
 
3405 mandeep.dh 1383
    public void setCustomerEmailId(String customerEmailId) {
1384
        this.customerEmailId = customerEmailId;
3339 mandeep.dh 1385
    }
1386
 
1387
    public String getDescription() {
1388
        return description;
1389
    }
1390
 
1391
    public void setDescription(String description) {
1392
        this.description = description;
1393
    }
1394
 
1395
    public String getAssigneeEmailId() {
1396
        return assigneeEmailId;
1397
    }
1398
 
1399
    public void setAssigneeEmailId(String assigneeEmailId) {
1400
        this.assigneeEmailId = assigneeEmailId;
1401
    }
1402
 
1403
    public String getPriority() {
1404
        return priority;
1405
    }
1406
 
1407
    public void setPriority(String priority) {
1408
        this.priority = priority;
1409
    }
1410
 
1411
    public String getCategory() {
1412
        return category;
1413
    }
1414
 
1415
    public void setCategory(String category) {
1416
        this.category = category;
1417
    }
1418
 
1419
    public String getOrderId() {
1420
        return orderId;
1421
    }
1422
 
1423
    public void setOrderId(String orderId) {
1424
        this.orderId = orderId;
1425
    }
3397 mandeep.dh 1426
 
1427
    public String[] getAgentIds() {
1428
        return agentIds;
1429
    }
1430
 
1431
    public void setAgentIds(String[] agentIds) {
1432
        this.agentIds = agentIds;
1433
    }
1434
 
1435
    public String getStartTimestamp() {
1436
        return startTimestamp;
1437
    }
1438
 
1439
    public void setStartTimestamp(String startTimestamp) {
1440
        this.startTimestamp = startTimestamp;
1441
    }
1442
 
1443
    public String getEndTimestamp() {
1444
        return endTimestamp;
1445
    }
1446
 
1447
    public void setEndTimestamp(String endTimestamp) {
1448
        this.endTimestamp = endTimestamp;
1449
    }
3405 mandeep.dh 1450
 
1451
    public String getUserId() {
1452
        return userId;
1453
    }
1454
 
1455
    public void setUserId(String userId) {
1456
        this.userId = userId;
1457
    }
1458
 
1459
    public String getId() {
1460
        return id;
1461
    }
1462
 
1463
    public void setId(String id) {
1464
        this.id = id;
1465
    }
1466
 
1467
    public String getActivityDescription() {
1468
        return activityDescription;
1469
    }
1470
 
1471
    public void setActivityDescription(String activityDescription) {
1472
        this.activityDescription = activityDescription;
1473
    }
1474
 
1475
    public String getStatus() {
1476
        return status;
1477
    }
1478
 
1479
    public void setStatus(String status) {
1480
        this.status = status;
1481
    }
1482
 
1483
    public String getActivityType() {
1484
        return activityType;
1485
    }
1486
 
1487
    public void setActivityType(String activityType) {
1488
        this.activityType = activityType;
1489
    }
1490
 
1491
    public Ticket getTicket() {
1492
        return ticket;
1493
    }
1494
 
1495
    public void setTicket(Ticket ticket) {
1496
        this.ticket = ticket;
1497
    }
1498
 
1499
    public List<Activity> getActivities() {
1500
        return activities;
1501
    }
1502
 
1503
    public void setActivities(List<Activity> activities) {
1504
        this.activities = activities;
1505
    }
1506
 
1507
    public String getSubject() {
1508
        return subject;
1509
    }
1510
 
1511
    public void setSubject(String subject) {
1512
        this.subject = subject;
1513
    }
1514
 
1515
    public String getBody() {
1516
        return body;
1517
    }
1518
 
1519
    public void setBody(String body) {
1520
        this.body = body;
1521
    }
1522
 
1523
    public String getCustomerName() {
1524
        return customerName;
1525
    }
1526
 
1527
    public void setCustomerName(String customerName) {
1528
        this.customerName = customerName;
1529
    }
1530
 
1531
    public String getCustomerMobileNumber() {
1532
        return customerMobileNumber;
1533
    }
1534
 
1535
    public void setCustomerMobileNumber(String customerMobileNumber) {
1536
        this.customerMobileNumber = customerMobileNumber;
1537
    }
3546 mandeep.dh 1538
 
1539
    public User getUser() {
1540
        return user;
1541
    }
1542
 
1543
    public void setUser(User user) {
1544
        this.user = user;
1545
    }
1546
 
1547
    public String getOrderStatus() {
1548
        return orderStatus;
1549
    }
1550
 
1551
    public void setOrderStatus(String orderStatus) {
1552
        this.orderStatus = orderStatus;
1553
    }
1554
 
1555
    public List<Order> getOrders() {
1556
        return orders;
1557
    }
1558
 
1559
    public void setOrders(List<Order> orders) {
1560
        this.orders = orders;
1561
    }
4020 mandeep.dh 1562
 
1563
    public String getEscalate() {
1564
        return escalate;
1565
    }
1566
 
1567
    public void setEscalate(String escalate) {
1568
        this.escalate = escalate;
1569
    }
4241 anupam.sin 1570
 
1571
    public String getCancelReason() {
1572
        return cancelReason;
1573
    }
1574
 
1575
    public void setCancelReason(String cancelReason) {
1576
        this.cancelReason = cancelReason;
1577
    }
4267 anupam.sin 1578
 
1579
    public List<Payment> getPayments() {
1580
        return payments;
1581
    }
1582
 
1583
    public void setPayments(List<Payment> payments) {
1584
        this.payments = payments;
1585
    }
1586
 
1587
    public String getTransactionId() {
1588
        return transactionId;
1589
    }
1590
 
1591
    public void setTransactionId(String transactionId) {
1592
        this.transactionId = transactionId;
1593
    }
4438 anupam.sin 1594
 
1595
    public String getPaymentId() {
1596
        return paymentId;
1597
    }
1598
 
1599
    public void setPaymentId(String paymentId) {
1600
        this.paymentId = paymentId;
1601
    }
4490 anupam.sin 1602
 
1603
    public HashMap<String, String> getAllAttachmentsForTicket() {
1604
        return allAttachmentsForTicket;
1605
    }
1606
 
1607
    public void setAllAttachmentsForTicket(HashMap<String, String> allAttachmentsForTicket) {
1608
        this.allAttachmentsForTicket = allAttachmentsForTicket;
1609
    }
5791 anupam.sin 1610
 
1611
    public String getPickupExtension() {
1612
        return pickupExtension;
1613
    }
1614
 
1615
    public void setPickupExtension(String pickupExtension) {
1616
        this.pickupExtension = pickupExtension;
1617
    }
5909 amar.kumar 1618
 
1619
	public Map<String, Long> getTicketCategorycountMap() {
1620
		return ticketCategorycountMap;
1621
	}
1622
 
1623
	public void setTicketCategorycountMap(
1624
			Map<String, Long> ticketCategorycountMap) {
1625
		this.ticketCategorycountMap = ticketCategorycountMap;
1626
	}
7645 anupam.sin 1627
 
1628
    public String getPremises() {
1629
        return premises;
1630
    }
1631
 
1632
    public void setPremises(String premises) {
1633
        this.premises = premises;
1634
    }
1635
 
1636
    public String getClosureType() {
1637
        return closureType;
1638
    }
1639
 
1640
    public void setClosureType(String closureType) {
1641
        this.closureType = closureType;
1642
    }
3137 mandeep.dh 1643
}