Subversion Repositories SmartDukaan

Rev

Rev 7295 | Rev 7393 | 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 {
7372 kshitij.so 76
	private static Logger                  log                     = Logger.getLogger(Class.class);
77
	private static BlueDartTrackingService blueDartTrackingService = new BlueDartTrackingService();
78
	private static AramexTrackingService aramexTrackingService     = new AramexTrackingService();
79
	private static DelhiveryTrackingService delhiveryTrackingService     = new DelhiveryTrackingService();
80
	private static RedExpressTrackingService redexpressTrackingService = new RedExpressTrackingService();
3090 mandeep.dh 81
 
7372 kshitij.so 82
	private long                 orderId;
83
	private Order                order;
84
	private List<Payment>        payments;
85
	private List<ShipmentUpdate> shipmentUpdates = new ArrayList<ShipmentUpdate>();
86
	private Long                 codTicketId;
87
	private List<Address>        addresses;
88
	private Set<OrderStatus>     setOfcancellableStates;
89
	private String               cancellationInitiator;
90
	private String               cancelReason;
91
	private String               body;
92
	private String               line1;
93
	private String               line2;
94
	private String               city;
95
	private String               state;
96
	private String               pin;
97
	private String				 freebieItem;
98
	private String				 dealText;
99
	private String 				 parentOrderIdForFreebieOrder;
100
	private String				 freebieOrderId;
2674 vikas 101
 
7372 kshitij.so 102
	public UserOrderInfoController() {
103
		super();
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);
112
	}
2674 vikas 113
 
7372 kshitij.so 114
	public String index() {
115
		try {
116
			PaymentClient paymentServiceClient = new PaymentClient();
117
			TransactionClient transactionServiceClient = new TransactionClient();
3090 mandeep.dh 118
 
7372 kshitij.so 119
			order = transactionServiceClient.getClient().getOrder(orderId);
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
			}
3090 mandeep.dh 125
 
7372 kshitij.so 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);
3578 mandeep.dh 131
 
7372 kshitij.so 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
			}
4689 anupam.sin 139
 
7372 kshitij.so 140
			payments = paymentServiceClient.getClient()
141
			.getPaymentForTxnId(order.getTransactionId());
4689 anupam.sin 142
 
4416 mandeep.dh 143
 
3578 mandeep.dh 144
 
7372 kshitij.so 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 {
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
					}
156
					else if (order.getLogistics_provider_id() == 3) {
157
						shipmentUpdates = delhiveryTrackingService.getUpdates(order.getAirwaybill_no());
158
					}
159
					else if (order.getLogistics_provider_id() == 6) {
160
						shipmentUpdates = redexpressTrackingService.getUpdates(order.getAirwaybill_no());
161
					}
162
					else {
163
						shipmentUpdates = new ArrayList<ShipmentUpdate>();
164
						log.error("Error : providerId = " + order.getLogistics_provider_id() + "for orderId : " + order.getId());
165
					}
166
					return true;
167
				}
168
			}), 60, TimeUnit.SECONDS);
2674 vikas 169
 
7372 kshitij.so 170
			if (order.isCod() && OrderStatus.COD_VERIFICATION_PENDING.equals(order.getStatus())) {
171
				populateCODTicketId(order.getCustomer_id());
172
			}
4142 mandeep.dh 173
 
7372 kshitij.so 174
			if (canEditOrderAddress()) {
175
				userContextServiceClient = new UserClient().getClient();
176
				addresses = userContextServiceClient.getAllAddressesForUser(order.getCustomer_id());
177
			}
3578 mandeep.dh 178
 
7372 kshitij.so 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);
191
		} catch(CatalogServiceException csex) {
192
			log.error("Unable to get item details for itemId: " + order.getFreebieItemId(), csex);
193
		}
194
		return INDEX;
195
	}
4689 anupam.sin 196
 
