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