Subversion Repositories SmartDukaan

Rev

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