7372 kshitij.so 197
	private boolean canEditOrderAddress() {
198
		return false;
199
	}
4689 anupam.sin 200
 
7372 kshitij.so 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
	}
4689 anupam.sin 218
 
7372 kshitij.so 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);
4689 anupam.sin 240
 
7372 kshitij.so 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);
4689 anupam.sin 249
 
7372 kshitij.so 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());
4689 anupam.sin 258
 
7372 kshitij.so 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
				boolean status_returned = transactionServiceClient.getClient().refundOrder(orderId, currentAgentEmailId, cancelReason + " : " + plainTextbody);
268
				if (status_returned) {
269
					order = transactionServiceClient.getClient().getOrder(orderId);
270
					long creatorId = CRMAuthorizingRealm.getAgent(currentAgentEmailId).getId();
271
					Ticket ticket = new Ticket();
272
					ticket.setDescription("Creating ticket for Order Cancellation due to Low inventory");
273
					ticket.setCreatorId(creatorId);
274
					ticket.setAssigneeId(36);
275
					ticket.setStatus(TicketStatus.OPEN);
276
					ticket.setPriority(TicketPriority.MEDIUM);
277
					ticket.setCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
278
					ticket.setOrderId(orderId);
279
					ticket.setCustomerId(order.getCustomer_id());
280
					ticket.setCustomerName(order.getCustomer_name());
281
					ticket.setCustomerEmailId(order.getCustomer_email());
282
					ticket.setCustomerMobileNumber(order.getCustomer_mobilenumber());
6322 amar.kumar 283
 
7372 kshitij.so 284
					Activity activity = new Activity();
285
					activity.setDescription("Creating Ticket");
286
					activity.setType(ActivityType.OTHER);
287
					activity.setTicketPriority(TicketPriority.MEDIUM);
288
					activity.setTicketStatus(TicketStatus.OPEN);
289
					activity.setCreatorId(creatorId);
290
					activity.setTicketAssigneeId(36);
291
					activity.setTicketCategory(TicketCategory.LOW_INVENTORY_CANCELLED_ORDERS);
292
					activity.setTicketDescription("Creating ticket for Order Cancellation due to Low inventory");
293
					activity.setCustomerId(order.getCustomer_id());
294
					activity.setCustomerName(order.getCustomer_name());
295
					activity.setCustomerEmailId(order.getCustomer_email());
296
					activity.setCustomerMobileNumber(order.getCustomer_mobilenumber());
6322 amar.kumar 297
 
7372 kshitij.so 298
					crmServiceClient = new CRMClient().getClient();
299
					crmServiceClient.insertTicket(ticket, activity);
300
				}
301
			}
302
		} catch(Exception e) {
303
			log.error("Could not mark order for Cancellation, OrderId : " + orderId, e);
304
		}
305
		return index();
306
	}
7221 kshitij.so 307
 
7372 kshitij.so 308
	public void getOrderConfirmationMail() throws IOException, TException, ConfigException, TransactionServiceException {
309
		TransactionClient transactionServiceClient = new TransactionClient();
310
		order = transactionServiceClient.getClient().getOrder(orderId);
311
		long source = order.getTransactionId();
312
		HelperClient helperClient = new HelperClient("helper_service_server","helper_service_server_port");
313
		String mail = helperClient.getClient().getOrderConfirmationMail(source);
314
		File file = new File("/tmp/temp");
7221 kshitij.so 315
 
7372 kshitij.so 316
		FileWriter writer = new FileWriter(file);
317
		writer.append(mail);
318
		writer.close();
4689 anupam.sin 319
 
7372 kshitij.so 320
		byte[] buffer = new byte[(int)file.length()];
321
		InputStream input = null;
322
		try {
323
			int totalBytesRead = 0;
324
			input = new BufferedInputStream(new FileInputStream(file));
325
			while(totalBytesRead < buffer.length){
326
				int bytesRemaining = buffer.length - totalBytesRead;
327
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
328
				if (bytesRead > 0){
329
					totalBytesRead = totalBytesRead + bytesRead;
330
				}
331
			}
332
		}
333
		finally {
334
			input.close();
335
			file.delete();
336
		}
3578 mandeep.dh 337
 
4142 mandeep.dh 338
 
7372 kshitij.so 339
		response.setHeader("Content-disposition", "inline; filename=" + "OrderDetail_"+orderId );
2674 vikas 340
 
7372 kshitij.so 341
		ServletOutputStream sos;
342
		try {
343
			sos = response.getOutputStream();
344
			sos.write(buffer);
345
			sos.flush();
346
		} catch (IOException e) {
347
			System.out.println("Unable to stream the manifest file");
348
		}   
349
	}
