Subversion Repositories SmartDukaan

Rev

Rev 7068 | Rev 7087 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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