Subversion Repositories SmartDukaan

Rev

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

Rev 6206 Rev 6244
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
3
import in.shop2020.model.v1.order.RechargeOrderStatus;
3
import in.shop2020.model.v1.order.RechargeOrderStatus;
-
 
4
import in.shop2020.model.v1.order.RechargePlan;
4
import in.shop2020.model.v1.order.RechargeStatistics;
5
import in.shop2020.model.v1.order.RechargeStatistics;
5
import in.shop2020.model.v1.order.RechargeType;
6
import in.shop2020.model.v1.order.RechargeType;
6
import in.shop2020.support.utils.ReportsUtils;
7
import in.shop2020.support.utils.ReportsUtils;
7
import in.shop2020.thrift.clients.TransactionClient;
8
import in.shop2020.thrift.clients.TransactionClient;
8
 
9
 
9
import java.text.DateFormat;
10
import java.text.DateFormat;
10
import java.text.SimpleDateFormat;
11
import java.text.SimpleDateFormat;
11
import java.util.Calendar;
12
import java.util.Calendar;
-
 
13
import java.util.HashMap;
-
 
14
import java.util.List;
12
import java.util.Map;
15
import java.util.Map;
13
import java.util.Map.Entry;
16
import java.util.Map.Entry;
14
 
17
 
15
import javax.servlet.ServletContext;
18
import javax.servlet.ServletContext;
16
import javax.servlet.http.HttpServletRequest;
19
import javax.servlet.http.HttpServletRequest;
Line 43... Line 46...
43
    private ServletContext context;
46
    private ServletContext context;
44
    
47
    
45
	private RechargeStatistics stats;
48
	private RechargeStatistics stats;
46
 
49
 
47
    private static Map<Long, String> providers;
50
    private static Map<Long, String> providers;
-
 
51
    static Map<String, String> planMap = new HashMap<String, String>();
48
 
52
    
49
    private TransactionClient tsc;
53
    private TransactionClient tsc;
50
    private in.shop2020.model.v1.order.TransactionService.Client tClient;
54
    private in.shop2020.model.v1.order.TransactionService.Client tClient;
51
    
55
    
52
    private final DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
56
    private final DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
53
	
57
	
Line 63... Line 67...
63
    static{
67
    static{
64
    	TransactionClient tc;
68
    	TransactionClient tc;
65
        try {
69
        try {
66
            tc = new TransactionClient();
70
            tc = new TransactionClient();
67
            providers = tc.getClient().getServiceProviders(RechargeType.MOBILE, false);
71
            providers = tc.getClient().getServiceProviders(RechargeType.MOBILE, false);
-
 
72
            for (Long operatorId : providers.keySet()) {
-
 
73
                List<RechargePlan> plans = tc.getClient().getPlansForOperator(operatorId);
-
 
74
                if (!plans.isEmpty()) {
-
 
75
                	for(RechargePlan plan: plans){
-
 
76
                		planMap.put(plan.getName(), plan.getDisplayName());
-
 
77
                	}
-
 
78
                }
-
 
79
            }
68
            for(Entry<Long, String> providerEntry: tc.getClient().getServiceProviders(RechargeType.DTH, false).entrySet()){
80
            for(Entry<Long, String> providerEntry: tc.getClient().getServiceProviders(RechargeType.DTH, false).entrySet()){
69
            	providers.put(providerEntry.getKey(), providerEntry.getValue());
81
            	providers.put(providerEntry.getKey(), providerEntry.getValue());
70
            }
82
            }
71
             
83
            
72
        } catch (Exception e) {
84
        } catch (Exception e) {
73
            logger.error("Cannot get providers", e);
85
            logger.error("Cannot get providers", e);
74
        }
86
        }
75
    }
87
    }
76
    
88
    
Line 93... Line 105...
93
 
105
 
94
    public String getOperator(long operatorId) {
106
    public String getOperator(long operatorId) {
95
        return providers.get(operatorId);
107
        return providers.get(operatorId);
96
    }
108
    }
97
 
109
 
-
 
110
    public String getPlanString(String plan) {
-
 
111
        return planMap.get(plan);
-
 
112
    }
-
 
113
    
98
    public String getStatusDescription(long status) {
114
    public String getStatusDescription(long status) {
99
        return RechargeOrderStatus.findByValue((int)status).toString();
115
        return RechargeOrderStatus.findByValue((int)status).toString();
100
    }
116
    }
101
    
117
    
102
    public String getDateTime(long milliseconds) {
118
    public String getDateTime(long milliseconds) {