Subversion Repositories SmartDukaan

Rev

Rev 7207 | Details | Compare with Previous | Last modification | View Log | RSS feed

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