| 405 |
rajveer |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 2191 |
varun.gupt |
3 |
import java.text.SimpleDateFormat;
|
|
|
4 |
import java.util.ArrayList;
|
| 2355 |
rajveer |
5 |
import java.util.Collections;
|
| 2191 |
varun.gupt |
6 |
import java.util.Date;
|
|
|
7 |
import java.util.HashMap;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
import java.util.Map;
|
|
|
10 |
|
|
|
11 |
import in.shop2020.logistics.Provider;
|
|
|
12 |
import in.shop2020.model.v1.order.Order;
|
|
|
13 |
import in.shop2020.serving.utils.FormattingUtils;
|
|
|
14 |
import in.shop2020.thrift.clients.LogisticsServiceClient;
|
|
|
15 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
|
|
16 |
|
| 832 |
rajveer |
17 |
import org.apache.log4j.Logger;
|
| 781 |
vikas |
18 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
19 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 413 |
rajveer |
20 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
21 |
import org.apache.struts2.convention.annotation.Results;
|
| 405 |
rajveer |
22 |
|
|
|
23 |
/**
|
| 413 |
rajveer |
24 |
* @author rajveer
|
| 405 |
rajveer |
25 |
*
|
|
|
26 |
*/
|
| 413 |
rajveer |
27 |
|
| 781 |
vikas |
28 |
@InterceptorRefs({
|
| 822 |
vikas |
29 |
@InterceptorRef("myDefault"),
|
|
|
30 |
@InterceptorRef("login")
|
| 781 |
vikas |
31 |
})
|
|
|
32 |
|
| 637 |
rajveer |
33 |
@Results({
|
|
|
34 |
@Result(name="redirect", type="redirectAction",
|
|
|
35 |
params = {"actionName" , "login"})
|
|
|
36 |
})
|
| 650 |
rajveer |
37 |
public class MyaccountController extends BaseController {
|
| 405 |
rajveer |
38 |
|
| 650 |
rajveer |
39 |
private static final long serialVersionUID = 1L;
|
| 2897 |
chandransh |
40 |
private static Logger logger = Logger.getLogger(Class.class);
|
| 2191 |
varun.gupt |
41 |
private FormattingUtils formattingUtils = new FormattingUtils();
|
| 650 |
rajveer |
42 |
|
| 2191 |
varun.gupt |
43 |
Map<Long, String> providerNames = new HashMap<Long, String>();
|
|
|
44 |
List<Order> orders = null;
|
|
|
45 |
List<String> orderDate = new ArrayList<String>();
|
| 405 |
rajveer |
46 |
|
|
|
47 |
public MyaccountController() {
|
|
|
48 |
super();
|
|
|
49 |
}
|
| 650 |
rajveer |
50 |
|
|
|
51 |
public String index(){
|
| 2897 |
chandransh |
52 |
logger.info("this.request=" + this.request);
|
| 650 |
rajveer |
53 |
|
| 2191 |
varun.gupt |
54 |
try {
|
|
|
55 |
TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
|
|
|
56 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
|
|
|
57 |
orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
|
| 2355 |
rajveer |
58 |
//Reverse the list of order. Last come first displayed
|
|
|
59 |
Collections.reverse(orders);
|
| 2191 |
varun.gupt |
60 |
LogisticsServiceClient logisticsServiceClient = new LogisticsServiceClient();
|
|
|
61 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = logisticsServiceClient.getClient();
|
|
|
62 |
List<Provider> providers = logisticsClient.getAllProviders();
|
|
|
63 |
|
|
|
64 |
for(Provider provider: providers)
|
|
|
65 |
providerNames.put(provider.getId(), provider.getName());
|
|
|
66 |
|
|
|
67 |
} catch (Exception e) {
|
| 2897 |
chandransh |
68 |
logger.error("Error while getting the orders for the user", e);
|
| 2191 |
varun.gupt |
69 |
}
|
|
|
70 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
|
|
71 |
|
|
|
72 |
if(orders != null && !orders.isEmpty()){
|
|
|
73 |
for(Order order: orders) {
|
|
|
74 |
Date orderedOn = new Date(order.getCreated_timestamp());
|
|
|
75 |
orderDate.add(dateformat.format(orderedOn));
|
|
|
76 |
}
|
|
|
77 |
}
|
| 650 |
rajveer |
78 |
return "index";
|
| 405 |
rajveer |
79 |
}
|
|
|
80 |
|
| 2191 |
varun.gupt |
81 |
public String formatPrice(double price) {
|
|
|
82 |
return formattingUtils.formatPrice(price);
|
|
|
83 |
}
|
| 507 |
rajveer |
84 |
|
| 2191 |
varun.gupt |
85 |
public Map<Long, String> getProviderNames() {
|
|
|
86 |
return providerNames;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public List<Order> getOrders() {
|
|
|
90 |
return orders;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public List<String> getOrderDate() {
|
|
|
94 |
return orderDate;
|
|
|
95 |
}
|
|
|
96 |
}
|