Subversion Repositories SmartDukaan

Rev

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

Rev 6270 Rev 6289
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
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;
3
import in.shop2020.model.v1.order.RechargeType;
6
import in.shop2020.model.v1.order.RechargeType;
4
import in.shop2020.serving.utils.Utils;
7
import in.shop2020.serving.utils.Utils;
5
import in.shop2020.thrift.clients.TransactionClient;
8
import in.shop2020.thrift.clients.TransactionClient;
6
 
9
 
-
 
10
import java.util.List;
7
import java.util.Map;
11
import java.util.Map;
8
 
12
 
9
import org.apache.log4j.Logger;
13
import org.apache.log4j.Logger;
10
 
14
 
11
import com.google.gson.Gson;
15
import com.google.gson.Gson;
Line 22... Line 26...
22
    private String error = "";
26
    private String error = "";
23
    private String uri;
27
    private String uri;
24
    private String operatorId;
28
    private String operatorId;
25
    private String operatorName;
29
    private String operatorName;
26
    private String serviceName;
30
    private String serviceName;
-
 
31
    private String denominationType;
-
 
32
    private String circleName;
-
 
33
    private List<RechargeDenomination> rechargeDenominations = null;
27
    private static final long serialVersionUID = 2079308723099307749L;
34
    private static final long serialVersionUID = 2079308723099307749L;
28
 
35
 
29
    private static Logger log = Logger.getLogger(Class.class);
36
    private static Logger log = Logger.getLogger(Class.class);
30
    
37
    
31
    
38
    
Line 64... Line 71...
64
    
71
    
65
    public String getProvider(){
72
    public String getProvider(){
66
    	TransactionClient tcl;
73
    	TransactionClient tcl;
67
    	try {
74
    	try {
68
    		tcl = new TransactionClient();
75
    		tcl = new TransactionClient();
69
    		return tcl.getClient().getServiceProviderForDevice(RechargeType.findByValue(Integer.parseInt(this.serviceType)), deviceNumber) + "";
76
    		DeviceNumberInfo deviceInfo =  tcl.getClient().getServiceProviderForDevice(RechargeType.findByValue(Integer.parseInt(this.serviceType)), deviceNumber);
-
 
77
    		return deviceInfo.getOperatorId() + ":" + deviceInfo.getCircleName();
70
    	} catch (Exception e) {
78
    	} catch (Exception e) {
71
    		log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  serviceType, e);
79
    		log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  serviceType, e);
-
 
80
    	    return ":";
72
    	}
81
    	}
-
 
82
    }
-
 
83
    
-
 
84
    public String getAllDenominations() {
-
 
85
        TransactionClient tcl;
-
 
86
        try {
-
 
87
            tcl = new TransactionClient();
-
 
88
            rechargeDenominations =  tcl.getClient().getRechargeDenominations(Long.parseLong(operatorId), circleName, DenominationType.findByValue(Integer.parseInt(denominationType)));
-
 
89
            if(rechargeDenominations == null || rechargeDenominations.isEmpty()) {
-
 
90
                setError("This information is unavailable for now.<br>You can recharge with the amount you normally use or you can try later.");
73
    	return 0 + "";
91
            }
-
 
92
        } catch (Exception e) {
-
 
93
            log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleName : " +  circleName + " and DenominationType : " + denominationType, e);
-
 
94
            setError("This information is unavailable for now.<br>You can recharge with the amount you normally use or you can try later.");
-
 
95
        }
-
 
96
        return "recharge-denomination";
74
    }
97
    }
75
    
98
    
76
    public String getPlanMapInJson() {
99
    public String getPlanMapInJson() {
77
        Gson gson = new Gson();
100
        Gson gson = new Gson();
78
            return (gson.toJson(Utils.getOperatorPlanMap()));
101
            return (gson.toJson(Utils.getOperatorPlanMap()));
Line 123... Line 146...
123
    }
146
    }
124
    
147
    
125
    public long getOperatorId(){
148
    public long getOperatorId(){
126
    	return Long.parseLong(this.operatorId);
149
    	return Long.parseLong(this.operatorId);
127
    }
150
    }
-
 
151
 
-
 
152
    public String getDenominationType() {
-
 
153
        return denominationType;
-
 
154
    }
-
 
155
 
-
 
156
    public void setDenominationType(String denominationType) {
-
 
157
        this.denominationType = denominationType;
-
 
158
    }
-
 
159
 
-
 
160
    public String getCircleName() {
-
 
161
        return circleName;
-
 
162
    }
-
 
163
 
-
 
164
    public void setCircleName(String circleName) {
-
 
165
        this.circleName = circleName;
-
 
166
    }
-
 
167
 
-
 
168
    public List<RechargeDenomination> getRechargeDenominations() {
-
 
169
        return rechargeDenominations;
-
 
170
    }
-
 
171
 
-
 
172
    public void setRechargeDenominations(
-
 
173
            List<RechargeDenomination> rechargeDenominations) {
-
 
174
        this.rechargeDenominations = rechargeDenominations;
-
 
175
    }
-
 
176
 
-
 
177
    public void setOperatorId(String operatorId) {
-
 
178
        this.operatorId = operatorId;
-
 
179
    }
128
}
180
}
129
181