4142 mandeep.dh 350
 
7372 kshitij.so 351
	public void getOrderDeliveryMail() throws IOException, TException, ConfigException, TransactionServiceException {
352
		HelperClient helperClient = new HelperClient("helper_service_server","helper_service_server_port");
353
		String mail = helperClient.getClient().getOrderDeliveryMail(orderId);
354
		File file = new File("/tmp/temp");
4142 mandeep.dh 355
 
7372 kshitij.so 356
		FileWriter writer = new FileWriter(file);
357
		writer.append(mail);
358
		writer.close();
2674 vikas 359
 
7372 kshitij.so 360
		byte[] buffer = new byte[(int)file.length()];
361
		InputStream input = null;
362
		try {
363
			int totalBytesRead = 0;
364
			input = new BufferedInputStream(new FileInputStream(file));
365
			while(totalBytesRead < buffer.length){
366
				int bytesRemaining = buffer.length - totalBytesRead;
367
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
368
				if (bytesRead > 0){
369
					totalBytesRead = totalBytesRead + bytesRead;
370
				}
371
			}
372
		}
373
		finally {
374
			input.close();
375
			file.delete();
376
		}
3578 mandeep.dh 377
 
5845 mandeep.dh 378
 
7372 kshitij.so 379
		response.setHeader("Content-disposition", "inline; filename=" + "OrderDetail_"+orderId );
4142 mandeep.dh 380
 
7372 kshitij.so 381
		ServletOutputStream sos;
382
		try {
383
			sos = response.getOutputStream();
384
			sos.write(buffer);
385
			sos.flush();
386
		} catch (IOException e) {
387
			System.out.println("Unable to stream the manifest file");
388
		}   
389
	}
2674 vikas 390
 
7372 kshitij.so 391
	public boolean canOrderBeCancelled() {
392
		if (setOfcancellableStates.contains(order.getStatus())) {
393
			return true;
394
		}
395
		return false;
396
	}
2674 vikas 397
 
7372 kshitij.so 398
	public String getPaymentGateway(Payment payment) {
399
		String gatewayName = "";
2674 vikas 400
 
7372 kshitij.so 401
		try {
402
			Client paymentServiceClient = new PaymentClient().getClient();
403
			gatewayName = paymentServiceClient.getPaymentGateway(payment.getGatewayId()).getName();
404
		} catch (TTransportException e) {
405
		} catch (PaymentException e) {
406
		} catch (TException e) {
407
		}
3090 mandeep.dh 408
 
7372 kshitij.so 409
		return gatewayName;
410
	}
3499 mandeep.dh 411
 
7372 kshitij.so 412
	public String getProductName(LineItem lineItem) {
413
		String name = ModelUtils.extractProductNameFromLineItem(lineItem);
3499 mandeep.dh 414
 
7372 kshitij.so 415
		if (lineItem.getColor() != null && !lineItem.getColor().isEmpty()) {
416
			name += "(" + lineItem.getColor() + ")";
417
		}
3578 mandeep.dh 418
 
7372 kshitij.so 419
		return name;
420
	}
3578 mandeep.dh 421
 
