Subversion Repositories SmartDukaan

Rev

Rev 16650 | Rev 17080 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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