Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
2674 vikas 1
package in.shop2020.serving.controllers;
2
 
7065 kshitij.so 3
import in.shop2020.config.ConfigException;
4689 anupam.sin 4
import in.shop2020.crm.Activity;
5
import in.shop2020.crm.ActivityType;
3578 mandeep.dh 6
import in.shop2020.crm.SearchFilter;
7
import in.shop2020.crm.Ticket;
8
import in.shop2020.crm.TicketCategory;
4689 anupam.sin 9
import in.shop2020.crm.TicketPriority;
3578 mandeep.dh 10
import in.shop2020.crm.TicketStatus;
5845 mandeep.dh 11
import in.shop2020.logistics.PickupStore;
7190 amar.kumar 12
import in.shop2020.model.v1.catalog.CatalogService;
13
import in.shop2020.model.v1.catalog.CatalogServiceException;
14
import in.shop2020.model.v1.catalog.Item;
2674 vikas 15
import in.shop2020.model.v1.order.LineItem;
16
import in.shop2020.model.v1.order.Order;
3578 mandeep.dh 17
import in.shop2020.model.v1.order.OrderStatus;
4689 anupam.sin 18
import in.shop2020.model.v1.order.TransactionServiceException;
4142 mandeep.dh 19
import in.shop2020.model.v1.user.Address;
4689 anupam.sin 20
import in.shop2020.model.v1.user.UserContextException;
2728 vikas 21
import in.shop2020.payments.Attribute;
22
import in.shop2020.payments.Constants;
2674 vikas 23
import in.shop2020.payments.Payment;
2728 vikas 24
import in.shop2020.payments.PaymentException;
4142 mandeep.dh 25
import in.shop2020.payments.PaymentService.Client;
4689 anupam.sin 26
import in.shop2020.serving.auth.CRMAuthorizingRealm;
3090 mandeep.dh 27
import in.shop2020.serving.model.ShipmentUpdate;
5845 mandeep.dh 28
import in.shop2020.serving.services.AramexTrackingService;
3090 mandeep.dh 29
import in.shop2020.serving.services.BlueDartTrackingService;
5303 phani.kuma 30
import in.shop2020.serving.services.DelhiveryTrackingService;
7200 kshitij.so 31
import in.shop2020.serving.services.RedExpressTrackingService;
3578 mandeep.dh 32
import in.shop2020.thrift.clients.CRMClient;
7190 amar.kumar 33
import in.shop2020.thrift.clients.CatalogClient;
6322 amar.kumar 34
import in.shop2020.thrift.clients.HelperClient;
5845 mandeep.dh 35
import in.shop2020.thrift.clients.LogisticsClient;
3128 rajveer 36
import in.shop2020.thrift.clients.PaymentClient;
37
import in.shop2020.thrift.clients.TransactionClient;
4142 mandeep.dh 38
import in.shop2020.thrift.clients.UserClient;
7065 kshitij.so 39
import in.shop2020.thrift.clients.config.ConfigClient;
3546 mandeep.dh 40
import in.shop2020.utils.ModelUtils;
6322 amar.kumar 41
import in.shop2020.warehouse.WarehouseService;
2674 vikas 42
 
6322 amar.kumar 43
import java.io.BufferedInputStream;
44
import java.io.File;
45
import java.io.FileInputStream;
46
import java.io.FileWriter;
47
import java.io.IOException;
48
import java.io.InputStream;
6912 anupam.sin 49
import java.text.SimpleDateFormat;
2674 vikas 50
import java.util.ArrayList;
6912 anupam.sin 51
import java.util.Calendar;
4416 mandeep.dh 52
import java.util.Collections;
6912 anupam.sin 53
import java.util.Date;
4689 anupam.sin 54
import java.util.HashSet;
2674 vikas 55
import java.util.List;
4689 anupam.sin 56
import java.util.Set;
4416 mandeep.dh 57
import java.util.concurrent.Callable;
58
import java.util.concurrent.Executors;
59
import java.util.concurrent.TimeUnit;
2674 vikas 60
 
6322 amar.kumar 61
import javax.servlet.ServletOutputStream;
62
 