7372 kshitij.so 422
	public int convertDouble(double value) {
423
		return (int)value;
424
	}
4142 mandeep.dh 425
 
7372 kshitij.so 426
	public String getInsuranceExpiryDate(long DeliveryDate) {
427
		if (DeliveryDate == 0) {
428
			return "N/A";
429
		}
430
		Calendar cal = Calendar.getInstance();
431
		cal.setTimeInMillis(DeliveryDate);
432
		cal.add(Calendar.YEAR, 1);
433
		SimpleDateFormat sdf = new SimpleDateFormat("dd MMM, yyyy");
434
		return sdf.format(cal.getTime());
435
	}
4142 mandeep.dh 436
 
7372 kshitij.so 437
	public String getShippingAddressOfStore(long storeId) {
438
		try {
439
			in.shop2020.logistics.LogisticsService.Client client = new LogisticsClient().getClient();
440
			PickupStore store = client.getPickupStore(storeId);
441
			return StringUtils.join(new String[] {
442
					store.getName(),
443
					store.getLine1(),
444
					store.getLine2(),
445
					store.getPin(),
446
					store.getCity(),
447
					store.getState(),
448
					store.getPhone()}, ",");
449
		} catch (Exception e) {
450
			return "";
451
		}
452
	}
4241 anupam.sin 453
 
7372 kshitij.so 454
	public String getAddress(Order order) {
455
		return ModelUtils.extractAddressFromOrder(order);
456
	}
4241 anupam.sin 457
 
7372 kshitij.so 458
	public String changeShippingAddress() {
459
		try {
460
			TransactionClient transactionServiceClient = new TransactionClient();
461
			transactionServiceClient.getClient().changeShippingAddress(orderId, line1, line2, city, state, pin);
462
		} catch(Exception e) {
463
			log.error("Unable to update address for orderId : " + orderId + "and address : " + 
464
					line1 + ", " + line2+ ", " + city + ", " + state + ", " + pin, e);
465
		}
466
		return null;
467
	}
4689 anupam.sin 468
 
7372 kshitij.so 469
	public Address getShippingAddress(Order order) {
470
		Address address = new Address();
471
		address.setLine1(order.getCustomer_address1());
472
		address.setLine2(order.getCustomer_address2());
473
		address.setCity(order.getCustomer_city());
474
		address.setState(order.getCustomer_state());
475
		address.setPin(order.getCustomer_pincode());
476
		return address;
477
	}
4689 anupam.sin 478
 
7372 kshitij.so 479
	public String getPaymentMethod(List<Attribute> paymentAttributes) {
480
		String paymentMethod = null;
481
		if (paymentAttributes == null || paymentAttributes.isEmpty()) {
482
			return "N/A";
483
		}
484
		for (Attribute a : paymentAttributes) {
485
			if ("payMethod".equals(a.getName())) {
486
				paymentMethod = Constants.PAYMENT_METHOD.get(a.getValue());
487
				break;
488
			}
489
		}
490
		return paymentMethod != null ? paymentMethod : "N/A";
491
	}
4689 anupam.sin 492
 
7372 kshitij.so 493
	public void setOrderId(String orderId) {
494
		try {
495
			this.orderId = Long.parseLong(orderId);
496
		} catch (NumberFormatException e) {
497
			log.error(e);
498
		}
499
	}
4689 anupam.sin 500
 
7372 kshitij.so 501
	public List<Payment> getPayments() {
502
		return payments;
503
	}
4689 anupam.sin 504
 
7372 kshitij.so 505
	public List<ShipmentUpdate> getShipmentUpdates() {
506
		return shipmentUpdates;
507
	}
4689 anupam.sin 508
 
7372 kshitij.so 509
	public void setShipmentUpdates(List<ShipmentUpdate> shipmentUpdates) {
510
		this.shipmentUpdates = shipmentUpdates;
511
	}
6985 anupam.sin 512
 
