Subversion Repositories SmartDukaan

Rev

Rev 6200 | Rev 6204 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6050 anupam.sin 1
package in.shop2020.serving.controllers;
2
 
6066 amit.gupta 3
import in.shop2020.model.v1.order.RechargeType;
6178 anupam.sin 4
import in.shop2020.serving.utils.Utils;
6066 amit.gupta 5
import in.shop2020.thrift.clients.TransactionClient;
6
 
6050 anupam.sin 7
import java.util.Map;
8
 
9
import org.apache.log4j.Logger;
10
 
6178 anupam.sin 11
import com.google.gson.Gson;
12
 
6050 anupam.sin 13
public class RechargeController extends BaseController {
14
 
15
    /**
16
     * 
17
     */
6178 anupam.sin 18
    private String serviceType = "1"; //Default is Mobile , 2 is for DTH
6103 amit.gupta 19
    private String deviceNumber = "";
6050 anupam.sin 20
    private String form = "";
6057 anupam.sin 21
    private Map<Long, String> providers;
6103 amit.gupta 22
    private String error = "";
6050 anupam.sin 23
 
24
    private static final long serialVersionUID = 2079308723099307749L;
25
 
26
    private static Logger log = Logger.getLogger(Class.class);
27
 
6057 anupam.sin 28
 
6050 anupam.sin 29
    public String index() {
6103 amit.gupta 30
    	if(error.equals("ServiceDown")){
6174 rajveer 31
    		error = "Oops! There seems to be a problem. Please try after some time";
6103 amit.gupta 32
    	}else{
33
    		error = "";
34
    	}
6050 anupam.sin 35
        return "index";
36
    }
37
 
38
    public String create() {
39
        if(form.equals("serviceSelect")) {
40
            return index();
41
        }
42
        return "hello";
43
    }
6057 anupam.sin 44
 
45
    public Map<Long, String> getProviderMap() {
6201 rajveer 46
        if(serviceType.equals("1"))
47
            providers = Utils.getMobileProvidersMap();
48
        else
49
            providers = Utils.getDthProvidersMap();
6057 anupam.sin 50
        return providers;
51
    }
6100 anupam.sin 52
 
6103 amit.gupta 53
    public String getServiceProvider() {
54
    	return "service-provider";
6100 anupam.sin 55
    }
6103 amit.gupta 56
 
57
    public String getProvider(){
58
    	TransactionClient tcl;
59
    	try {
60
    		tcl = new TransactionClient();
61
    		return tcl.getClient().getServiceProviderForDevice(RechargeType.findByValue(Integer.parseInt(this.serviceType)), deviceNumber) + "";
62
    	} catch (Exception e) {
63
    		log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  serviceType, e);
64
    	}
65
    	return 0 + "";
66
    }
6178 anupam.sin 67
 
68
    public String getPlanMapInJson() {
69
        Gson gson = new Gson();
70
            return (gson.toJson(Utils.getOperatorPlanMap()));
71
    }
6050 anupam.sin 72
 
6057 anupam.sin 73
    public void setServiceType(String incomingServiceType) {
74
        serviceType = incomingServiceType;
75
    }
6103 amit.gupta 76
 
77
    public void setDeviceNumber(String deviceNumber){
78
    	this.deviceNumber = deviceNumber;
79
    }
6057 anupam.sin 80
 
6050 anupam.sin 81
    public String getServiceType() {
82
        return serviceType;
83
    }
84
 
85
    public String getForm() {
86
        return form;
87
    }
88
 
89
    public void setForm(String form) {
90
        this.form = form;
91
    }
6103 amit.gupta 92
 
93
	public String getError() {
94
		return error;
95
	}
96
 
97
	public void setError(String error) {
98
		this.error = error;
99
	}
100
 
6050 anupam.sin 101
}