4689 anupam.sin 63
import net.htmlparser.jericho.Source;
64
 
5845 mandeep.dh 65
import org.apache.commons.lang.StringUtils;
2674 vikas 66
import org.apache.log4j.Logger;
2728 vikas 67
import org.apache.thrift.TException;
4142 mandeep.dh 68
import org.apache.thrift.transport.TTransportException;
2674 vikas 69
 
70
/**
71
 * @author vikas
3578 mandeep.dh 72
 * 
2674 vikas 73
 */
74
@SuppressWarnings("serial")
75
public class UserOrderInfoController extends BaseController {
3578 mandeep.dh 76
    private static Logger                  log                     = Logger.getLogger(Class.class);
3090 mandeep.dh 77
    private static BlueDartTrackingService blueDartTrackingService = new BlueDartTrackingService();
4710 anupam.sin 78
    private static AramexTrackingService aramexTrackingService     = new AramexTrackingService();
5303 phani.kuma 79
    private static DelhiveryTrackingService delhiveryTrackingService     = new DelhiveryTrackingService();
7200 kshitij.so 80
    private static RedExpressTrackingService redexpressTrackingService = new RedExpressTrackingService();
3090 mandeep.dh 81
 
4142 mandeep.dh 82
    private long                 orderId;
83
    private Order                order;
84
    private List<Payment>        payments;
4416 mandeep.dh 85
    private List<ShipmentUpdate> shipmentUpdates = new ArrayList<ShipmentUpdate>();
4142 mandeep.dh 86
    private Long                 codTicketId;
87
    private List<Address>        addresses;
4689 anupam.sin 88
    private Set<OrderStatus>     setOfcancellableStates;
89
    private String               cancellationInitiator;
90
    private String               cancelReason;
91
    private String               body;
6985 anupam.sin 92
    private String               line1;
93
    private String               line2;
94
    private String               city;
95
    private String               state;
96
    private String               pin;
7190 amar.kumar 97
    private String				 freebieItem;
98
    private String				 dealText;
99
    private String 				 parentOrderIdForFreebieOrder;
100
    private String				 freebieOrderId;
2674 vikas 101
 
3578 mandeep.dh 102
    public UserOrderInfoController() {
2674 vikas 103
        super();
4689 anupam.sin 104
        setOfcancellableStates = new HashSet<OrderStatus>();
105
        setOfcancellableStates.add(OrderStatus.SUBMITTED_FOR_PROCESSING);
106
        setOfcancellableStates.add(OrderStatus.INVENTORY_LOW);
107
        setOfcancellableStates.add(OrderStatus.LOW_INV_PO_RAISED);
108
        setOfcancellableStates.add(OrderStatus.LOW_INV_REVERSAL_IN_PROCESS);
109
        setOfcancellableStates.add(OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT);
110
        setOfcancellableStates.add(OrderStatus.ACCEPTED);
111
        setOfcancellableStates.add(OrderStatus.BILLED);
2674 vikas 112
    }
113
 
4689 anupam.sin 114
    public String index() {
115
        try {
116
            PaymentClient paymentServiceClient = new PaymentClient();
117
            TransactionClient transactionServiceClient = new TransactionClient();
3090 mandeep.dh 118
 
3499 mandeep.dh 119
            order = transactionServiceClient.getClient().getOrder(orderId);
7190 amar.kumar 120
            if(order.getFreebieItemId()>0) {
121
            	CatalogService.Client catalogClient = new CatalogClient().getClient();
122
            	Item item = catalogClient.getItem(order.getFreebieItemId());
123
            	freebieItem = item.getBrand() + " " + item.getModelName() + " " + item.getModelNumber() + " " + item.getColor();
124
            }
125
 
126
            if(order.getLineitems().get(0).getDealText()!=null && !order.getLineitems().get(0).getDealText().isEmpty()) {
127
            	dealText = order.getLineitems().get(0).getDealText();
128
            }
129
            List<in.shop2020.model.v1.order.Attribute> attributes = 
130
            	transactionServiceClient.getClient().getAllAttributesForOrderId(orderId);
131
 
132
            for(in.shop2020.model.v1.order.Attribute attribute: attributes){
133
            	if(attribute.getName().equals("parentOrderIdForFreebie")){
134
            		parentOrderIdForFreebieOrder = attribute.getValue();
135
            	} else if (attribute.getName().equals("freebieOrderId")){
136
            		freebieOrderId = attribute.getValue();
137
            	}
138
            }
139
 
4689 anupam.sin 140
            payments = paymentServiceClient.getClient()
141
            .getPaymentForTxnId(order.getTransactionId());
3090 mandeep.dh 142
 
3578 mandeep.dh 143
 
4689 anupam.sin 144
 
145
            // Spawning a thread to capture shipment updates from Bluedart
146
            // This is done to ensure that response from Crm web app is sent
147
            // within given time limits. Also, we wont be affected in the cases 
148
            // where bluedart site is down or slow
149
            Executors.newSingleThreadExecutor().invokeAll(Collections.singletonList(new Callable<Boolean>() {
150
                public Boolean call() throws Exception {
4710 anupam.sin 151
                    if (order.getLogistics_provider_id() == 1)
152
                        shipmentUpdates = blueDartTrackingService.getUpdates(order.getAirwaybill_no());
153
                    else if (order.getLogistics_provider_id() == 2) {
154
                        shipmentUpdates = aramexTrackingService.getUpdates(order.getAirwaybill_no());
155
                    }
5303 phani.kuma 156
                    else if (order.getLogistics_provider_id() == 3) {
157
                        shipmentUpdates = delhiveryTrackingService.getUpdates(order.getAirwaybill_no());
158
                    }
7200 kshitij.so 159
                    else if (order.getLogistics_provider_id() == 6) {
160
                        shipmentUpdates = redexpressTrackingService.getUpdates(order.getAirwaybill_no());
161
                    }
4710 anupam.sin 162
                    else {
5845 mandeep.dh 163
                        shipmentUpdates = new ArrayList<ShipmentUpdate>();
4710 anupam.sin 164
                        log.error("Error : providerId = " + order.getLogistics_provider_id() + "for orderId : " + order.getId());
165
                    }
4689 anupam.sin 166
                    return true;
167
                }
7295 kshitij.so 168
            }), 60, TimeUnit.SECONDS);
4689 anupam.sin 169
 
170
            if (order.isCod() && OrderStatus.COD_VERIFICATION_PENDING.equals(order.getStatus())) {
171
                populateCODTicketId(order.getCustomer_id());
4416 mandeep.dh 172
            }
173
 
4689 anupam.sin 174
            if (canEditOrderAddress()) {
175
                userContextServiceClient = new UserClient().getClient();
176
                addresses = userContextServiceClient.getAllAddressesForUser(order.getCustomer_id());
177
            }
3578 mandeep.dh 178
 
4689 anupam.sin 179
        } catch (TTransportException e) {
180
            log.error("Unable to create thrift Client", e);
181
        } catch (TransactionServiceException e) {
182
            addActionError("Invalid order id or no order selected.");
183
        } catch (TException e) {
184
            log.error("Unable to get thrift Client", e);
185
        } catch (PaymentException e) {
186
            log.error("Unable to get payments for transctionId : " + order.getTransactionId(), e);
187
        } catch (InterruptedException e) {
188
            log.error("Thread was interrupted", e);
189
        } catch (UserContextException e) {
190
            log.error("Unable to get addresses for user : " + order.getCustomer_id(), e);
7190 amar.kumar 191
        } catch(CatalogServiceException csex) {
192
        	log.error("Unable to get item details for itemId: " + order.getFreebieItemId(), csex);
4142 mandeep.dh 193
        }
194
        return INDEX;
2674 vikas 195
    }
196
 
4142 mandeep.dh 197
    private boolean canEditOrderAddress() {
198
        return false;
199
    }
200
 
3578 mandeep.dh 201
    private void populateCODTicketId(long customerId) {
202
        try {
203
            SearchFilter searchFilter = new SearchFilter();
204
            searchFilter.setTicketCategory(TicketCategory.COD_VERIFICATION);
205
            searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
206
            searchFilter.getTicketStatuses().add(TicketStatus.OPEN);
207
            searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
208
            searchFilter.setCustomerId(customerId);
209
            crmServiceClient = new CRMClient().getClient();
210
            List<Ticket> tickets = crmServiceClient.getTickets(searchFilter);
211
            if (tickets != null && !tickets.isEmpty()) {
212
                codTicketId = tickets.get(0).getId();
213
            }
214
        } catch (TException e) {
215
            log.error("Error fetching tickets for customerId: " + customerId, e);
216
        }
217
    }
218
 
4689 anupam.sin 219
    public String markOrderForCancellation() {
220
        try{
221
            TransactionClient transactionServiceClient = new TransactionClient();
222
            log.info("URL = " + request.getRequestURI());
223
            log.info("Initiator = " + request.getParameter("cancellationInitiator"));
224
            log.info("orderId = " + request.getParameter("orderId"));
225
            if (cancellationInitiator.equals("CUSTOMER")) {
226
                order = transactionServiceClient.getClient().getOrder(orderId);
227
                transactionServiceClient.getClient().markOrderCancellationRequestReceived(orderId);
228
                long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
229
                Ticket ticket = new Ticket();
230
                String plainTextbody = "";
231
                if(body!=null && !body.isEmpty()){
232
                    plainTextbody = new Source(body).getTextExtractor().toString();
233
                }
234
                ticket.setDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
235
                ticket.setCreatorId(creatorId);
236
                ticket.setStatus(TicketStatus.OPEN);
237
                ticket.setPriority(TicketPriority.HIGH);
238
                ticket.setCategory(TicketCategory.ORDER_CANCELLATION);
239
                ticket.setOrderId(orderId);
240
 
241
                Activity activity = new Activity();
242
                activity.setDescription("Creating Ticket");
243
                activity.setType(ActivityType.OTHER);
244
                activity.setTicketPriority(TicketPriority.HIGH);
245
                activity.setTicketStatus(TicketStatus.OPEN);
246
                activity.setCreatorId(creatorId);
247
                activity.setTicketDescription("Creating ticket for Cancellation Request Received, Reason : " + cancelReason + " : " + plainTextbody);
248
                activity.setTicketCategory(TicketCategory.ORDER_CANCELLATION);
249
 
250
                ticket.setCustomerId(order.getCustomer_id());
251
                activity.setCustomerId(order.getCustomer_id());
252
                ticket.setCustomerName(order.getCustomer_name());
253
                activity.setCustomerName(order.getCustomer_name());
254
                ticket.setCustomerEmailId(order.getCustomer_email());
255
                activity.setCustomerEmailId(order.getCustomer_email());
256
                ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
257
                activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
258
 
259
                crmServiceClient = new CRMClient().getClient();
260
                crmServiceClient.insertTicket(ticket, activity);
261
            } 
262
            else if (cancellationInitiator.equals("INTERNAL")) {
263
                String plainTextbody = "";
264
                if(body!=null && !body.isEmpty()){
265
                    plainTextbody = new Source(body).getTextExtractor().toString();
266
                }
267
                transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
268
                long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
269
                Ticket ticket = new Ticket();
270
                ticket.setDescription("Creating ticket for Order Cancellation due to Low inventory");
271
                ticket.setCreatorId(creatorId);
272
                ticket.setStatus(TicketStatus.CLOSED);
273
                ticket.setPriority(TicketPriority.MEDIUM);
274
                ticket.setCategory(TicketCategory.ORDER_CANCELLATION);
275
                ticket.setOrderId(orderId);
276
 
277
                Activity activity = new Activity();
278
                activity.setDescription("Creating Ticket");
279
                activity.setType(ActivityType.OTHER);
280
                activity.setTicketPriority(TicketPriority.MEDIUM);
281
                activity.setTicketStatus(TicketStatus.CLOSED);
282
                activity.setCreatorId(creatorId);
283
                activity.setTicketCategory(TicketCategory.ORDER_CANCELLATION);
284
                activity.setTicketDescription("Creating ticket for Order Cancellation due to Low inventory");
285
 
286
                ticket.setCustomerId(order.getCustomer_id());
287
                activity.setCustomerId(order.getCustomer_id());
288
                ticket.setCustomerName(order.getCustomer_name());
289
                activity.setCustomerName(order.getCustomer_name());
290
                ticket.setCustomerEmailId(order.getCustomer_email());
291
                activity.setCustomerEmailId(order.getCustomer_email());
292
                ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
293
                activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
294
 
295
                crmServiceClient = new CRMClient().getClient();
296
                crmServiceClient.insertTicket(ticket, activity);
297
            }
298
        } catch(Exception e) {
299
            log.error("Could not mark order for Cancellation, OrderId : " + orderId, e);
300
        }
301
        return index();
302
    }
303
 
7200 kshitij.so 304
    public void getOrderConfirmationMail() throws IOException, TException, ConfigException, TransactionServiceException {
305
    	TransactionClient transactionServiceClient = new TransactionClient();
306
    	order = transactionServiceClient.getClient().getOrder(orderId);
307
    	long source = order.getTransactionId();
7221 kshitij.so 308
    	HelperClient helperClient = new HelperClient("helper_service_server","helper_service_server_port");
7200 kshitij.so 309
    	String mail = helperClient.getClient().getOrderConfirmationMail(source);
7221 kshitij.so 310
    	File file = new File("/tmp/temp");
7200 kshitij.so 311
 
6322 amar.kumar 312
    	FileWriter writer = new FileWriter(file);
313
    	writer.append(mail);
314
    	writer.close();
315
 
316
    	byte[] buffer = new byte[(int)file.length()];
317
        InputStream input = null;
318
    	try {
319
            int totalBytesRead = 0;
320
            input = new BufferedInputStream(new FileInputStream(file));
321
            while(totalBytesRead < buffer.length){
322
                int bytesRemaining = buffer.length - totalBytesRead;
323
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
324
                if (bytesRead > 0){
325
                    totalBytesRead = totalBytesRead + bytesRead;
326
                }
327
            }
328
        }
329
        finally {
330
            input.close();
331
            file.delete();
332
        }
333
 
334
 
335
    	response.setHeader("Content-disposition", "inline; filename=" + "OrderDetail_"+orderId );
336
 
337
        ServletOutputStream sos;
338
        try {
339
            sos = response.getOutputStream();
340
            sos.write(buffer);
341
            sos.flush();
342
        } catch (IOException e) {
343
            System.out.println("Unable to stream the manifest file");
344
        }   
345
    }
346
 
7221 kshitij.so 347
    public void getOrderDeliveryMail() throws IOException, TException, ConfigException, TransactionServiceException {
348
    	HelperClient helperClient = new HelperClient("helper_service_server","helper_service_server_port");
349
    	String mail = helperClient.getClient().getOrderDeliveryMail(orderId);
350
    	File file = new File("/tmp/temp");
351
 
352
    	FileWriter writer = new FileWriter(file);
353
    	writer.append(mail);
354
    	writer.close();
355
 
356
    	byte[] buffer = new byte[(int)file.length()];
357
        InputStream input = null;
358
    	try {
359
            int totalBytesRead = 0;
360
            input = new BufferedInputStream(new FileInputStream(file));
361
            while(totalBytesRead < buffer.length){
362
                int bytesRemaining = buffer.length - totalBytesRead;
363
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
364
                if (bytesRead > 0){
365
                    totalBytesRead = totalBytesRead + bytesRead;
366
                }
367
            }
368
        }
369
        finally {
370
            input.close();
371
            file.delete();
372
        }
373
 
374
 
375
    	response.setHeader("Content-disposition", "inline; filename=" + "OrderDetail_"+orderId );
376
 
377
        ServletOutputStream sos;
378
        try {
379
            sos = response.getOutputStream();
380
            sos.write(buffer);
381
            sos.flush();
382
        } catch (IOException e) {
383
            System.out.println("Unable to stream the manifest file");
384
        }   
385
    }
386
 
4689 anupam.sin 387
    public boolean canOrderBeCancelled() {
388
        if (setOfcancellableStates.contains(order.getStatus())) {
389
            return true;
390
        }
391
        return false;
392
    }
393
 
4142 mandeep.dh 394
    public String getPaymentGateway(Payment payment) {
395
        String gatewayName = "";
3578 mandeep.dh 396
 
4142 mandeep.dh 397
        try {
398
            Client paymentServiceClient = new PaymentClient().getClient();
399
            gatewayName = paymentServiceClient.getPaymentGateway(payment.getGatewayId()).getName();
400
        } catch (TTransportException e) {
401
        } catch (PaymentException e) {
402
        } catch (TException e) {
2674 vikas 403
        }
4142 mandeep.dh 404
 
405
        return gatewayName;
2674 vikas 406
    }
407
 
4142 mandeep.dh 408
    public String getProductName(LineItem lineItem) {
409
        String name = ModelUtils.extractProductNameFromLineItem(lineItem);
410
 
4146 mandeep.dh 411
        if (lineItem.getColor() != null && !lineItem.getColor().isEmpty()) {
4142 mandeep.dh 412
            name += "(" + lineItem.getColor() + ")";
2674 vikas 413
        }
4142 mandeep.dh 414
 
415
        return name;
2674 vikas 416
    }
417
 
4142 mandeep.dh 418
    public int convertDouble(double value) {
419
        return (int)value;
2674 vikas 420
    }
6912 anupam.sin 421
 
422
    public String getInsuranceExpiryDate(long DeliveryDate) {
423
        if (DeliveryDate == 0) {
424
            return "N/A";
425
        }
426
        Calendar cal = Calendar.getInstance();
427
        cal.setTimeInMillis(DeliveryDate);
428
        cal.add(Calendar.YEAR, 1);
6960 anupam.sin 429
        SimpleDateFormat sdf = new SimpleDateFormat("dd MMM, yyyy");
430
        return sdf.format(cal.getTime());
6912 anupam.sin 431
    }
3578 mandeep.dh 432
 
5845 mandeep.dh 433
    public String getShippingAddressOfStore(long storeId) {
434
        try {
435
            in.shop2020.logistics.LogisticsService.Client client = new LogisticsClient().getClient();
436
            PickupStore store = client.getPickupStore(storeId);
437
            return StringUtils.join(new String[] {
438
                    store.getName(),
439
                    store.getLine1(),
440
                    store.getLine2(),
441
                    store.getPin(),
442
                    store.getCity(),
443
                    store.getState(),
444
                    store.getPhone()}, ",");
445
        } catch (Exception e) {
446
            return "";
447
        }
448
    }
449
 
4142 mandeep.dh 450
    public String getAddress(Order order) {
451
        return ModelUtils.extractAddressFromOrder(order);
452
    }
6985 anupam.sin 453
 
454
    public String changeShippingAddress() {
455
        try {
456
            TransactionClient transactionServiceClient = new TransactionClient();
457
            transactionServiceClient.getClient().changeShippingAddress(orderId, line1, line2, city, state, pin);
458
        } catch(Exception e) {
459
            log.error("Unable to update address for orderId : " + orderId + "and address : " + 
460
                    line1 + ", " + line2+ ", " + city + ", " + state + ", " + pin, e);
461
        }
462
        return null;
463
    }
464
 
465
    public Address getShippingAddress(Order order) {
466
        Address address = new Address();
467
        address.setLine1(order.getCustomer_address1());
468
        address.setLine2(order.getCustomer_address2());
469
        address.setCity(order.getCustomer_city());
470
        address.setState(order.getCustomer_state());
471
        address.setPin(order.getCustomer_pincode());
472
        return address;
473
    }
4142 mandeep.dh 474
 
2728 vikas 475
    public String getPaymentMethod(List<Attribute> paymentAttributes) {
476
        String paymentMethod = null;
3578 mandeep.dh 477
        if (paymentAttributes == null || paymentAttributes.isEmpty()) {
2728 vikas 478
            return "N/A";
479
        }
3578 mandeep.dh 480
        for (Attribute a : paymentAttributes) {
481
            if ("payMethod".equals(a.getName())) {
2728 vikas 482
                paymentMethod = Constants.PAYMENT_METHOD.get(a.getValue());
483
                break;
484
            }
485
        }
486
        return paymentMethod != null ? paymentMethod : "N/A";
487
    }
2674 vikas 488
 
489
    public void setOrderId(String orderId) {
490
        try {
491
            this.orderId = Long.parseLong(orderId);
3578 mandeep.dh 492
        } catch (NumberFormatException e) {
2674 vikas 493
            log.error(e);
494
        }
495
    }
496
 
4142 mandeep.dh 497
    public List<Payment> getPayments() {
498
        return payments;
2674 vikas 499
    }
500
 
3090 mandeep.dh 501
    public List<ShipmentUpdate> getShipmentUpdates() {
502
        return shipmentUpdates;
503
    }
504
 
505
    public void setShipmentUpdates(List<ShipmentUpdate> shipmentUpdates) {
506
        this.shipmentUpdates = shipmentUpdates;
507
    }
3499 mandeep.dh 508
 
509
    public Order getOrder() {
510
        return order;
511
    }
512
 
513
    public void setOrder(Order order) {
514
        this.order = order;
515
    }
3578 mandeep.dh 516
 
517
    public Long getCodTicketId() {
518
        return codTicketId;
519
    }
520
 
521
    public void setCodTicketId(Long codTicketId) {
522
        this.codTicketId = codTicketId;
523
    }
4142 mandeep.dh 524
 
525
    public List<Address> getAddresses() {
526
        return addresses;
527
    }
528
 
529
    public void setAddresses(List<Address> addresses) {
530
        this.addresses = addresses;
531
    }
4241 anupam.sin 532
 
533
    public String getOrderStatusDescription(Order order) {
534
        String status = order.getStatus().getDescription();
535
 
536
        if (order.getStatus() == OrderStatus.DELIVERY_SUCCESS) {
537
            status = "Completed";
538
        }
539
 
540
        return status;
541
    }
4689 anupam.sin 542
 
543
    public String getCancellationInitiator() {
544
        return cancellationInitiator;
545
    }
546
 
547
    public void setCancellationInitiator(String cancellationInitiator) {
548
        this.cancellationInitiator = cancellationInitiator;
549
    }
550
 
551
    public String getCancelReason() {
552
        return cancelReason;
553
    }
554
 
555
    public void setCancelReason(String cancelReason) {
556
        this.cancelReason = cancelReason;
557
    }
558
 
559
    public String getBody() {
560
        return body;
561
    }
562
 
563
    public void setBody(String body) {
564
        this.body = body;
565
    }
6985 anupam.sin 566
 
567
    public String getLine1() {
568
        return line1;
569
    }
570
 
571
    public void setLine1(String line1) {
572
        this.line1 = line1;
573
    }
574
 
575
    public String getLine2() {
576
        return line2;
577
    }
578
 
579
    public void setLine2(String line2) {
580
        this.line2 = line2;
581
    }
582
 
583
    public String getCity() {
584
        return city;
585
    }
586
 
587
    public void setCity(String city) {
588
        this.city = city;
589
    }
590
 
591
    public String getState() {
592
        return state;
593
    }
594
 
595
    public void setState(String state) {
596
        this.state = state;
597
    }
598
 
599
    public String getPin() {
600
        return pin;
601
    }
602
 
603
    public void setPin(String pin) {
604
        this.pin = pin;
605
    }
7190 amar.kumar 606
 
607
	public String getFreebieItem() {
608
		return freebieItem;
609
	}
610
 
611
	public void setFreebieItem(String freebieItem) {
612
		this.freebieItem = freebieItem;
613
	}
614
 
615
	public String getDealText() {
616
		return dealText;
617
	}
618
 
619
	public void setDealText(String dealText) {
620
		this.dealText = dealText;
621
	}
622
 
623
	public String getParentOrderIdForFreebieOrder() {
624
		return parentOrderIdForFreebieOrder;
625
	}
626
 
627
	public void setParentOrderIdForFreebieOrder(String parentOrderIdForFreebieOrder) {
628
		this.parentOrderIdForFreebieOrder = parentOrderIdForFreebieOrder;
629
	}
630
 
631
	public String getFreebieOrderId() {
632
		return freebieOrderId;
633
	}
634
 
635
	public void setFreebieOrderId(String freebieOrderId) {
636
		this.freebieOrderId = freebieOrderId;
637
	}
638
 
2674 vikas 639
}