Subversion Repositories SmartDukaan

Rev

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

Rev 22054 Rev 23809
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.order.UserWalletHistory;
-
 
5
import in.shop2020.model.v1.order.WalletReferenceType;
5
import in.shop2020.model.v1.user.User;
6
import in.shop2020.model.v1.user.User;
6
import in.shop2020.model.v1.user.UserContextService.Client;
7
import in.shop2020.model.v1.user.UserContextService.Client;
7
import in.shop2020.support.utils.ReportsUtils;
8
import in.shop2020.support.utils.ReportsUtils;
8
import in.shop2020.thrift.clients.TransactionClient;
9
import in.shop2020.thrift.clients.TransactionClient;
9
import in.shop2020.thrift.clients.UserClient;
10
import in.shop2020.thrift.clients.UserClient;
Line 49... Line 50...
49
	private HttpSession session;
50
	private HttpSession session;
50
	private HttpServletResponse response;
51
	private HttpServletResponse response;
51
	private String id;
52
	private String id;
52
	private String email;
53
	private String email;
53
	private User user;
54
	private User user;
-
 
55
 
54
	private String amount;
56
	private String amount;
55
	private String url;
57
	private String url;
56
	private String result;
58
	private String result;
57
	private String cashback;
59
	private String cashback;
58
	private String description;
60
	private String description;
-
 
61
	private WalletReferenceType transactionType;
59
 
62
 
60
	public String getCashback() {
63
	public String getCashback() {
61
		return cashback;
64
		return cashback;
62
	}
65
	}
63
 
66
 
Line 79... Line 82...
79
 
82
 
80
	public void setUrl(String url) {
83
	public void setUrl(String url) {
81
		this.url = url;
84
		this.url = url;
82
	}
85
	}
83
 
86
 
-
 
87
	public WalletReferenceType getTransactionType() {
-
 
88
		return transactionType;
-
 
89
	}
-
 
90
	
-
 
91
	public void setTransactionType(WalletReferenceType transactionType) {
-
 
92
		this.transactionType = transactionType;
-
 
93
	}
-
 
94
	
84
	public String getAmount() {
95
	public String getAmount() {
85
		return amount;
96
		return amount;
86
	}
97
	}
87
 
98
 
88
	public void setAmount(String amount) {
99
	public void setAmount(String amount) {
Line 141... Line 152...
141
			e.printStackTrace();
152
			e.printStackTrace();
142
			addActionError("Service exception.");
153
			addActionError("Service exception.");
143
			return "index";
154
			return "index";
144
		}
155
		}
145
		try{
156
		try{
-
 
157
			Client uc = new UserClient().getClient();
-
 
158
			user = uc.getUserByEmail(email);
146
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
159
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
147
			userWallet = tc.getUserWallet(user.getUserId());
160
			userWallet = tc.getUserWallet(user.getUserId());
148
			setUserWalletHistory(tc.getLatestUserWalletHistory(user.getUserId(), 0, 20));
161
			setUserWalletHistory(tc.getLatestUserWalletHistory(user.getUserId(), 0, 20));
149
		}
162
		}
150
		catch(Exception e){
163
		catch(Exception e){
Line 193... Line 206...
193
		}
206
		}
194
		if(StringUtils.isEmpty(description)) {
207
		if(StringUtils.isEmpty(description)) {
195
			setResult("Short Description should not be empty");
208
			setResult("Short Description should not be empty");
196
			return "pmsa-result";
209
			return "pmsa-result";
197
		}
210
		}
-
 
211
		if(this.transactionType.equals(WalletReferenceType.ADVANCE_REVERSAL)) {
-
 
212
			credit_amount = -credit_amount;
-
 
213
		}
198
		try {
214
		try {
199
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
215
			in.shop2020.model.v1.order.TransactionService.Client tc = new TransactionClient().getClient();
200
			tc.creditUserWallet(user.getUserId(), credit_amount, cash_back, description);
216
			tc.creditUserWallet(user.getUserId(), credit_amount, cash_back, description);
201
		} catch (Exception e) {
217
		} catch (Exception e) {
202
			e.printStackTrace();
218
			e.printStackTrace();