7372 kshitij.so 513
	public Order getOrder() {
514
		return order;
515
	}
6985 anupam.sin 516
 
7372 kshitij.so 517
	public void setOrder(Order order) {
518
		this.order = order;
519
	}
6985 anupam.sin 520
 
7372 kshitij.so 521
	public Long getCodTicketId() {
522
		return codTicketId;
523
	}
6985 anupam.sin 524
 
7372 kshitij.so 525
	public void setCodTicketId(Long codTicketId) {
526
		this.codTicketId = codTicketId;
527
	}
6985 anupam.sin 528
 
7372 kshitij.so 529
	public List<Address> getAddresses() {
530
		return addresses;
531
	}
6985 anupam.sin 532
 
7372 kshitij.so 533
	public void setAddresses(List<Address> addresses) {
534
		this.addresses = addresses;
535
	}
6985 anupam.sin 536
 
7372 kshitij.so 537
	public String getOrderStatusDescription(Order order) {
538
		String status = order.getStatus().getDescription();
6985 anupam.sin 539
 
7372 kshitij.so 540
		if (order.getStatus() == OrderStatus.DELIVERY_SUCCESS) {
541
			status = "Completed";
542
		}
6985 anupam.sin 543
 
7372 kshitij.so 544
		return status;
545
	}
6985 anupam.sin 546
 
7372 kshitij.so 547
	public String getCancellationInitiator() {
548
		return cancellationInitiator;
549
	}
7190 amar.kumar 550
 
7372 kshitij.so 551
	public void setCancellationInitiator(String cancellationInitiator) {
552
		this.cancellationInitiator = cancellationInitiator;
553
	}
554
 
555
	public String getCancelReason() {
556
		return cancelReason;
557
	}
558
 
559
	public void setCancelReason(String cancelReason) {
560
		this.cancelReason = cancelReason;
561
	}
562
 
563
	public String getBody() {
564
		return body;
565
	}
566
 
567
	public void setBody(String body) {
568
		this.body = body;
569
	}
570
 
571
	public String getLine1() {
572
		return line1;
573
	}
574
 
575
	public void setLine1(String line1) {
576
		this.line1 = line1;
577
	}
578
 
579
	public String getLine2() {
580
		return line2;
581
	}
582
 
583
	public void setLine2(String line2) {
584
		this.line2 = line2;
585
	}
586
 
587
	public String getCity() {
588
		return city;
589
	}
590
 
591
	public void setCity(String city) {
592
		this.city = city;
593
	}
594
 
595
	public String getState() {
596
		return state;
597
	}
598
 
599
	public void setState(String state) {
600
		this.state = state;
601
	}
602
 
603
	public String getPin() {
604
		return pin;
605
	}
606
 
607
	public void setPin(String pin) {
608
		this.pin = pin;
609
	}
610
 
7190 amar.kumar 611
	public String getFreebieItem() {
612
		return freebieItem;
613
	}
614
 
615
	public void setFreebieItem(String freebieItem) {
616
		this.freebieItem = freebieItem;
617
	}
618
 
619
	public String getDealText() {
620
		return dealText;
621
	}
622
 
623
	public void setDealText(String dealText) {
624
		this.dealText = dealText;
625
	}
626
 
627
	public String getParentOrderIdForFreebieOrder() {
628
		return parentOrderIdForFreebieOrder;
629
	}
630
 
631
	public void setParentOrderIdForFreebieOrder(String parentOrderIdForFreebieOrder) {
632
		this.parentOrderIdForFreebieOrder = parentOrderIdForFreebieOrder;
633
	}
634
 
635
	public String getFreebieOrderId() {
636
		return freebieOrderId;
637
	}
638
 
639
	public void setFreebieOrderId(String freebieOrderId) {
640
		this.freebieOrderId = freebieOrderId;
641
	}
7372 kshitij.so 642
 
2674 vikas 643
}