Subversion Repositories SmartDukaan

Rev

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