| 23505 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 33247 |
ranu |
3 |
import com.spice.profitmandi.common.enumuration.ProviderBalanceFrom;
|
|
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
5 |
import com.spice.profitmandi.common.model.*;
|
|
|
6 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
|
|
7 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
|
|
8 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
|
|
9 |
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
|
|
|
10 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
|
|
11 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
|
|
12 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
|
|
13 |
import com.spice.profitmandi.service.recharge.RechargeService;
|
|
|
14 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
15 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 23628 |
ashik.ali |
16 |
import org.apache.logging.log4j.LogManager;
|
|
|
17 |
import org.apache.logging.log4j.Logger;
|
| 23505 |
ashik.ali |
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
19 |
import org.springframework.beans.factory.annotation.Value;
|
| 23628 |
ashik.ali |
20 |
import org.springframework.http.ResponseEntity;
|
| 23505 |
ashik.ali |
21 |
import org.springframework.stereotype.Controller;
|
|
|
22 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
23 |
import org.springframework.ui.Model;
|
|
|
24 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
25 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
26 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
27 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
28 |
|
| 33247 |
ranu |
29 |
import javax.servlet.http.HttpServletRequest;
|
|
|
30 |
import java.time.LocalDateTime;
|
|
|
31 |
import java.util.*;
|
| 23505 |
ashik.ali |
32 |
|
|
|
33 |
@Controller
|
| 26228 |
amit.gupta |
34 |
@Transactional(rollbackFor = Throwable.class)
|
| 23505 |
ashik.ali |
35 |
public class RechargeController {
|
|
|
36 |
|
| 23628 |
ashik.ali |
37 |
private static final Logger LOGGER = LogManager.getLogger(RechargeController.class);
|
| 26228 |
amit.gupta |
38 |
|
| 24276 |
amit.gupta |
39 |
private List<String> blockedRecharge = Arrays.asList();
|
| 24261 |
amit.gupta |
40 |
|
| 23575 |
ashik.ali |
41 |
@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
|
|
|
42 |
private String thinkWalnutDigitalRechargeTransactionMobileUrl;
|
| 26228 |
amit.gupta |
43 |
|
| 23575 |
ashik.ali |
44 |
@Value("${think.walnut.digital.recharge.transaction.dth.url}")
|
|
|
45 |
private String thinkWalnutDigitalRechargeTransactionDthUrl;
|
| 26228 |
amit.gupta |
46 |
|
| 23575 |
ashik.ali |
47 |
@Value("${think.walnut.digital.recharge.enquiry.url}")
|
|
|
48 |
private String thinkWalnutDigitalRechargeEnquiryUrl;
|
| 26228 |
amit.gupta |
49 |
|
| 23628 |
ashik.ali |
50 |
@Value("${think.walnut.digital.recharge.balance.url}")
|
|
|
51 |
private String thinkWalnutDigitalRechargeBalanceUrl;
|
| 26228 |
amit.gupta |
52 |
|
| 23628 |
ashik.ali |
53 |
@Value("${think.walnut.digital.recharge.username}")
|
|
|
54 |
private String thinkWalnutDigitalRechargeUserName;
|
| 26228 |
amit.gupta |
55 |
|
| 23628 |
ashik.ali |
56 |
@Value("${think.walnut.digital.recharge.password}")
|
|
|
57 |
private String thinkWalnutDigitalRechargePassword;
|
| 26228 |
amit.gupta |
58 |
|
| 23575 |
ashik.ali |
59 |
@Value("${think.walnut.digital.recharge.auth.key}")
|
|
|
60 |
private String thinkWalnutDigitalRechargeAuthKey;
|
| 26228 |
amit.gupta |
61 |
|
| 23505 |
ashik.ali |
62 |
@Autowired
|
|
|
63 |
private RechargeService rechargeService;
|
| 26228 |
amit.gupta |
64 |
|
| 23505 |
ashik.ali |
65 |
@Autowired
|
|
|
66 |
private RechargeOperatorRepository rechargeOperatorRepository;
|
| 26228 |
amit.gupta |
67 |
|
| 23505 |
ashik.ali |
68 |
@Autowired
|
| 23575 |
ashik.ali |
69 |
private RechargeProviderRepository rechargeProviderRepository;
|
| 26228 |
amit.gupta |
70 |
|
| 23575 |
ashik.ali |
71 |
@Autowired
|
| 23505 |
ashik.ali |
72 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 26228 |
amit.gupta |
73 |
|
| 23505 |
ashik.ali |
74 |
@Autowired
|
| 23528 |
ashik.ali |
75 |
private RechargeCommissionRepository rechargeCommissionRepository;
|
| 26228 |
amit.gupta |
76 |
|
| 23528 |
ashik.ali |
77 |
@Autowired
|
| 23548 |
ashik.ali |
78 |
private PaymentOptionRepository paymentOptionRepository;
|
| 26228 |
amit.gupta |
79 |
|
| 23548 |
ashik.ali |
80 |
@Autowired
|
|
|
81 |
private FofoPartnerPaymentOptionRepository fofoPartnerPaymentOptionRepository;
|
| 26228 |
amit.gupta |
82 |
|
| 23548 |
ashik.ali |
83 |
@Autowired
|
| 23628 |
ashik.ali |
84 |
private RechargeProviderCreditWalletHistoryRepository rechargeProviderCreditWalletHistoryRepository;
|
| 26228 |
amit.gupta |
85 |
|
| 23628 |
ashik.ali |
86 |
@Autowired
|
|
|
87 |
private DailyRechargeRepository dailyRechargeRepository;
|
| 26228 |
amit.gupta |
88 |
|
| 23628 |
ashik.ali |
89 |
@Autowired
|
| 23505 |
ashik.ali |
90 |
private CookiesProcessor cookiesProcessor;
|
| 26228 |
amit.gupta |
91 |
|
| 23628 |
ashik.ali |
92 |
@Autowired
|
|
|
93 |
private ResponseSender<?> responseSender;
|
| 26228 |
amit.gupta |
94 |
|
| 23505 |
ashik.ali |
95 |
@RequestMapping(value = "/createRecharge", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
96 |
public String createRecharge(HttpServletRequest request,
|
|
|
97 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString, Model model)
|
|
|
98 |
throws ProfitMandiBusinessException {
|
| 23548 |
ashik.ali |
99 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23505 |
ashik.ali |
100 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
|
|
101 |
List<RechargeOperator> rechargeOperators = null;
|
| 26228 |
amit.gupta |
102 |
if (rechargeType == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
103 |
model.addAttribute("operatorTypes", OperatorType.values());
|
|
|
104 |
rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(OperatorType.PREPAID);
|
| 26228 |
amit.gupta |
105 |
} else {
|
| 23505 |
ashik.ali |
106 |
rechargeOperators = rechargeOperatorRepository.selectAllByRechargeType(rechargeType);
|
|
|
107 |
}
|
| 26228 |
amit.gupta |
108 |
|
| 32457 |
jai.hind |
109 |
int paymentOption = 1;
|
|
|
110 |
Set<Integer> paymentOptionIds = new HashSet<>();
|
|
|
111 |
paymentOptionIds.add(1);
|
|
|
112 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(paymentOptionIds);
|
|
|
113 |
model.addAttribute("paymentOption", paymentOptions.get(0));
|
| 23505 |
ashik.ali |
114 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
115 |
return "create-recharge";
|
|
|
116 |
}
|
| 26228 |
amit.gupta |
117 |
|
|
|
118 |
private Map<Integer, String> rechargeTransactionsToRechargeOperatorIdNameMap(
|
| 33247 |
ranu |
119 |
List<RechargeTransaction> rechargeTransactions) throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
120 |
Map<Integer, String> rechargeOperatorIdrechargeOperatorNameMap = new HashMap<>();
|
| 26228 |
amit.gupta |
121 |
if (rechargeTransactions.isEmpty()) {
|
| 23505 |
ashik.ali |
122 |
return rechargeOperatorIdrechargeOperatorNameMap;
|
|
|
123 |
}
|
|
|
124 |
Set<Integer> operatorIds = new HashSet<>();
|
| 26228 |
amit.gupta |
125 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| 23505 |
ashik.ali |
126 |
operatorIds.add(rechargeTransaction.getOperatorId());
|
|
|
127 |
}
|
| 26228 |
amit.gupta |
128 |
|
| 23505 |
ashik.ali |
129 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByIds(operatorIds);
|
| 26228 |
amit.gupta |
130 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 23505 |
ashik.ali |
131 |
rechargeOperatorIdrechargeOperatorNameMap.put(rechargeOperator.getId(), rechargeOperator.getName());
|
|
|
132 |
}
|
|
|
133 |
return rechargeOperatorIdrechargeOperatorNameMap;
|
|
|
134 |
}
|
| 26228 |
amit.gupta |
135 |
|
|
|
136 |
private Map<Integer, RechargeOperator> rechargeCommissionsOperatorIdRechargeOperatorMap(
|
| 33247 |
ranu |
137 |
List<RechargeCommission> rechargeCommissions) throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
138 |
Map<Integer, RechargeOperator> rechargeOperatorIdNameMap = new HashMap<>();
|
| 26228 |
amit.gupta |
139 |
if (rechargeCommissions.isEmpty()) {
|
| 23528 |
ashik.ali |
140 |
return rechargeOperatorIdNameMap;
|
|
|
141 |
}
|
|
|
142 |
Set<Integer> operatorIds = new HashSet<>();
|
| 26228 |
amit.gupta |
143 |
for (RechargeCommission rechargeCommission : rechargeCommissions) {
|
| 23528 |
ashik.ali |
144 |
operatorIds.add(rechargeCommission.getOperatorId());
|
|
|
145 |
}
|
| 26228 |
amit.gupta |
146 |
|
| 23528 |
ashik.ali |
147 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByIds(operatorIds);
|
| 26228 |
amit.gupta |
148 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 23528 |
ashik.ali |
149 |
rechargeOperatorIdNameMap.put(rechargeOperator.getId(), rechargeOperator);
|
|
|
150 |
}
|
|
|
151 |
return rechargeOperatorIdNameMap;
|
|
|
152 |
}
|
| 26228 |
amit.gupta |
153 |
|
| 33247 |
ranu |
154 |
private Map<Integer, String> rechargeCommissionsProviderIdNameMap(List<RechargeCommission> rechargeCommissions) throws ProfitMandiBusinessException {
|
| 26228 |
amit.gupta |
155 |
if (rechargeCommissions.isEmpty()) {
|
| 23628 |
ashik.ali |
156 |
return new HashMap<>();
|
| 23575 |
ashik.ali |
157 |
}
|
|
|
158 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
159 |
for (RechargeCommission rechargeCommission : rechargeCommissions) {
|
| 23575 |
ashik.ali |
160 |
providerIds.add(rechargeCommission.getProviderId());
|
|
|
161 |
}
|
| 23628 |
ashik.ali |
162 |
return providerIdNameMap(providerIds);
|
|
|
163 |
}
|
| 26228 |
amit.gupta |
164 |
|
| 33247 |
ranu |
165 |
private Map<Integer, String> providerIdNameMap(Set<Integer> providerIds) throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
166 |
Map<Integer, String> rechargeProviderIdNameMap = new HashMap<>();
|
| 23575 |
ashik.ali |
167 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAllByIds(providerIds);
|
| 26228 |
amit.gupta |
168 |
for (RechargeProvider rechargeProvider : rechargeProviders) {
|
| 23575 |
ashik.ali |
169 |
rechargeProviderIdNameMap.put(rechargeProvider.getId(), rechargeProvider.getName());
|
|
|
170 |
}
|
|
|
171 |
return rechargeProviderIdNameMap;
|
|
|
172 |
}
|
| 26228 |
amit.gupta |
173 |
|
|
|
174 |
private Map<Integer, String> rechargeProviderCreditWalletHistoriesProviderIdNameMap(
|
| 33247 |
ranu |
175 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories) throws ProfitMandiBusinessException {
|
| 26228 |
amit.gupta |
176 |
if (rechargeProviderCreditWalletHistories.isEmpty()) {
|
| 23628 |
ashik.ali |
177 |
return new HashMap<>();
|
|
|
178 |
}
|
|
|
179 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
180 |
for (RechargeProviderCreditWalletHistory rechargeProviderCreditWalletHistory : rechargeProviderCreditWalletHistories) {
|
| 23628 |
ashik.ali |
181 |
providerIds.add(rechargeProviderCreditWalletHistory.getProviderId());
|
|
|
182 |
}
|
|
|
183 |
return this.providerIdNameMap(providerIds);
|
|
|
184 |
}
|
| 26228 |
amit.gupta |
185 |
|
| 33247 |
ranu |
186 |
private Map<Integer, String> dailyRechargesProviderIdNameMap(List<DailyRecharge> dailyRecharges) throws ProfitMandiBusinessException {
|
| 26228 |
amit.gupta |
187 |
if (dailyRecharges.isEmpty()) {
|
| 23628 |
ashik.ali |
188 |
return new HashMap<>();
|
|
|
189 |
}
|
|
|
190 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
191 |
for (DailyRecharge dailyRecharge : dailyRecharges) {
|
| 23628 |
ashik.ali |
192 |
providerIds.add(dailyRecharge.getProviderId());
|
|
|
193 |
}
|
|
|
194 |
return this.providerIdNameMap(providerIds);
|
|
|
195 |
}
|
| 26228 |
amit.gupta |
196 |
|
| 23505 |
ashik.ali |
197 |
@RequestMapping(value = "/createRecharge", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
198 |
public String createRecharge(HttpServletRequest request, @RequestBody RechargeRequest rechargeRequest,
|
|
|
199 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
200 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
201 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
202 |
LOGGER.info("Recharge request body {}", rechargeRequest);
|
| 23505 |
ashik.ali |
203 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26228 |
amit.gupta |
204 |
|
| 23559 |
ashik.ali |
205 |
RechargeCredential rechargeTransactionMobileCredential = new RechargeCredential();
|
| 23575 |
ashik.ali |
206 |
rechargeTransactionMobileCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionMobileUrl);
|
| 23628 |
ashik.ali |
207 |
rechargeTransactionMobileCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
208 |
rechargeTransactionMobileCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
209 |
rechargeTransactionMobileCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
210 |
|
| 23559 |
ashik.ali |
211 |
RechargeCredential rechargeTransactionDthCredential = new RechargeCredential();
|
| 23575 |
ashik.ali |
212 |
rechargeTransactionDthCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionDthUrl);
|
| 23628 |
ashik.ali |
213 |
rechargeTransactionDthCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
214 |
rechargeTransactionDthCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
215 |
rechargeTransactionDthCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
216 |
|
|
|
217 |
if (blockedRecharge.contains(loginDetails.getEmailId())) {
|
|
|
218 |
throw new ProfitMandiBusinessException("Recharge Provider", rechargeRequest.getOperatorId(),
|
|
|
219 |
"We are experiencing some problem right now.");
|
| 24261 |
amit.gupta |
220 |
}
|
| 26228 |
amit.gupta |
221 |
|
|
|
222 |
rechargeService.doRecharge(rechargeTransactionMobileCredential, rechargeTransactionDthCredential,
|
|
|
223 |
loginDetails.getFofoId(), rechargeRequest);
|
| 23505 |
ashik.ali |
224 |
RechargeType rechargeType = RechargeType.valueOf(rechargeRequest.getRechargeType());
|
| 26228 |
amit.gupta |
225 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
226 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
227 |
long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(),
|
|
|
228 |
rechargeType);
|
|
|
229 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
230 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
231 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
232 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
|
|
233 |
model.addAttribute("start", offset + 1);
|
|
|
234 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
235 |
if (rechargeTransactions.size() < limit) {
|
| 23505 |
ashik.ali |
236 |
model.addAttribute("end", offset + rechargeTransactions.size());
|
| 26228 |
amit.gupta |
237 |
} else {
|
| 23505 |
ashik.ali |
238 |
model.addAttribute("end", offset + limit);
|
|
|
239 |
}
|
| 26228 |
amit.gupta |
240 |
if (RechargeType.valueOf(rechargeRequest.getRechargeType()) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
241 |
return "mobile-recharges";
|
| 26228 |
amit.gupta |
242 |
} else {
|
| 23505 |
ashik.ali |
243 |
return "dth-recharges";
|
|
|
244 |
}
|
|
|
245 |
}
|
| 26228 |
amit.gupta |
246 |
|
| 23505 |
ashik.ali |
247 |
@RequestMapping(value = "/checkStatus", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
248 |
public String checkStatus(HttpServletRequest request,
|
|
|
249 |
@RequestParam(name = ProfitMandiConstants.REQUEST_ID) String requestId,
|
|
|
250 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
251 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
252 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
253 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
254 |
LOGGER.info("RequestId [{}], rechargeType [{}]", requestId, rechargeTypeString);
|
|
|
255 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23575 |
ashik.ali |
256 |
RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
|
|
|
257 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
| 23628 |
ashik.ali |
258 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
259 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
260 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
261 |
rechargeService.checkStatus(thinkWalnutDigitalRechargeEnquiryCredential, loginDetails.getFofoId(), requestId);
|
| 23505 |
ashik.ali |
262 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
263 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
264 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
265 |
// long size =
|
|
|
266 |
// rechargeTransactionRepository.selectCountByRetailerId(loginDetails.getFofoId());
|
|
|
267 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
268 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
269 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
270 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
| 26228 |
amit.gupta |
271 |
|
|
|
272 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
273 |
return "mobile-recharges-paginated";
|
| 26228 |
amit.gupta |
274 |
} else {
|
| 23505 |
ashik.ali |
275 |
return "dth-recharges-paginated";
|
|
|
276 |
}
|
|
|
277 |
}
|
| 26228 |
amit.gupta |
278 |
|
| 23505 |
ashik.ali |
279 |
@RequestMapping(value = "/getRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
280 |
public String getRecharges(HttpServletRequest request,
|
|
|
281 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
282 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
283 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
284 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
285 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
286 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
287 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
288 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
289 |
long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(),
|
|
|
290 |
rechargeType);
|
|
|
291 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
292 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
293 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
294 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
|
|
295 |
model.addAttribute("start", offset + 1);
|
|
|
296 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
297 |
if (rechargeTransactions.size() < limit) {
|
| 23505 |
ashik.ali |
298 |
model.addAttribute("end", offset + rechargeTransactions.size());
|
| 26228 |
amit.gupta |
299 |
} else {
|
| 23505 |
ashik.ali |
300 |
model.addAttribute("end", offset + limit);
|
|
|
301 |
}
|
| 26228 |
amit.gupta |
302 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
303 |
return "mobile-recharges";
|
| 26228 |
amit.gupta |
304 |
} else {
|
| 23505 |
ashik.ali |
305 |
return "dth-recharges";
|
|
|
306 |
}
|
|
|
307 |
}
|
| 26228 |
amit.gupta |
308 |
|
| 23505 |
ashik.ali |
309 |
@RequestMapping(value = "/getPaginatedRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
310 |
public String getPaginatedRecharges(HttpServletRequest request,
|
|
|
311 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
312 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
313 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
314 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
315 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
316 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
317 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
318 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
319 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
320 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
321 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
322 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
| 26228 |
amit.gupta |
323 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
324 |
return "mobile-recharges-paginated";
|
| 26228 |
amit.gupta |
325 |
} else {
|
| 23505 |
ashik.ali |
326 |
return "dth-recharges-paginated";
|
|
|
327 |
}
|
|
|
328 |
}
|
| 26228 |
amit.gupta |
329 |
|
| 23528 |
ashik.ali |
330 |
@RequestMapping(value = "/getRechargeOperators", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
331 |
public String getRechargeOperators(HttpServletRequest request,
|
|
|
332 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_TYPE) String operatorTypeString, Model model) {
|
|
|
333 |
// model.addAttribute("rechargeOperators",
|
|
|
334 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
335 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
| 23505 |
ashik.ali |
336 |
OperatorType operatorType = OperatorType.valueOf(operatorTypeString);
|
|
|
337 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(operatorType);
|
|
|
338 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
339 |
return "recharge-operators";
|
|
|
340 |
}
|
| 26228 |
amit.gupta |
341 |
|
| 23528 |
ashik.ali |
342 |
@RequestMapping(value = "/getRechargeCommissionOperators", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
343 |
public String getRechargeCommissionOperators(HttpServletRequest request,
|
|
|
344 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_TYPE) String operatorTypeString, Model model)
|
|
|
345 |
throws ProfitMandiBusinessException {
|
|
|
346 |
// model.addAttribute("rechargeOperators",
|
|
|
347 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
348 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
| 23528 |
ashik.ali |
349 |
OperatorType operatorType = OperatorType.valueOf(operatorTypeString);
|
|
|
350 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(operatorType);
|
|
|
351 |
List<Integer> rechargeOperatorIds = rechargeCommissionRepository.selectAllOperatorIds();
|
| 26228 |
amit.gupta |
352 |
if (!rechargeOperatorIds.isEmpty()) {
|
| 23528 |
ashik.ali |
353 |
rechargeOperators = this.filterRechargeOperators(rechargeOperators, rechargeOperatorIds);
|
| 26228 |
amit.gupta |
354 |
if (rechargeOperators.isEmpty()) {
|
| 23528 |
ashik.ali |
355 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.OPERATOR_TYPE, operatorType, "RCHRG_1003");
|
|
|
356 |
}
|
|
|
357 |
}
|
|
|
358 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
359 |
return "recharge-operators";
|
|
|
360 |
}
|
| 26228 |
amit.gupta |
361 |
|
| 23528 |
ashik.ali |
362 |
@RequestMapping(value = "/createRechargeCommission", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
363 |
public String createRechargeCommission(HttpServletRequest request,
|
| 30248 |
tejbeer |
364 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) RechargeType rechargeType, Model model)
|
| 26228 |
amit.gupta |
365 |
throws ProfitMandiBusinessException {
|
|
|
366 |
// model.addAttribute("rechargeOperators",
|
|
|
367 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
368 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
|
|
369 |
|
| 23528 |
ashik.ali |
370 |
List<RechargeOperator> rechargeOperators = null;
|
| 30248 |
tejbeer |
371 |
if (rechargeType.equals(RechargeType.MOBILE)) {
|
| 23528 |
ashik.ali |
372 |
model.addAttribute("operatorTypes", OperatorType.values());
|
|
|
373 |
rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(OperatorType.PREPAID);
|
| 26228 |
amit.gupta |
374 |
} else {
|
| 23528 |
ashik.ali |
375 |
rechargeOperators = rechargeOperatorRepository.selectAllByRechargeType(rechargeType);
|
|
|
376 |
}
|
|
|
377 |
List<Integer> rechargeOperatorIds = rechargeCommissionRepository.selectAllOperatorIds();
|
| 30248 |
tejbeer |
378 |
LOGGER.info("rechargeOperators" + rechargeOperators);
|
|
|
379 |
LOGGER.info("rechargeOperatorIds" + rechargeOperatorIds);
|
|
|
380 |
|
| 26228 |
amit.gupta |
381 |
if (!rechargeOperatorIds.isEmpty()) {
|
| 23528 |
ashik.ali |
382 |
rechargeOperators = this.filterRechargeOperators(rechargeOperators, rechargeOperatorIds);
|
| 26228 |
amit.gupta |
383 |
if (rechargeOperators.isEmpty()) {
|
| 23528 |
ashik.ali |
384 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RECHARGE_TYPE, rechargeType, "RCHRG_1003");
|
|
|
385 |
}
|
|
|
386 |
}
|
|
|
387 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
388 |
return "create-recharge-commission";
|
|
|
389 |
}
|
| 26228 |
amit.gupta |
390 |
|
|
|
391 |
private List<RechargeOperator> filterRechargeOperators(List<RechargeOperator> rechargeOperators,
|
|
|
392 |
List<Integer> rechargeOperatorIds) {
|
| 23528 |
ashik.ali |
393 |
List<RechargeOperator> filteredRechargeOperators = new ArrayList<>();
|
| 26228 |
amit.gupta |
394 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 30248 |
tejbeer |
395 |
if (rechargeOperatorIds.contains(rechargeOperator.getId())) {
|
| 23528 |
ashik.ali |
396 |
filteredRechargeOperators.add(rechargeOperator);
|
|
|
397 |
}
|
|
|
398 |
}
|
|
|
399 |
return filteredRechargeOperators;
|
|
|
400 |
}
|
| 26228 |
amit.gupta |
401 |
|
| 23528 |
ashik.ali |
402 |
@RequestMapping(value = "/createRechargeCommission", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
403 |
public String createRechargeCommission(HttpServletRequest request,
|
|
|
404 |
@RequestBody RechargeCommissionRequest rechargeCommissionRequest,
|
|
|
405 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
406 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
407 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
408 |
rechargeService.createRechargeCommission(rechargeCommissionRequest);
|
|
|
409 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
|
|
410 |
long size = rechargeCommissionRepository.selectAllCount();
|
| 26228 |
amit.gupta |
411 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
412 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
413 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
414 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
415 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
416 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
417 |
model.addAttribute("start", offset + 1);
|
|
|
418 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
419 |
if (rechargeCommissions.size() < limit) {
|
| 23528 |
ashik.ali |
420 |
model.addAttribute("end", offset + rechargeCommissions.size());
|
| 26228 |
amit.gupta |
421 |
} else {
|
| 23528 |
ashik.ali |
422 |
model.addAttribute("end", offset + limit);
|
|
|
423 |
}
|
|
|
424 |
return "recharge-commissions";
|
|
|
425 |
}
|
| 26228 |
amit.gupta |
426 |
|
| 23528 |
ashik.ali |
427 |
@RequestMapping(value = "/getRechargeCommissions", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
428 |
public String getRechargeCommissions(HttpServletRequest request,
|
|
|
429 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
430 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
431 |
throws ProfitMandiBusinessException {
|
|
|
432 |
// LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
433 |
// RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 23528 |
ashik.ali |
434 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
|
|
435 |
long size = rechargeCommissionRepository.selectAllCount();
|
| 26228 |
amit.gupta |
436 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
437 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
438 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
439 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
440 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
441 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
442 |
model.addAttribute("start", offset + 1);
|
|
|
443 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
444 |
if (rechargeCommissions.size() < limit) {
|
| 23528 |
ashik.ali |
445 |
model.addAttribute("end", offset + rechargeCommissions.size());
|
| 26228 |
amit.gupta |
446 |
} else {
|
| 23528 |
ashik.ali |
447 |
model.addAttribute("end", offset + limit);
|
|
|
448 |
}
|
|
|
449 |
return "recharge-commissions";
|
|
|
450 |
}
|
| 26228 |
amit.gupta |
451 |
|
| 23528 |
ashik.ali |
452 |
@RequestMapping(value = "/getPaginatedRechargeCommissions", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
453 |
public String getPaginatedRechargeCommissions(HttpServletRequest request,
|
|
|
454 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
455 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
456 |
throws ProfitMandiBusinessException {
|
|
|
457 |
// LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
458 |
// RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 23528 |
ashik.ali |
459 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
| 26228 |
amit.gupta |
460 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
461 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
462 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
463 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
464 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
465 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
466 |
return "recharge-commissions-paginated";
|
|
|
467 |
}
|
| 26228 |
amit.gupta |
468 |
|
| 23528 |
ashik.ali |
469 |
@RequestMapping(value = "/getRechargeCommissionByOperatorId", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
470 |
public String getRechargeCommissionByOperatorId(HttpServletRequest request,
|
|
|
471 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_ID) int operatorId,
|
|
|
472 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId, Model model)
|
|
|
473 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
474 |
RechargeOperator rechargeOperator = rechargeOperatorRepository.selectById(operatorId);
|
| 26228 |
amit.gupta |
475 |
RechargeCommission rechargeCommission = rechargeCommissionRepository.selectByOperatorIdAndProviderId(operatorId,
|
|
|
476 |
providerId);
|
| 23528 |
ashik.ali |
477 |
model.addAttribute("rechargeCommission", rechargeCommission);
|
|
|
478 |
model.addAttribute("rechargeOperator", rechargeOperator);
|
|
|
479 |
return "recharge-commission-details";
|
|
|
480 |
}
|
| 26228 |
amit.gupta |
481 |
|
| 23528 |
ashik.ali |
482 |
@RequestMapping(value = "/updateRechargeCommission", method = RequestMethod.PUT)
|
| 26228 |
amit.gupta |
483 |
public String updateRechargeCommission(HttpServletRequest request,
|
|
|
484 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_ID) int operatorId,
|
|
|
485 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
486 |
@RequestParam(name = ProfitMandiConstants.AMOUNT_TYPE) String amountTypeString,
|
|
|
487 |
@RequestParam(name = ProfitMandiConstants.AMOUNT) float amount,
|
|
|
488 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
489 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
490 |
throws ProfitMandiBusinessException {
|
| 23575 |
ashik.ali |
491 |
rechargeService.updateRechargeCommission(operatorId, providerId, amountTypeString, amount);
|
| 23528 |
ashik.ali |
492 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
| 26228 |
amit.gupta |
493 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
494 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
495 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
496 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
497 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
498 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
499 |
return "recharge-commissions-paginated";
|
|
|
500 |
}
|
| 26228 |
amit.gupta |
501 |
|
| 23628 |
ashik.ali |
502 |
@RequestMapping(value = "/getRechargeProviderBalance", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
503 |
public String getRechargeProviderBalance(HttpServletRequest request, Model model)
|
|
|
504 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
505 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
|
|
506 |
model.addAttribute("rechargeProviders", rechargeProviders);
|
|
|
507 |
model.addAttribute("providerBalanceFroms", ProviderBalanceFrom.values());
|
|
|
508 |
RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();
|
|
|
509 |
thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);
|
|
|
510 |
thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
511 |
thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
512 |
thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
513 |
model.addAttribute("rechargeProviderBalanceMaps",
|
|
|
514 |
rechargeService.getRechargeProvidersBalance(thinkWalnutDigitalRechargeCredential));
|
| 23628 |
ashik.ali |
515 |
return "recharge-provider-balance";
|
|
|
516 |
}
|
| 26228 |
amit.gupta |
517 |
|
| 23628 |
ashik.ali |
518 |
@RequestMapping(value = "/getRechargeProviderWalletAddMoney", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
519 |
public String getRechargeProviderWalletAddMoney(HttpServletRequest request, Model model)
|
|
|
520 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
521 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
|
|
522 |
model.addAttribute("rechargeProviders", rechargeProviders);
|
|
|
523 |
return "recharge-provider-wallet-add-money";
|
|
|
524 |
}
|
| 26228 |
amit.gupta |
525 |
|
| 23628 |
ashik.ali |
526 |
@RequestMapping(value = "/addMoneyToRechargeProviderWallet", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
527 |
public String createRechargeProviderWalletAddMoney(HttpServletRequest request,
|
|
|
528 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
529 |
@RequestParam(name = ProfitMandiConstants.AMOUNT) float amount, @RequestParam LocalDateTime receiveDateTime,
|
|
|
530 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
531 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
532 |
throws ProfitMandiBusinessException {
|
| 23886 |
amit.gupta |
533 |
rechargeService.createRechargeProviderCreditWallet(providerId, amount, receiveDateTime);
|
| 26228 |
amit.gupta |
534 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories = rechargeProviderCreditWalletHistoryRepository
|
|
|
535 |
.selectAll(offset, limit);
|
| 23628 |
ashik.ali |
536 |
long size = rechargeProviderCreditWalletHistoryRepository.selectAllCount();
|
| 26228 |
amit.gupta |
537 |
Map<Integer, String> rechargeProviderIdNameMap = this
|
|
|
538 |
.rechargeProviderCreditWalletHistoriesProviderIdNameMap(rechargeProviderCreditWalletHistories);
|
| 23628 |
ashik.ali |
539 |
model.addAttribute("rechargeProviderCreditWalletHistories", rechargeProviderCreditWalletHistories);
|
|
|
540 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
541 |
model.addAttribute("start", offset + 1);
|
|
|
542 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
543 |
if (rechargeProviderCreditWalletHistories.size() < limit) {
|
| 23628 |
ashik.ali |
544 |
model.addAttribute("end", offset + rechargeProviderCreditWalletHistories.size());
|
| 26228 |
amit.gupta |
545 |
} else {
|
| 23628 |
ashik.ali |
546 |
model.addAttribute("end", offset + limit);
|
|
|
547 |
}
|
|
|
548 |
return "recharge-provider-wallet-add-moneys";
|
|
|
549 |
}
|
| 26228 |
amit.gupta |
550 |
|
| 23628 |
ashik.ali |
551 |
@RequestMapping(value = "/getRechargeProviderWalletAddMoneys", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
552 |
public String getRechargeProviderWalletAddMoney(HttpServletRequest request,
|
|
|
553 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
554 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
555 |
throws ProfitMandiBusinessException {
|
|
|
556 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories = rechargeProviderCreditWalletHistoryRepository
|
|
|
557 |
.selectAll(offset, limit);
|
| 23628 |
ashik.ali |
558 |
long size = rechargeProviderCreditWalletHistoryRepository.selectAllCount();
|
| 26228 |
amit.gupta |
559 |
Map<Integer, String> rechargeProviderIdNameMap = this
|
|
|
560 |
.rechargeProviderCreditWalletHistoriesProviderIdNameMap(rechargeProviderCreditWalletHistories);
|
| 23628 |
ashik.ali |
561 |
model.addAttribute("rechargeProviderCreditWalletHistories", rechargeProviderCreditWalletHistories);
|
|
|
562 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
563 |
model.addAttribute("start", offset + 1);
|
|
|
564 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
565 |
if (rechargeProviderCreditWalletHistories.size() < limit) {
|
| 23628 |
ashik.ali |
566 |
model.addAttribute("end", offset + rechargeProviderCreditWalletHistories.size());
|
| 26228 |
amit.gupta |
567 |
} else {
|
| 23628 |
ashik.ali |
568 |
model.addAttribute("end", offset + limit);
|
|
|
569 |
}
|
|
|
570 |
return "recharge-provider-wallet-add-moneys";
|
|
|
571 |
}
|
| 26228 |
amit.gupta |
572 |
|
| 23628 |
ashik.ali |
573 |
@RequestMapping(value = "/getPaginatedRechargeProviderWalletAddMoneys", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
574 |
public String getPaginatedRechargeProviderWalletAddMoney(HttpServletRequest request,
|
|
|
575 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
576 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
577 |
throws ProfitMandiBusinessException {
|
|
|
578 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories = rechargeProviderCreditWalletHistoryRepository
|
|
|
579 |
.selectAll(offset, limit);
|
|
|
580 |
Map<Integer, String> rechargeProviderIdNameMap = this
|
|
|
581 |
.rechargeProviderCreditWalletHistoriesProviderIdNameMap(rechargeProviderCreditWalletHistories);
|
| 23628 |
ashik.ali |
582 |
model.addAttribute("rechargeProviderCreditWalletHistories", rechargeProviderCreditWalletHistories);
|
|
|
583 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
584 |
return "recharge-provider-wallet-add-moneys-paginated";
|
|
|
585 |
}
|
| 26228 |
amit.gupta |
586 |
|
| 23628 |
ashik.ali |
587 |
@RequestMapping(value = "/getDailyRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
588 |
public String getDailyRecharges(HttpServletRequest request,
|
|
|
589 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
590 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
591 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
592 |
List<DailyRecharge> dailyRecharges = dailyRechargeRepository.selectAll(offset, limit);
|
|
|
593 |
long size = dailyRechargeRepository.selectAllCount();
|
|
|
594 |
Map<Integer, String> rechargeProviderIdNameMap = this.dailyRechargesProviderIdNameMap(dailyRecharges);
|
|
|
595 |
model.addAttribute("dailyRecharges", dailyRecharges);
|
|
|
596 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
597 |
model.addAttribute("start", offset + 1);
|
|
|
598 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
599 |
if (dailyRecharges.size() < limit) {
|
| 23628 |
ashik.ali |
600 |
model.addAttribute("end", offset + dailyRecharges.size());
|
| 26228 |
amit.gupta |
601 |
} else {
|
| 23628 |
ashik.ali |
602 |
model.addAttribute("end", offset + limit);
|
|
|
603 |
}
|
|
|
604 |
return "daily-recharges";
|
|
|
605 |
}
|
| 26228 |
amit.gupta |
606 |
|
| 23628 |
ashik.ali |
607 |
@RequestMapping(value = "/getPaginatedDailyRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
608 |
public String getPaginatedDailyRecharges(HttpServletRequest request,
|
|
|
609 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
610 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
611 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
612 |
List<DailyRecharge> dailyRecharges = dailyRechargeRepository.selectAll(offset, limit);
|
|
|
613 |
Map<Integer, String> rechargeProviderIdNameMap = this.dailyRechargesProviderIdNameMap(dailyRecharges);
|
|
|
614 |
model.addAttribute("dailyRecharges", dailyRecharges);
|
|
|
615 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
616 |
return "daily-recharges-paginated";
|
|
|
617 |
}
|
| 26228 |
amit.gupta |
618 |
|
| 23628 |
ashik.ali |
619 |
@RequestMapping(value = "/getBalanceByProviderId", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
620 |
public ResponseEntity<?> getBalanceByProviderId(HttpServletRequest request,
|
|
|
621 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
622 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_BALANCE_FROM) ProviderBalanceFrom providerBalanceFrom)
|
|
|
623 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
624 |
RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();
|
|
|
625 |
thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);
|
|
|
626 |
thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
627 |
thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
628 |
thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
629 |
return responseSender.ok(
|
|
|
630 |
rechargeService.checkBalance(thinkWalnutDigitalRechargeCredential, providerId, providerBalanceFrom));
|
| 23628 |
ashik.ali |
631 |
}
|
| 26228 |
amit.gupta |
632 |
}
|