Subversion Repositories SmartDukaan

Rev

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