Subversion Repositories SmartDukaan

Rev

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