Subversion Repositories SmartDukaan

Rev

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