Subversion Repositories SmartDukaan

Rev

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