Subversion Repositories SmartDukaan

Rev

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

Rev 21363 Rev 22044
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
3
import in.shop2020.model.v1.order.UserWallet;
3
import in.shop2020.model.v1.order.UserWallet;
-
 
4
import in.shop2020.model.v1.order.UserWalletHistory;
4
import in.shop2020.model.v1.user.User;
5
import in.shop2020.model.v1.user.User;
5
import in.shop2020.model.v1.user.UserContextService.Client;
6
import in.shop2020.model.v1.user.UserContextService.Client;
6
import in.shop2020.support.utils.ReportsUtils;
7
import in.shop2020.support.utils.ReportsUtils;
7
import in.shop2020.thrift.clients.TransactionClient;
8
import in.shop2020.thrift.clients.TransactionClient;
8
import in.shop2020.thrift.clients.UserClient;
9
import in.shop2020.thrift.clients.UserClient;
9
 
10
 
-
 
11
import java.util.List;
-
 
12
 
10
import javax.servlet.ServletContext;
13
import javax.servlet.ServletContext;
11
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpServletRequest;
12
import javax.servlet.http.HttpServletResponse;
15
import javax.servlet.http.HttpServletResponse;
13
import javax.servlet.http.HttpSession;
16
import javax.servlet.http.HttpSession;
14
 
17
 
-
 
18
import org.apache.commons.lang.StringUtils;
15
import org.apache.struts2.convention.annotation.InterceptorRef;
19
import org.apache.struts2.convention.annotation.InterceptorRef;
16
import org.apache.struts2.convention.annotation.InterceptorRefs;
20
import org.apache.struts2.convention.annotation.InterceptorRefs;
17
import org.apache.struts2.convention.annotation.Result;
21
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Results;
22
import org.apache.struts2.convention.annotation.Results;
19
import org.apache.struts2.interceptor.ServletRequestAware;
23
import org.apache.struts2.interceptor.ServletRequestAware;
Line 47... Line 51...
47
	private User user;
51
	private User user;
48
	private String amount;
52
	private String amount;
49
	private String url;
53
	private String url;
50
	private String result;
54
	private String result;
51
	private String cashback;
55
	private String cashback;
-
 
56
	private String description;
52
 
57
 
53
	public String getCashback() {
58
	public String getCashback() {
54
		return cashback;
59
		return cashback;
55
	}
60
	}
56
 
61
 
Line 89... Line 94...
89
	public void setUser(User user) {
94
	public void setUser(User user) {
90
		this.user = user;
95
		this.user = user;
91
	}
96
	}
92
 
97
 
93
	private UserWallet userWallet;
98
	private UserWallet userWallet;
-
 
99
	private List<UserWalletHistory> userWalletHistory;
94
 
100
 
95
 
101
 
96
	public UserWallet getUserWallet() {
102
	public UserWallet getUserWallet() {
97
		return userWallet;
103
		return userWallet;
98
	}
104
	}
-
 
105
	
-
 
106
	public List<UserWalletHistory> getUserWalletHistory() {
-
 
107
		return this.userWalletHistory;
-
 
108
	}
99
 
109
 
100
	public void setUserWallet(UserWallet userWallet) {
110
	public void setUserWallet(UserWallet userWallet) {
101
		this.userWallet = userWallet;
111
		this.userWallet = userWallet;
102
	}
112
	}
103
 
113
 
Line 131... Line 141...
131
			return "index";
141
			return "index";
132
		}
142
		}
133
		try{
143
		try{
134
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
144
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
135
			userWallet = tc.getUserWallet(user.getUserId());
145
			userWallet = tc.getUserWallet(user.getUserId());
-
 
146
			setUserWalletHistory(tc.getLatestUserWalletHistory(user.getUserId(), 0, 20));
136
		}
147
		}
137
		catch(Exception e){
148
		catch(Exception e){
138
			e.printStackTrace();
149
			e.printStackTrace();
139
			addActionError("Service exception.");
150
			addActionError("Service exception.");
140
			return "index";
151
			return "index";
Line 142... Line 153...
142
		return "user-wallet-credit-edit";
153
		return "user-wallet-credit-edit";
143
	}
154
	}
144
 
155
 
145
	public String creditWallet(){
156
	public String creditWallet(){
146
		long credit_amount;
157
		long credit_amount;
147
		double cash_back; 
158
		double cash_back;
148
		try{
159
		try{
149
			credit_amount = Long.valueOf(amount);
160
			credit_amount = Long.valueOf(amount);
150
			if (credit_amount <=0){
161
			if (credit_amount <=0){
151
				setResult("Amount cant be negative");
162
				setResult("Amount cant be negative");
152
				return "pmsa-result";
163
				return "pmsa-result";
Line 176... Line 187...
176
 
187
 
177
		if (user.getUserId()==-1){
188
		if (user.getUserId()==-1){
178
			setResult("User email not valid");
189
			setResult("User email not valid");
179
			return "pmsa-result";
190
			return "pmsa-result";
180
		}
191
		}
-
 
192
		if(StringUtils.isEmpty(description)) {
-
 
193
			setResult("Short Description should not be empty");
-
 
194
			return "pmsa-result";
-
 
195
		}
181
		try {
196
		try {
182
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
197
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
183
			tc.creditUserWallet(user.getUserId(), credit_amount, cash_back);
198
			tc.creditUserWallet(user.getUserId(), credit_amount, cash_back, description);
184
		} catch (Exception e) {
199
		} catch (Exception e) {
185
			e.printStackTrace();
200
			e.printStackTrace();
186
			setResult("Service error");
201
			setResult("Service error");
187
			return "pmsa-result";
202
			return "pmsa-result";
188
		}
203
		}
Line 213... Line 228...
213
	}
228
	}
214
 
229
 
215
	public void setServletResponse(HttpServletResponse response) {
230
	public void setServletResponse(HttpServletResponse response) {
216
		this.response = response;
231
		this.response = response;
217
	}
232
	}
-
 
233
	
-
 
234
	public void setDescription(String description) {
-
 
235
		this.description = description;
-
 
236
	}
-
 
237
 
-
 
238
	public void setUserWalletHistory(List<UserWalletHistory> userWalletHistory) {
-
 
239
		this.userWalletHistory = userWalletHistory;
-
 
240
	}
218
 
241
 
219
 
242
 
220
}
243
}
221
244