Subversion Repositories SmartDukaan

Rev

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