Subversion Repositories SmartDukaan

Rev

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

Rev 6108 Rev 6124
Line 75... Line 75...
75
    				rechargeType.toString(), number, operator);
75
    				rechargeType.toString(), number, operator);
76
    		return "recharge-redirect";
76
    		return "recharge-redirect";
77
    	}
77
    	}
78
        setTotalAmount(amount);
78
        setTotalAmount(amount);
79
        if(userinfo.isLoggedIn()) {
79
        if(userinfo.isLoggedIn()) {
-
 
80
            setUserId("" + userinfo.getUserId());
80
            try {
81
            try {
81
            TransactionClient tc = new TransactionClient();
82
            TransactionClient tc = new TransactionClient();
82
            UserWallet wallet = tc.getClient().getUserWallet(userinfo.getUserId());
83
            UserWallet wallet = tc.getClient().getUserWallet(userinfo.getUserId());
83
            long amountA = 0;
84
            long amountA = 0;
84
            if(wallet.getAmount() == 0){
85
            if(wallet.getAmount() == 0){
Line 95... Line 96...
95
            
96
            
96
                
97
                
97
            } catch (Exception e) {
98
            } catch (Exception e) {
98
                log.error("Unable to get user wallet", e);
99
                log.error("Unable to get user wallet", e);
99
            }
100
            }
-
 
101
        } else {
-
 
102
            long tempUserId = createUserAndSendMail(email);
-
 
103
            if(tempUserId == -1)
-
 
104
            {
-
 
105
                return "recharge-redirect";
-
 
106
            } else {
-
 
107
                setUserId("" + tempUserId);
-
 
108
            }
100
        }
109
        }
101
        setUserId("" + createUserAndSendMail(email));
-
 
102
        return index();
110
        return index();
103
        
-
 
104
    }
111
    }
105
    
112
    
106
    public String getProvider(){
113
    public String getProvider(){
107
    	TransactionClient tcl;
114
    	TransactionClient tcl;
108
    	try {
115
    	try {
Line 119... Line 126...
119
        this.totalAmount  = amount2;
126
        this.totalAmount  = amount2;
120
        
127
        
121
    }
128
    }
122
 
129
 
123
    public String createRecharge(){
130
    public String createRecharge(){
124
        if(userinfo.isLoggedIn()) {
-
 
125
            setUserId("" + userinfo.getUserId());
-
 
126
        } else {
-
 
127
            //setUserId("686085");
-
 
128
        }
-
 
129
        
-
 
130
        try {
131
        try {
131
            TransactionClient tc = new TransactionClient();
132
            TransactionClient tc = new TransactionClient();
132
            RechargeOrder rechargeOrder = new RechargeOrder();
133
            RechargeOrder rechargeOrder = new RechargeOrder();
133
            rechargeOrder.setTotalAmount(Long.parseLong(amount) + Long.parseLong(getWalletAmountUsed()));
134
            rechargeOrder.setTotalAmount(Long.parseLong(amount) + Long.parseLong(getWalletAmountUsed()));
134
            rechargeOrder.setUserEmailId(email);
135
            rechargeOrder.setUserEmailId(email);
Line 169... Line 170...
169
        User user = null;
170
        User user = null;
170
        String password = null;
171
        String password = null;
171
        try{
172
        try{
172
        UserClient ucl = new UserClient();
173
        UserClient ucl = new UserClient();
173
        user = ucl.getClient().getUserByEmail(email);
174
        user = ucl.getClient().getUserByEmail(email);
174
        if(user == null) {
175
        if(user.getUserId() == -1) {
175
            user = new User();
-
 
176
            user.setEmail(email);
176
            user.setEmail(email);
177
            password = generateNewPassword();
177
            password = generateNewPassword();
178
            String encryptedPassword = desEncrypter.encrypt(password);
178
            String encryptedPassword = desEncrypter.encrypt(password);
179
            user.setPassword(encryptedPassword);
179
            user.setPassword(encryptedPassword);
180
            user.setCommunicationEmail(email);
180
            user.setCommunicationEmail(email);
181
            UserClient userContextServiceClient = new UserClient();
181
            UserClient userContextServiceClient = new UserClient();
182
            in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
182
            in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
183
            user = userClient.createUser(user);
183
            user = userClient.createUser(user);
-
 
184
            
-
 
185
            List<String> toList = new ArrayList<String>();
-
 
186
            toList.add(email);
-
 
187
            HelperClient helperServiceClient = null;
-
 
188
                helperServiceClient = new HelperClient();
-
 
189
                in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
-
 
190
                Mail mail = new Mail();
-
 
191
                mail.setSubject("Registration successful");
-
 
192
                mail.setTo(toList);
-
 
193
                mail.setData("Your have successfully registered with Saholic.com. Your user name is: " + email + " and your password is: " +  password);
-
 
194
                client.sendMail(mail);
184
            }
195
            }
185
        }catch (UserContextException ux){
196
        }catch (UserContextException ux){
186
            return -1;               
197
            return -1;               
187
        } catch (TTransportException e) {
198
        } catch (TTransportException e) {
188
            return -1;
199
            return -1;
189
        } catch (TException e) {
200
        } catch (TException e) {
190
            return -1;
201
            return -1;
-
 
202
        } catch (Exception e) {
-
 
203
            log.error("Unexpected error while mailing the new password");
-
 
204
            return -1;
191
        }
205
        }
192
        return user.getUserId();
206
        return user.getUserId();
193
    }
207
    }
194
    
208
    
195
    public String temp() {
209
    public String temp() {