Subversion Repositories SmartDukaan

Rev

Rev 6091 | Rev 6228 | 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
 
3
import java.util.HashMap;
4
import java.util.List;
5
import java.util.Map;
6091 anupam.sin 6
import java.util.ResourceBundle;
6050 anupam.sin 7
 
8
import org.apache.log4j.Logger;
9
import org.apache.struts2.convention.annotation.Result;
10
import org.apache.struts2.convention.annotation.Results;
11
import org.apache.thrift.TException;
12
import org.apache.thrift.transport.TTransportException;
13
 
14
import in.shop2020.model.v1.order.RechargeOrder;
6215 anupam.sin 15
import in.shop2020.model.v1.user.Address;
6050 anupam.sin 16
import in.shop2020.thrift.clients.HelperClient;
6091 anupam.sin 17
import in.shop2020.thrift.clients.UserClient;
6050 anupam.sin 18
import in.shop2020.utils.HelperServiceException;
19
import in.shop2020.utils.QuickLink;
20
 
21
public class RechargePayOptionsController extends BaseController {
22
 
23
    /**
24
     * 
25
     */
6091 anupam.sin 26
 
27
    //private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
28
    //private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
6050 anupam.sin 29
    private RechargeOrder rechargeOrder = null;
6057 anupam.sin 30
    private String rechargeOrderId = "";
31
    private String amount = "";
32
    private String errorMsg = "";
6091 anupam.sin 33
    private String userId = null;
6215 anupam.sin 34
    private String rechargeType = "";
6050 anupam.sin 35
 
36
    private static final long serialVersionUID = 2079308723099307749L;
37
 
38
    private static Logger log = Logger.getLogger(Class.class);
39
 
40
    public String index() {
41
        return "index";
42
    }
43
 
44
    public String create() {
45
        return index();
46
    }
47
 
6215 anupam.sin 48
    /*public boolean shouldShowEbsTestGateway() {
6091 anupam.sin 49
        //return SHOW_EBS_TEST_GATEWAY;
50
        return true;
6215 anupam.sin 51
    }*/
6091 anupam.sin 52
 
6215 anupam.sin 53
    /*Please dont delete this. It will be reused.
6091 anupam.sin 54
    public boolean isAddressRequired() {
55
        UserClient ucl;
56
        long addressId = 0;
57
        try {
58
            ucl = new UserClient();
59
            addressId = ucl.getClient().getDefaultAddressId(Long.parseLong(userId));
60
        } catch (Exception e) {
61
            log.error("Unable to connect to user service", e);
62
        }
63
        if (addressId <= 0) {
64
            return true;
65
        } else {
66
            return false;
67
        }
68
    }
6215 anupam.sin 69
    */
70
    public boolean isPhoneNumberRequired() {
71
        Address address;
72
        UserClient ucl;
73
        if (rechargeType.equals("2")) {                         //2 is DTH recharge
74
            long addressId = 0;
75
            try {
76
                ucl = new UserClient();
77
                addressId = ucl.getClient().getDefaultAddressId(Long.parseLong(userId));
78
                address = ucl.getClient().getAddressById(addressId);
79
                if (address == null || address.getPhone().isEmpty() || address.getPhone() == null) {
80
                    //Phone number will be be required in cases when 
81
                    //rechargeType is DTH and the user does not have a default address
82
                    //or if it does not contain a phone number. For all other cases
83
                    //it will be not be required to be filled in by the user.
84
                    return true;
85
                }
86
            } catch (Exception e) {
87
                log.error("Unable to connect to user service", e);
88
                //We dont know if we need his number. Let us ask anyway.
89
                return true;
90
            }
91
        }
92
        return false;
93
    }
6091 anupam.sin 94
 
6050 anupam.sin 95
    public void setRechargeOrder(RechargeOrder rechargeOrder) {
96
        this.rechargeOrder = rechargeOrder;
97
    }
98
 
99
    public RechargeOrder getRechargeOrder() {
100
        return rechargeOrder;
101
    }
102
 
103
    public void setRechargeOrderId(String rechargeOrderId) {
6057 anupam.sin 104
        this.rechargeOrderId = rechargeOrderId;
6050 anupam.sin 105
    }
106
 
107
    public String getRechargeOrderId() {
6057 anupam.sin 108
        return rechargeOrderId;
6050 anupam.sin 109
    }
6057 anupam.sin 110
 
111
    public void setAmount(String amount) {
112
        this.amount = amount;
113
    }
114
 
115
    public String getAmount() {
116
        return amount;
117
    }
118
 
119
    public String getErrorMsg() {
120
        return errorMsg;
121
    }
6091 anupam.sin 122
 
123
    public String getUserId() {
124
        return userId;
125
    }
126
 
127
    public void setUserId(String userId) {
128
        this.userId = userId;
129
    }
6215 anupam.sin 130
 
131
    public void setRechargeType(String rechargeType) {
132
        this.rechargeType = rechargeType;
133
    }
134
 
135
    public String getRechargeType() {
136
        return rechargeType;
137
    }
6050 anupam.sin 138
}