| 7082 |
rajveer |
1 |
package in.shop2020.recharge.controllers;
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
|
|
5 |
import in.shop2020.model.v1.order.RechargePlan;
|
|
|
6 |
import in.shop2020.model.v1.order.RechargeStatistics;
|
|
|
7 |
import in.shop2020.model.v1.order.RechargeTransaction;
|
|
|
8 |
import in.shop2020.model.v1.order.RechargeType;
|
|
|
9 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
10 |
|
|
|
11 |
import java.text.DateFormat;
|
|
|
12 |
import java.text.SimpleDateFormat;
|
|
|
13 |
import java.util.Calendar;
|
|
|
14 |
import java.util.HashMap;
|
|
|
15 |
import java.util.List;
|
|
|
16 |
import java.util.Map;
|
|
|
17 |
import java.util.Map.Entry;
|
|
|
18 |
|
|
|
19 |
import javax.servlet.ServletContext;
|
|
|
20 |
import javax.servlet.http.HttpServletRequest;
|
|
|
21 |
import javax.servlet.http.HttpSession;
|
|
|
22 |
|
|
|
23 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
24 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
|
|
25 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
26 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
27 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
28 |
import org.apache.struts2.util.ServletContextAware;
|
|
|
29 |
import org.slf4j.Logger;
|
|
|
30 |
import org.slf4j.LoggerFactory;
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
public class ReportController implements ServletRequestAware, ServletContextAware {
|
|
|
35 |
|
|
|
36 |
private static Logger logger = LoggerFactory.getLogger(ReportController.class);
|
|
|
37 |
|
|
|
38 |
private HttpServletRequest request;
|
|
|
39 |
private HttpSession session;
|
|
|
40 |
private ServletContext context;
|
|
|
41 |
|
|
|
42 |
private TransactionClient tsc;
|
|
|
43 |
private in.shop2020.model.v1.order.TransactionService.Client tClient;
|
|
|
44 |
|
|
|
45 |
private final DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
|
|
|
46 |
|
|
|
47 |
private List<RechargeTransaction> txns = null;
|
|
|
48 |
public ReportController(){
|
|
|
49 |
try {
|
|
|
50 |
tsc = new TransactionClient();
|
|
|
51 |
tClient = tsc.getClient();
|
|
|
52 |
} catch (Exception e) {
|
|
|
53 |
logger.error("Error connecting to one of the user, order or payment service", e);
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
|
| 7087 |
rajveer |
58 |
public String index() throws Exception{
|
| 7096 |
anupam.sin |
59 |
String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
|
|
|
60 |
if(loginStatus == null || !loginStatus.equals("TRUE")){
|
|
|
61 |
return "authfail";
|
|
|
62 |
}
|
|
|
63 |
txns = tClient.getRechargeTransactions(Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
|
| 7082 |
rajveer |
64 |
return "index";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
public String getDateTime(long milliseconds) {
|
|
|
69 |
Calendar cal = Calendar.getInstance();
|
|
|
70 |
cal.setTimeInMillis(milliseconds);
|
|
|
71 |
return formatter.format(cal.getTime());
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public List<RechargeTransaction> getTxns(){
|
|
|
75 |
return txns;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
@Override
|
|
|
79 |
public void setServletRequest(HttpServletRequest req) {
|
|
|
80 |
this.request = req;
|
|
|
81 |
this.session = req.getSession();
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
@Override
|
|
|
85 |
public void setServletContext(ServletContext context) {
|
|
|
86 |
this.context = context;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public String getServletContextPath() {
|
|
|
90 |
return context.getContextPath();
|
|
|
91 |
}
|
| 7096 |
anupam.sin |
92 |
|
|
|
93 |
public String getOperatorName(long operatorId) {
|
|
|
94 |
String operatorName = "";
|
|
|
95 |
if (HomeController.getMobileProvidersMap().containsKey(operatorId)) {
|
|
|
96 |
operatorName = HomeController.getMobileProvidersMap().get(operatorId);
|
|
|
97 |
} else if(HomeController.getDthProvidersMap().containsKey(operatorId)) {
|
|
|
98 |
operatorName = HomeController.getDthProvidersMap().get(operatorId);
|
|
|
99 |
} else {
|
|
|
100 |
operatorName = "N/A";
|
|
|
101 |
}
|
|
|
102 |
return operatorName;
|
|
|
103 |
}
|
| 7082 |
rajveer |
104 |
}
|
|
|
105 |
|