| 2895 |
chandransh |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.order.Order;
|
|
|
4 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
5 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 3126 |
rajveer |
6 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 2895 |
chandransh |
7 |
|
|
|
8 |
import java.text.SimpleDateFormat;
|
| 3014 |
chandransh |
9 |
import java.util.Arrays;
|
| 2895 |
chandransh |
10 |
import java.util.Collections;
|
|
|
11 |
import java.util.Date;
|
|
|
12 |
import java.util.List;
|
|
|
13 |
|
|
|
14 |
import org.apache.log4j.Logger;
|
|
|
15 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
16 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
|
|
17 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
18 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
19 |
|
|
|
20 |
@SuppressWarnings("serial")
|
|
|
21 |
@InterceptorRefs({
|
|
|
22 |
@InterceptorRef("myDefault"),
|
|
|
23 |
@InterceptorRef("login")
|
|
|
24 |
})
|
|
|
25 |
|
|
|
26 |
@Results({
|
|
|
27 |
@Result(name="redirect", type="redirectAction",
|
|
|
28 |
params = {"actionName" , "login"})
|
|
|
29 |
})
|
|
|
30 |
public class FailedOrdersController extends BaseController {
|
|
|
31 |
private static Logger logger = Logger.getLogger(FailedOrdersController.class);
|
| 3121 |
chandransh |
32 |
private static final List<OrderStatus> statuses = Arrays.asList(
|
|
|
33 |
new OrderStatus[] {
|
|
|
34 |
OrderStatus.PAYMENT_FAILED,
|
| 4684 |
rajveer |
35 |
OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 3121 |
chandransh |
36 |
OrderStatus.REJECTED,
|
|
|
37 |
OrderStatus.DOA_INVALID_REFUNDED,
|
|
|
38 |
OrderStatus.DOA_INVALID_RESHIPPED,
|
|
|
39 |
OrderStatus.DOA_VALID_REFUNDED,
|
| 4452 |
rajveer |
40 |
OrderStatus.DOA_VALID_RESHIPPED,
|
| 4484 |
rajveer |
41 |
OrderStatus.RTO_REFUNDED,
|
|
|
42 |
OrderStatus.RTO_RESHIPPED
|
| 3121 |
chandransh |
43 |
}
|
|
|
44 |
);
|
| 3014 |
chandransh |
45 |
|
| 2895 |
chandransh |
46 |
private FormattingUtils formattingUtils = new FormattingUtils();
|
| 3014 |
chandransh |
47 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
| 2895 |
chandransh |
48 |
List<Order> orders = null;
|
|
|
49 |
|
|
|
50 |
public String index(){
|
|
|
51 |
logger.info("this.request=" + this.request);
|
|
|
52 |
|
|
|
53 |
try {
|
| 3126 |
rajveer |
54 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 2895 |
chandransh |
55 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
|
| 3014 |
chandransh |
56 |
|
|
|
57 |
orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), statuses);
|
| 2895 |
chandransh |
58 |
//Reverse the list of order. Last come should be displayed first.
|
|
|
59 |
Collections.reverse(orders);
|
|
|
60 |
} catch (Exception e) {
|
|
|
61 |
logger.error("Unable to get the failed orders of the customer", e);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
return "index";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public String formatPrice(double price) {
|
|
|
68 |
return formattingUtils.formatPrice(price);
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public List<Order> getOrders() {
|
|
|
72 |
return orders;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public String getOrderCreationDate(Order order){
|
|
|
76 |
Date orderedOn = new Date(order.getCreated_timestamp());
|
|
|
77 |
return dateformat.format(orderedOn);
|
|
|
78 |
}
|
|
|
79 |
}
|