| 6111 |
anupam.sin |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
|
|
3 |
import java.text.SimpleDateFormat;
|
|
|
4 |
import java.util.ArrayList;
|
|
|
5 |
import java.util.Arrays;
|
|
|
6 |
import java.util.Collections;
|
|
|
7 |
import java.util.Date;
|
|
|
8 |
import java.util.HashMap;
|
|
|
9 |
import java.util.List;
|
|
|
10 |
import java.util.Map;
|
|
|
11 |
|
|
|
12 |
import in.shop2020.logistics.Provider;
|
|
|
13 |
import in.shop2020.model.v1.order.Order;
|
|
|
14 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
15 |
import in.shop2020.model.v1.order.OrderStatusGroups;
|
|
|
16 |
import in.shop2020.model.v1.order.RechargeOrder;
|
|
|
17 |
import in.shop2020.serving.utils.FormattingUtils;
|
|
|
18 |
import in.shop2020.thrift.clients.LogisticsClient;
|
|
|
19 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
20 |
|
|
|
21 |
import org.apache.log4j.Logger;
|
|
|
22 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
23 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
|
|
24 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
25 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* @author rajveer
|
|
|
29 |
*
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
@SuppressWarnings("serial")
|
|
|
33 |
@InterceptorRefs({
|
|
|
34 |
@InterceptorRef("myDefault"),
|
|
|
35 |
@InterceptorRef("login")
|
|
|
36 |
})
|
|
|
37 |
|
|
|
38 |
@Results({
|
|
|
39 |
@Result(name="redirect", type="redirectAction",
|
|
|
40 |
params = {"actionName" , "login"})
|
|
|
41 |
})
|
|
|
42 |
public class MyRechargesController extends BaseController {
|
|
|
43 |
|
|
|
44 |
private static Logger logger = Logger.getLogger(Class.class);
|
|
|
45 |
|
|
|
46 |
private FormattingUtils formattingUtils = new FormattingUtils();
|
|
|
47 |
|
|
|
48 |
Map<Long, String> providerNames = new HashMap<Long, String>();
|
|
|
49 |
List<RechargeOrder> rechargeOrders = null;
|
|
|
50 |
List<String> orderDate = new ArrayList<String>();
|
|
|
51 |
|
|
|
52 |
// private static final OrderStatusGroups statusGroup = new OrderStatusGroups();
|
|
|
53 |
//private static final List<OrderStatus> openOrderStatuses = statusGroup.getOpenOrders();
|
|
|
54 |
//private static final List<OrderStatus> shippedOrderStatuses = statusGroup.getShippedOrders();
|
|
|
55 |
|
|
|
56 |
public MyRechargesController() {
|
|
|
57 |
super();
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public String index(){
|
|
|
61 |
logger.info("this.request=" + this.request);
|
|
|
62 |
|
|
|
63 |
try {
|
|
|
64 |
TransactionClient transactionServiceClient = new TransactionClient();
|
|
|
65 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
|
|
|
66 |
rechargeOrders = orderClient.getRechargeOrders(userinfo.getUserId());
|
|
|
67 |
//Reverse the list of order. Last come first displayed
|
|
|
68 |
Collections.reverse(rechargeOrders);
|
|
|
69 |
//LogisticsClient logisticsServiceClient = new LogisticsClient();
|
|
|
70 |
//in.shop2020.logistics.LogisticsService.Client logisticsClient = logisticsServiceClient.getClient();
|
|
|
71 |
//List<Provider> providers = logisticsClient.getAllProviders();
|
|
|
72 |
|
|
|
73 |
//for(Provider provider: providers)
|
|
|
74 |
// providerNames.put(provider.getId(), provider.getName());
|
|
|
75 |
|
|
|
76 |
} catch (Exception e) {
|
|
|
77 |
logger.error("Error while getting the recharge orders for the user", e);
|
|
|
78 |
}
|
|
|
79 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
|
|
80 |
|
|
|
81 |
if(rechargeOrders != null && !rechargeOrders.isEmpty()){
|
|
|
82 |
for(RechargeOrder rechargeOrder: rechargeOrders) {
|
|
|
83 |
Date orderedOn = new Date(rechargeOrder.getCreationTimestamp());
|
|
|
84 |
orderDate.add(dateformat.format(orderedOn));
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
return "index";
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public String formatDate(long timestamp){
|
|
|
91 |
Date date = new Date(timestamp);
|
|
|
92 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
|
|
93 |
return dateformat.format(date);
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
public List<RechargeOrder> getRechargeOrders() {
|
|
|
97 |
return rechargeOrders;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public List<String> getOrderDate() {
|
|
|
101 |
return orderDate;
|
|
|
102 |
}
|
|
|
103 |
}
|