| 7068 |
anupam.sin |
1 |
package in.shop2020.recharge.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.order.DenominationType;
|
|
|
4 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
|
|
5 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
|
|
6 |
import in.shop2020.model.v1.order.RechargePlan;
|
|
|
7 |
import in.shop2020.model.v1.order.RechargeType;
|
|
|
8 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
9 |
|
| 7073 |
anupam.sin |
10 |
import java.util.HashMap;
|
| 7068 |
anupam.sin |
11 |
import java.util.List;
|
|
|
12 |
import java.util.Map;
|
|
|
13 |
|
|
|
14 |
import org.apache.log4j.Logger;
|
| 7096 |
anupam.sin |
15 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
16 |
import org.apache.struts2.convention.annotation.Results;
|
| 7068 |
anupam.sin |
17 |
|
| 7096 |
anupam.sin |
18 |
import com.google.gson.Gson;
|
|
|
19 |
|
|
|
20 |
@Results({
|
|
|
21 |
@Result(name = "redirect", location = "${redirectUrl}", type = "redirect")
|
|
|
22 |
})
|
|
|
23 |
|
| 7068 |
anupam.sin |
24 |
public class HomeController extends BaseController {
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
*
|
|
|
28 |
*/
|
| 7073 |
anupam.sin |
29 |
private String deviceType = null; //Default is Mobile , 2 is for DTH
|
| 7068 |
anupam.sin |
30 |
private String deviceNumber = "";
|
|
|
31 |
private String form = "";
|
|
|
32 |
private String error = "";
|
|
|
33 |
private String operatorId;
|
|
|
34 |
private String operatorName;
|
|
|
35 |
private String serviceName;
|
|
|
36 |
private String denominationType;
|
| 7096 |
anupam.sin |
37 |
private String circlecode;
|
| 7068 |
anupam.sin |
38 |
private List<RechargeDenomination> rechargeDenominations = null;
|
|
|
39 |
private static final long serialVersionUID = 2079308723099307749L;
|
|
|
40 |
|
| 7096 |
anupam.sin |
41 |
private String storeIdString;
|
|
|
42 |
private Long storeId;
|
| 7068 |
anupam.sin |
43 |
private static Logger log = Logger.getLogger(Class.class);
|
|
|
44 |
private static Map<Long, String> mobileProvidersMap;
|
|
|
45 |
private static Map<Long, String> dthProvidersMap;
|
|
|
46 |
private static Map<Long, List<RechargePlan>> operatorPlanMap;
|
| 7096 |
anupam.sin |
47 |
private String errorMsg = "";
|
|
|
48 |
private String redirectUrl;
|
| 7068 |
anupam.sin |
49 |
|
|
|
50 |
|
|
|
51 |
static {
|
| 7073 |
anupam.sin |
52 |
TransactionClient tcl;
|
|
|
53 |
try {
|
|
|
54 |
operatorPlanMap = new HashMap<Long, List<RechargePlan>>();
|
|
|
55 |
tcl = new TransactionClient();
|
|
|
56 |
mobileProvidersMap = tcl.getClient().getServiceProviders(RechargeType.MOBILE, true);
|
|
|
57 |
setDthProvidersMap(tcl.getClient().getServiceProviders(RechargeType.DTH, true));
|
|
|
58 |
for (Long operatorId : mobileProvidersMap.keySet()) {
|
|
|
59 |
List<RechargePlan> plans = tcl.getClient().getPlansForOperator(operatorId);
|
|
|
60 |
if (!plans.isEmpty()) {
|
|
|
61 |
operatorPlanMap.put(operatorId, plans);
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
} catch(Exception e) {
|
| 7096 |
anupam.sin |
65 |
;
|
| 7073 |
anupam.sin |
66 |
}
|
| 7068 |
anupam.sin |
67 |
}
|
|
|
68 |
|
| 7096 |
anupam.sin |
69 |
public String getPlanMapInJson() {
|
|
|
70 |
Gson gson = new Gson();
|
|
|
71 |
return (gson.toJson(operatorPlanMap));
|
|
|
72 |
}
|
| 7068 |
anupam.sin |
73 |
|
|
|
74 |
public String index() {
|
|
|
75 |
|
| 7096 |
anupam.sin |
76 |
String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
|
|
|
77 |
if(loginStatus != null && loginStatus.equals("TRUE")){
|
|
|
78 |
return "index";
|
|
|
79 |
}
|
|
|
80 |
return "authfail";
|
| 7068 |
anupam.sin |
81 |
}
|
|
|
82 |
|
|
|
83 |
public String create() {
|
|
|
84 |
return index();
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
// public Map<Long, String> getProviderMap() {
|
| 7073 |
anupam.sin |
88 |
// if(deviceType.equals("1"))
|
| 7068 |
anupam.sin |
89 |
// providers = Utils.getMobileProvidersMap();
|
|
|
90 |
// else
|
|
|
91 |
// providers = Utils.getDthProvidersMap();
|
|
|
92 |
// return providers;
|
|
|
93 |
// }
|
|
|
94 |
//
|
|
|
95 |
public String getServiceProvider() {
|
|
|
96 |
return "service-provider";
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public String getProvider(){
|
|
|
100 |
TransactionClient tcl;
|
|
|
101 |
try {
|
|
|
102 |
tcl = new TransactionClient();
|
| 7073 |
anupam.sin |
103 |
DeviceNumberInfo deviceInfo = tcl.getClient().getServiceProviderForDevice(RechargeType.findByValue(Integer.parseInt(this.deviceType)), deviceNumber);
|
| 7068 |
anupam.sin |
104 |
return deviceInfo.getOperatorId() + ":" + deviceInfo.getCircleCode();
|
|
|
105 |
} catch (Exception e) {
|
| 7073 |
anupam.sin |
106 |
log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " + deviceType, e);
|
| 7068 |
anupam.sin |
107 |
return ":";
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
|
| 7073 |
anupam.sin |
111 |
public void setDeviceType(String incomingdeviceType) {
|
|
|
112 |
deviceType = incomingdeviceType;
|
| 7068 |
anupam.sin |
113 |
}
|
|
|
114 |
|
|
|
115 |
public void setDeviceNumber(String deviceNumber){
|
|
|
116 |
this.deviceNumber = deviceNumber;
|
|
|
117 |
}
|
|
|
118 |
|
| 7073 |
anupam.sin |
119 |
public String getDeviceType() {
|
|
|
120 |
return deviceType;
|
| 7068 |
anupam.sin |
121 |
}
|
|
|
122 |
|
|
|
123 |
public String getForm() {
|
|
|
124 |
return form;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void setForm(String form) {
|
|
|
128 |
this.form = form;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public String getError() {
|
|
|
132 |
return error;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public void setError(String error) {
|
|
|
136 |
this.error = error;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public String getPageName() {
|
|
|
140 |
return operatorName + " online recharge";
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public String getPageTitle() {
|
|
|
144 |
return operatorName + " online recharge";
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public String getPageMetaDesc() {
|
|
|
148 |
return "Recharge your " + this.operatorName + " " + this.serviceName + " online for all cities using Credit/Debit card & net banking. Fast, Secure and Hassle Free Recharge";
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public String getPageMetaKeywords() {
|
|
|
152 |
return "mobile, recharge";
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
public long getOperatorId(){
|
|
|
156 |
return Long.parseLong(this.operatorId);
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
public String getDenominationType() {
|
|
|
160 |
return denominationType;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
public void setDenominationType(String denominationType) {
|
|
|
164 |
this.denominationType = denominationType;
|
|
|
165 |
}
|
|
|
166 |
|
| 7096 |
anupam.sin |
167 |
public String getCirclecode() {
|
|
|
168 |
return circlecode;
|
| 7068 |
anupam.sin |
169 |
}
|
|
|
170 |
|
| 7096 |
anupam.sin |
171 |
public void setCircleCode(String circlecode) {
|
|
|
172 |
this.circlecode = circlecode;
|
| 7068 |
anupam.sin |
173 |
}
|
|
|
174 |
|
|
|
175 |
public List<RechargeDenomination> getRechargeDenominations() {
|
|
|
176 |
return rechargeDenominations;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
public void setRechargeDenominations(
|
|
|
180 |
List<RechargeDenomination> rechargeDenominations) {
|
|
|
181 |
this.rechargeDenominations = rechargeDenominations;
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
public void setOperatorId(String operatorId) {
|
|
|
185 |
this.operatorId = operatorId;
|
|
|
186 |
}
|
|
|
187 |
|
| 7096 |
anupam.sin |
188 |
public void setErrorMsg(String errorMsg) {
|
|
|
189 |
this.errorMsg = errorMsg;
|
| 7068 |
anupam.sin |
190 |
}
|
|
|
191 |
|
| 7096 |
anupam.sin |
192 |
public String getErrorMsg() {
|
| 7068 |
anupam.sin |
193 |
return errorMsg;
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
public static void setDthProvidersMap(Map<Long, String> dthProvidersMap) {
|
|
|
197 |
HomeController.dthProvidersMap = dthProvidersMap;
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
public static Map<Long, String> getDthProvidersMap() {
|
|
|
201 |
return dthProvidersMap;
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
public static void setMobileProvidersMap(Map<Long, String> mobileProvidersMap) {
|
|
|
205 |
HomeController.mobileProvidersMap = mobileProvidersMap;
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
public static Map<Long, String> getMobileProvidersMap() {
|
|
|
209 |
return mobileProvidersMap;
|
|
|
210 |
}
|
| 7096 |
anupam.sin |
211 |
|
|
|
212 |
public Long getStoreId() {
|
|
|
213 |
return storeId;
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
public void setStoreId(Long storeId) {
|
|
|
217 |
this.storeId = storeId;
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
public String getRedirectUrl() {
|
|
|
221 |
return redirectUrl;
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
public void setRedirectUrl(String redirectUrl) {
|
|
|
225 |
this.redirectUrl = redirectUrl;
|
|
|
226 |
}
|
| 7068 |
anupam.sin |
227 |
}
|