| 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 |
|
| 32457 |
jai.hind |
131 |
int paymentOption = 1;
|
|
|
132 |
Set<Integer> paymentOptionIds = new HashSet<>();
|
|
|
133 |
paymentOptionIds.add(1);
|
|
|
134 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(paymentOptionIds);
|
|
|
135 |
model.addAttribute("paymentOption", paymentOptions.get(0));
|
| 23505 |
ashik.ali |
136 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
137 |
return "create-recharge";
|
|
|
138 |
}
|
| 26228 |
amit.gupta |
139 |
|
|
|
140 |
private Map<Integer, String> rechargeTransactionsToRechargeOperatorIdNameMap(
|
|
|
141 |
List<RechargeTransaction> rechargeTransactions) {
|
| 23505 |
ashik.ali |
142 |
Map<Integer, String> rechargeOperatorIdrechargeOperatorNameMap = new HashMap<>();
|
| 26228 |
amit.gupta |
143 |
if (rechargeTransactions.isEmpty()) {
|
| 23505 |
ashik.ali |
144 |
return rechargeOperatorIdrechargeOperatorNameMap;
|
|
|
145 |
}
|
|
|
146 |
Set<Integer> operatorIds = new HashSet<>();
|
| 26228 |
amit.gupta |
147 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| 23505 |
ashik.ali |
148 |
operatorIds.add(rechargeTransaction.getOperatorId());
|
|
|
149 |
}
|
| 26228 |
amit.gupta |
150 |
|
| 23505 |
ashik.ali |
151 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByIds(operatorIds);
|
| 26228 |
amit.gupta |
152 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 23505 |
ashik.ali |
153 |
rechargeOperatorIdrechargeOperatorNameMap.put(rechargeOperator.getId(), rechargeOperator.getName());
|
|
|
154 |
}
|
|
|
155 |
return rechargeOperatorIdrechargeOperatorNameMap;
|
|
|
156 |
}
|
| 26228 |
amit.gupta |
157 |
|
|
|
158 |
private Map<Integer, RechargeOperator> rechargeCommissionsOperatorIdRechargeOperatorMap(
|
|
|
159 |
List<RechargeCommission> rechargeCommissions) {
|
| 23528 |
ashik.ali |
160 |
Map<Integer, RechargeOperator> rechargeOperatorIdNameMap = new HashMap<>();
|
| 26228 |
amit.gupta |
161 |
if (rechargeCommissions.isEmpty()) {
|
| 23528 |
ashik.ali |
162 |
return rechargeOperatorIdNameMap;
|
|
|
163 |
}
|
|
|
164 |
Set<Integer> operatorIds = new HashSet<>();
|
| 26228 |
amit.gupta |
165 |
for (RechargeCommission rechargeCommission : rechargeCommissions) {
|
| 23528 |
ashik.ali |
166 |
operatorIds.add(rechargeCommission.getOperatorId());
|
|
|
167 |
}
|
| 26228 |
amit.gupta |
168 |
|
| 23528 |
ashik.ali |
169 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByIds(operatorIds);
|
| 26228 |
amit.gupta |
170 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 23528 |
ashik.ali |
171 |
rechargeOperatorIdNameMap.put(rechargeOperator.getId(), rechargeOperator);
|
|
|
172 |
}
|
|
|
173 |
return rechargeOperatorIdNameMap;
|
|
|
174 |
}
|
| 26228 |
amit.gupta |
175 |
|
|
|
176 |
private Map<Integer, String> rechargeCommissionsProviderIdNameMap(List<RechargeCommission> rechargeCommissions) {
|
|
|
177 |
if (rechargeCommissions.isEmpty()) {
|
| 23628 |
ashik.ali |
178 |
return new HashMap<>();
|
| 23575 |
ashik.ali |
179 |
}
|
|
|
180 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
181 |
for (RechargeCommission rechargeCommission : rechargeCommissions) {
|
| 23575 |
ashik.ali |
182 |
providerIds.add(rechargeCommission.getProviderId());
|
|
|
183 |
}
|
| 23628 |
ashik.ali |
184 |
return providerIdNameMap(providerIds);
|
|
|
185 |
}
|
| 26228 |
amit.gupta |
186 |
|
|
|
187 |
private Map<Integer, String> providerIdNameMap(Set<Integer> providerIds) {
|
| 23628 |
ashik.ali |
188 |
Map<Integer, String> rechargeProviderIdNameMap = new HashMap<>();
|
| 23575 |
ashik.ali |
189 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAllByIds(providerIds);
|
| 26228 |
amit.gupta |
190 |
for (RechargeProvider rechargeProvider : rechargeProviders) {
|
| 23575 |
ashik.ali |
191 |
rechargeProviderIdNameMap.put(rechargeProvider.getId(), rechargeProvider.getName());
|
|
|
192 |
}
|
|
|
193 |
return rechargeProviderIdNameMap;
|
|
|
194 |
}
|
| 26228 |
amit.gupta |
195 |
|
|
|
196 |
private Map<Integer, String> rechargeProviderCreditWalletHistoriesProviderIdNameMap(
|
|
|
197 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories) {
|
|
|
198 |
if (rechargeProviderCreditWalletHistories.isEmpty()) {
|
| 23628 |
ashik.ali |
199 |
return new HashMap<>();
|
|
|
200 |
}
|
|
|
201 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
202 |
for (RechargeProviderCreditWalletHistory rechargeProviderCreditWalletHistory : rechargeProviderCreditWalletHistories) {
|
| 23628 |
ashik.ali |
203 |
providerIds.add(rechargeProviderCreditWalletHistory.getProviderId());
|
|
|
204 |
}
|
|
|
205 |
return this.providerIdNameMap(providerIds);
|
|
|
206 |
}
|
| 26228 |
amit.gupta |
207 |
|
|
|
208 |
private Map<Integer, String> dailyRechargesProviderIdNameMap(List<DailyRecharge> dailyRecharges) {
|
|
|
209 |
if (dailyRecharges.isEmpty()) {
|
| 23628 |
ashik.ali |
210 |
return new HashMap<>();
|
|
|
211 |
}
|
|
|
212 |
Set<Integer> providerIds = new HashSet<>();
|
| 26228 |
amit.gupta |
213 |
for (DailyRecharge dailyRecharge : dailyRecharges) {
|
| 23628 |
ashik.ali |
214 |
providerIds.add(dailyRecharge.getProviderId());
|
|
|
215 |
}
|
|
|
216 |
return this.providerIdNameMap(providerIds);
|
|
|
217 |
}
|
| 26228 |
amit.gupta |
218 |
|
| 23505 |
ashik.ali |
219 |
@RequestMapping(value = "/createRecharge", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
220 |
public String createRecharge(HttpServletRequest request, @RequestBody RechargeRequest rechargeRequest,
|
|
|
221 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
222 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
223 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
224 |
LOGGER.info("Recharge request body {}", rechargeRequest);
|
| 23505 |
ashik.ali |
225 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 26228 |
amit.gupta |
226 |
|
| 23559 |
ashik.ali |
227 |
RechargeCredential rechargeTransactionMobileCredential = new RechargeCredential();
|
| 23575 |
ashik.ali |
228 |
rechargeTransactionMobileCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionMobileUrl);
|
| 23628 |
ashik.ali |
229 |
rechargeTransactionMobileCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
230 |
rechargeTransactionMobileCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
231 |
rechargeTransactionMobileCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
232 |
|
| 23559 |
ashik.ali |
233 |
RechargeCredential rechargeTransactionDthCredential = new RechargeCredential();
|
| 23575 |
ashik.ali |
234 |
rechargeTransactionDthCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionDthUrl);
|
| 23628 |
ashik.ali |
235 |
rechargeTransactionDthCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
236 |
rechargeTransactionDthCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
237 |
rechargeTransactionDthCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
238 |
|
|
|
239 |
if (blockedRecharge.contains(loginDetails.getEmailId())) {
|
|
|
240 |
throw new ProfitMandiBusinessException("Recharge Provider", rechargeRequest.getOperatorId(),
|
|
|
241 |
"We are experiencing some problem right now.");
|
| 24261 |
amit.gupta |
242 |
}
|
| 26228 |
amit.gupta |
243 |
|
|
|
244 |
rechargeService.doRecharge(rechargeTransactionMobileCredential, rechargeTransactionDthCredential,
|
|
|
245 |
loginDetails.getFofoId(), rechargeRequest);
|
| 23505 |
ashik.ali |
246 |
RechargeType rechargeType = RechargeType.valueOf(rechargeRequest.getRechargeType());
|
| 26228 |
amit.gupta |
247 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
248 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
249 |
long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(),
|
|
|
250 |
rechargeType);
|
|
|
251 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
252 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
253 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
254 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
|
|
255 |
model.addAttribute("start", offset + 1);
|
|
|
256 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
257 |
if (rechargeTransactions.size() < limit) {
|
| 23505 |
ashik.ali |
258 |
model.addAttribute("end", offset + rechargeTransactions.size());
|
| 26228 |
amit.gupta |
259 |
} else {
|
| 23505 |
ashik.ali |
260 |
model.addAttribute("end", offset + limit);
|
|
|
261 |
}
|
| 26228 |
amit.gupta |
262 |
if (RechargeType.valueOf(rechargeRequest.getRechargeType()) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
263 |
return "mobile-recharges";
|
| 26228 |
amit.gupta |
264 |
} else {
|
| 23505 |
ashik.ali |
265 |
return "dth-recharges";
|
|
|
266 |
}
|
|
|
267 |
}
|
| 26228 |
amit.gupta |
268 |
|
| 23505 |
ashik.ali |
269 |
@RequestMapping(value = "/checkStatus", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
270 |
public String checkStatus(HttpServletRequest request,
|
|
|
271 |
@RequestParam(name = ProfitMandiConstants.REQUEST_ID) String requestId,
|
|
|
272 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
273 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
274 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
275 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
276 |
LOGGER.info("RequestId [{}], rechargeType [{}]", requestId, rechargeTypeString);
|
|
|
277 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23575 |
ashik.ali |
278 |
RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
|
|
|
279 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
| 23628 |
ashik.ali |
280 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
281 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 23575 |
ashik.ali |
282 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
283 |
rechargeService.checkStatus(thinkWalnutDigitalRechargeEnquiryCredential, loginDetails.getFofoId(), requestId);
|
| 23505 |
ashik.ali |
284 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
285 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
286 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
287 |
// long size =
|
|
|
288 |
// rechargeTransactionRepository.selectCountByRetailerId(loginDetails.getFofoId());
|
|
|
289 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
290 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
291 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
292 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
| 26228 |
amit.gupta |
293 |
|
|
|
294 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
295 |
return "mobile-recharges-paginated";
|
| 26228 |
amit.gupta |
296 |
} else {
|
| 23505 |
ashik.ali |
297 |
return "dth-recharges-paginated";
|
|
|
298 |
}
|
|
|
299 |
}
|
| 26228 |
amit.gupta |
300 |
|
| 23505 |
ashik.ali |
301 |
@RequestMapping(value = "/getRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
302 |
public String getRecharges(HttpServletRequest request,
|
|
|
303 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
304 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
305 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
306 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
307 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
308 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
309 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
310 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
311 |
long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(),
|
|
|
312 |
rechargeType);
|
|
|
313 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
314 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
315 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
316 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
|
|
317 |
model.addAttribute("start", offset + 1);
|
|
|
318 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
319 |
if (rechargeTransactions.size() < limit) {
|
| 23505 |
ashik.ali |
320 |
model.addAttribute("end", offset + rechargeTransactions.size());
|
| 26228 |
amit.gupta |
321 |
} else {
|
| 23505 |
ashik.ali |
322 |
model.addAttribute("end", offset + limit);
|
|
|
323 |
}
|
| 26228 |
amit.gupta |
324 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
325 |
return "mobile-recharges";
|
| 26228 |
amit.gupta |
326 |
} else {
|
| 23505 |
ashik.ali |
327 |
return "dth-recharges";
|
|
|
328 |
}
|
|
|
329 |
}
|
| 26228 |
amit.gupta |
330 |
|
| 23505 |
ashik.ali |
331 |
@RequestMapping(value = "/getPaginatedRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
332 |
public String getPaginatedRecharges(HttpServletRequest request,
|
|
|
333 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString,
|
|
|
334 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
335 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
336 |
throws ProfitMandiBusinessException {
|
| 23505 |
ashik.ali |
337 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
338 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 26228 |
amit.gupta |
339 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
340 |
.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
|
|
|
341 |
Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this
|
|
|
342 |
.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
|
| 23505 |
ashik.ali |
343 |
model.addAttribute("rechargeTransactions", rechargeTransactions);
|
|
|
344 |
model.addAttribute("rechargeOperatorIdRechargeOperatorNameMap", rechargeOperatorIdRechargeOperatorNameMap);
|
| 26228 |
amit.gupta |
345 |
if (RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 23505 |
ashik.ali |
346 |
return "mobile-recharges-paginated";
|
| 26228 |
amit.gupta |
347 |
} else {
|
| 23505 |
ashik.ali |
348 |
return "dth-recharges-paginated";
|
|
|
349 |
}
|
|
|
350 |
}
|
| 26228 |
amit.gupta |
351 |
|
| 23528 |
ashik.ali |
352 |
@RequestMapping(value = "/getRechargeOperators", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
353 |
public String getRechargeOperators(HttpServletRequest request,
|
|
|
354 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_TYPE) String operatorTypeString, Model model) {
|
|
|
355 |
// model.addAttribute("rechargeOperators",
|
|
|
356 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
357 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
| 23505 |
ashik.ali |
358 |
OperatorType operatorType = OperatorType.valueOf(operatorTypeString);
|
|
|
359 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(operatorType);
|
|
|
360 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
361 |
return "recharge-operators";
|
|
|
362 |
}
|
| 26228 |
amit.gupta |
363 |
|
| 23528 |
ashik.ali |
364 |
@RequestMapping(value = "/getRechargeCommissionOperators", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
365 |
public String getRechargeCommissionOperators(HttpServletRequest request,
|
|
|
366 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_TYPE) String operatorTypeString, Model model)
|
|
|
367 |
throws ProfitMandiBusinessException {
|
|
|
368 |
// model.addAttribute("rechargeOperators",
|
|
|
369 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
370 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
| 23528 |
ashik.ali |
371 |
OperatorType operatorType = OperatorType.valueOf(operatorTypeString);
|
|
|
372 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(operatorType);
|
|
|
373 |
List<Integer> rechargeOperatorIds = rechargeCommissionRepository.selectAllOperatorIds();
|
| 26228 |
amit.gupta |
374 |
if (!rechargeOperatorIds.isEmpty()) {
|
| 23528 |
ashik.ali |
375 |
rechargeOperators = this.filterRechargeOperators(rechargeOperators, rechargeOperatorIds);
|
| 26228 |
amit.gupta |
376 |
if (rechargeOperators.isEmpty()) {
|
| 23528 |
ashik.ali |
377 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.OPERATOR_TYPE, operatorType, "RCHRG_1003");
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
381 |
return "recharge-operators";
|
|
|
382 |
}
|
| 26228 |
amit.gupta |
383 |
|
| 23528 |
ashik.ali |
384 |
@RequestMapping(value = "/createRechargeCommission", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
385 |
public String createRechargeCommission(HttpServletRequest request,
|
| 30248 |
tejbeer |
386 |
@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) RechargeType rechargeType, Model model)
|
| 26228 |
amit.gupta |
387 |
throws ProfitMandiBusinessException {
|
|
|
388 |
// model.addAttribute("rechargeOperators",
|
|
|
389 |
// rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE));
|
|
|
390 |
// model.addAttribute("rechargeTypes", RechargeType.values());
|
|
|
391 |
|
| 23528 |
ashik.ali |
392 |
List<RechargeOperator> rechargeOperators = null;
|
| 30248 |
tejbeer |
393 |
if (rechargeType.equals(RechargeType.MOBILE)) {
|
| 23528 |
ashik.ali |
394 |
model.addAttribute("operatorTypes", OperatorType.values());
|
|
|
395 |
rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(OperatorType.PREPAID);
|
| 26228 |
amit.gupta |
396 |
} else {
|
| 23528 |
ashik.ali |
397 |
rechargeOperators = rechargeOperatorRepository.selectAllByRechargeType(rechargeType);
|
|
|
398 |
}
|
|
|
399 |
List<Integer> rechargeOperatorIds = rechargeCommissionRepository.selectAllOperatorIds();
|
| 30248 |
tejbeer |
400 |
LOGGER.info("rechargeOperators" + rechargeOperators);
|
|
|
401 |
LOGGER.info("rechargeOperatorIds" + rechargeOperatorIds);
|
|
|
402 |
|
| 26228 |
amit.gupta |
403 |
if (!rechargeOperatorIds.isEmpty()) {
|
| 23528 |
ashik.ali |
404 |
rechargeOperators = this.filterRechargeOperators(rechargeOperators, rechargeOperatorIds);
|
| 26228 |
amit.gupta |
405 |
if (rechargeOperators.isEmpty()) {
|
| 23528 |
ashik.ali |
406 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RECHARGE_TYPE, rechargeType, "RCHRG_1003");
|
|
|
407 |
}
|
|
|
408 |
}
|
|
|
409 |
model.addAttribute("rechargeOperators", rechargeOperators);
|
|
|
410 |
return "create-recharge-commission";
|
|
|
411 |
}
|
| 26228 |
amit.gupta |
412 |
|
|
|
413 |
private List<RechargeOperator> filterRechargeOperators(List<RechargeOperator> rechargeOperators,
|
|
|
414 |
List<Integer> rechargeOperatorIds) {
|
| 23528 |
ashik.ali |
415 |
List<RechargeOperator> filteredRechargeOperators = new ArrayList<>();
|
| 26228 |
amit.gupta |
416 |
for (RechargeOperator rechargeOperator : rechargeOperators) {
|
| 30248 |
tejbeer |
417 |
if (rechargeOperatorIds.contains(rechargeOperator.getId())) {
|
| 23528 |
ashik.ali |
418 |
filteredRechargeOperators.add(rechargeOperator);
|
|
|
419 |
}
|
|
|
420 |
}
|
|
|
421 |
return filteredRechargeOperators;
|
|
|
422 |
}
|
| 26228 |
amit.gupta |
423 |
|
| 23528 |
ashik.ali |
424 |
@RequestMapping(value = "/createRechargeCommission", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
425 |
public String createRechargeCommission(HttpServletRequest request,
|
|
|
426 |
@RequestBody RechargeCommissionRequest rechargeCommissionRequest,
|
|
|
427 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
428 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
429 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
430 |
rechargeService.createRechargeCommission(rechargeCommissionRequest);
|
|
|
431 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
|
|
432 |
long size = rechargeCommissionRepository.selectAllCount();
|
| 26228 |
amit.gupta |
433 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
434 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
435 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
436 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
437 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
438 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
439 |
model.addAttribute("start", offset + 1);
|
|
|
440 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
441 |
if (rechargeCommissions.size() < limit) {
|
| 23528 |
ashik.ali |
442 |
model.addAttribute("end", offset + rechargeCommissions.size());
|
| 26228 |
amit.gupta |
443 |
} else {
|
| 23528 |
ashik.ali |
444 |
model.addAttribute("end", offset + limit);
|
|
|
445 |
}
|
|
|
446 |
return "recharge-commissions";
|
|
|
447 |
}
|
| 26228 |
amit.gupta |
448 |
|
| 23528 |
ashik.ali |
449 |
@RequestMapping(value = "/getRechargeCommissions", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
450 |
public String getRechargeCommissions(HttpServletRequest request,
|
|
|
451 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
452 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
453 |
throws ProfitMandiBusinessException {
|
|
|
454 |
// LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
455 |
// RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 23528 |
ashik.ali |
456 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
|
|
457 |
long size = rechargeCommissionRepository.selectAllCount();
|
| 26228 |
amit.gupta |
458 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
459 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
460 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
461 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
462 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
463 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
464 |
model.addAttribute("start", offset + 1);
|
|
|
465 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
466 |
if (rechargeCommissions.size() < limit) {
|
| 23528 |
ashik.ali |
467 |
model.addAttribute("end", offset + rechargeCommissions.size());
|
| 26228 |
amit.gupta |
468 |
} else {
|
| 23528 |
ashik.ali |
469 |
model.addAttribute("end", offset + limit);
|
|
|
470 |
}
|
|
|
471 |
return "recharge-commissions";
|
|
|
472 |
}
|
| 26228 |
amit.gupta |
473 |
|
| 23528 |
ashik.ali |
474 |
@RequestMapping(value = "/getPaginatedRechargeCommissions", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
475 |
public String getPaginatedRechargeCommissions(HttpServletRequest request,
|
|
|
476 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
477 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
478 |
throws ProfitMandiBusinessException {
|
|
|
479 |
// LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
480 |
// RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 23528 |
ashik.ali |
481 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
| 26228 |
amit.gupta |
482 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
483 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
484 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
485 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
486 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
487 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
488 |
return "recharge-commissions-paginated";
|
|
|
489 |
}
|
| 26228 |
amit.gupta |
490 |
|
| 23528 |
ashik.ali |
491 |
@RequestMapping(value = "/getRechargeCommissionByOperatorId", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
492 |
public String getRechargeCommissionByOperatorId(HttpServletRequest request,
|
|
|
493 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_ID) int operatorId,
|
|
|
494 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId, Model model)
|
|
|
495 |
throws ProfitMandiBusinessException {
|
| 23528 |
ashik.ali |
496 |
RechargeOperator rechargeOperator = rechargeOperatorRepository.selectById(operatorId);
|
| 26228 |
amit.gupta |
497 |
RechargeCommission rechargeCommission = rechargeCommissionRepository.selectByOperatorIdAndProviderId(operatorId,
|
|
|
498 |
providerId);
|
| 23528 |
ashik.ali |
499 |
model.addAttribute("rechargeCommission", rechargeCommission);
|
|
|
500 |
model.addAttribute("rechargeOperator", rechargeOperator);
|
|
|
501 |
return "recharge-commission-details";
|
|
|
502 |
}
|
| 26228 |
amit.gupta |
503 |
|
| 23528 |
ashik.ali |
504 |
@RequestMapping(value = "/updateRechargeCommission", method = RequestMethod.PUT)
|
| 26228 |
amit.gupta |
505 |
public String updateRechargeCommission(HttpServletRequest request,
|
|
|
506 |
@RequestParam(name = ProfitMandiConstants.OPERATOR_ID) int operatorId,
|
|
|
507 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
508 |
@RequestParam(name = ProfitMandiConstants.AMOUNT_TYPE) String amountTypeString,
|
|
|
509 |
@RequestParam(name = ProfitMandiConstants.AMOUNT) float amount,
|
|
|
510 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
511 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
512 |
throws ProfitMandiBusinessException {
|
| 23575 |
ashik.ali |
513 |
rechargeService.updateRechargeCommission(operatorId, providerId, amountTypeString, amount);
|
| 23528 |
ashik.ali |
514 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
| 26228 |
amit.gupta |
515 |
Map<Integer, RechargeOperator> rechargeOperatorIdRechargeOperatorMap = this
|
|
|
516 |
.rechargeCommissionsOperatorIdRechargeOperatorMap(rechargeCommissions);
|
| 23575 |
ashik.ali |
517 |
Map<Integer, String> rechargeProviderIdNameMap = this.rechargeCommissionsProviderIdNameMap(rechargeCommissions);
|
| 23528 |
ashik.ali |
518 |
model.addAttribute("rechargeCommissions", rechargeCommissions);
|
|
|
519 |
model.addAttribute("rechargeOperatorIdRechargeOperatorMap", rechargeOperatorIdRechargeOperatorMap);
|
| 23575 |
ashik.ali |
520 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
| 23528 |
ashik.ali |
521 |
return "recharge-commissions-paginated";
|
|
|
522 |
}
|
| 26228 |
amit.gupta |
523 |
|
| 23628 |
ashik.ali |
524 |
@RequestMapping(value = "/getRechargeProviderBalance", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
525 |
public String getRechargeProviderBalance(HttpServletRequest request, Model model)
|
|
|
526 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
527 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
|
|
528 |
model.addAttribute("rechargeProviders", rechargeProviders);
|
|
|
529 |
model.addAttribute("providerBalanceFroms", ProviderBalanceFrom.values());
|
|
|
530 |
RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();
|
|
|
531 |
thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);
|
|
|
532 |
thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
533 |
thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
534 |
thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
535 |
model.addAttribute("rechargeProviderBalanceMaps",
|
|
|
536 |
rechargeService.getRechargeProvidersBalance(thinkWalnutDigitalRechargeCredential));
|
| 23628 |
ashik.ali |
537 |
return "recharge-provider-balance";
|
|
|
538 |
}
|
| 26228 |
amit.gupta |
539 |
|
| 23628 |
ashik.ali |
540 |
@RequestMapping(value = "/getRechargeProviderWalletAddMoney", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
541 |
public String getRechargeProviderWalletAddMoney(HttpServletRequest request, Model model)
|
|
|
542 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
543 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
|
|
544 |
model.addAttribute("rechargeProviders", rechargeProviders);
|
|
|
545 |
return "recharge-provider-wallet-add-money";
|
|
|
546 |
}
|
| 26228 |
amit.gupta |
547 |
|
| 23628 |
ashik.ali |
548 |
@RequestMapping(value = "/addMoneyToRechargeProviderWallet", method = RequestMethod.POST)
|
| 26228 |
amit.gupta |
549 |
public String createRechargeProviderWalletAddMoney(HttpServletRequest request,
|
|
|
550 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
551 |
@RequestParam(name = ProfitMandiConstants.AMOUNT) float amount, @RequestParam LocalDateTime receiveDateTime,
|
|
|
552 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
553 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
554 |
throws ProfitMandiBusinessException {
|
| 23886 |
amit.gupta |
555 |
rechargeService.createRechargeProviderCreditWallet(providerId, amount, receiveDateTime);
|
| 26228 |
amit.gupta |
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 = "/getRechargeProviderWalletAddMoneys", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
574 |
public String getRechargeProviderWalletAddMoney(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);
|
| 23628 |
ashik.ali |
580 |
long size = rechargeProviderCreditWalletHistoryRepository.selectAllCount();
|
| 26228 |
amit.gupta |
581 |
Map<Integer, String> rechargeProviderIdNameMap = this
|
|
|
582 |
.rechargeProviderCreditWalletHistoriesProviderIdNameMap(rechargeProviderCreditWalletHistories);
|
| 23628 |
ashik.ali |
583 |
model.addAttribute("rechargeProviderCreditWalletHistories", rechargeProviderCreditWalletHistories);
|
|
|
584 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
585 |
model.addAttribute("start", offset + 1);
|
|
|
586 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
587 |
if (rechargeProviderCreditWalletHistories.size() < limit) {
|
| 23628 |
ashik.ali |
588 |
model.addAttribute("end", offset + rechargeProviderCreditWalletHistories.size());
|
| 26228 |
amit.gupta |
589 |
} else {
|
| 23628 |
ashik.ali |
590 |
model.addAttribute("end", offset + limit);
|
|
|
591 |
}
|
|
|
592 |
return "recharge-provider-wallet-add-moneys";
|
|
|
593 |
}
|
| 26228 |
amit.gupta |
594 |
|
| 23628 |
ashik.ali |
595 |
@RequestMapping(value = "/getPaginatedRechargeProviderWalletAddMoneys", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
596 |
public String getPaginatedRechargeProviderWalletAddMoney(HttpServletRequest request,
|
|
|
597 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
598 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
599 |
throws ProfitMandiBusinessException {
|
|
|
600 |
List<RechargeProviderCreditWalletHistory> rechargeProviderCreditWalletHistories = rechargeProviderCreditWalletHistoryRepository
|
|
|
601 |
.selectAll(offset, limit);
|
|
|
602 |
Map<Integer, String> rechargeProviderIdNameMap = this
|
|
|
603 |
.rechargeProviderCreditWalletHistoriesProviderIdNameMap(rechargeProviderCreditWalletHistories);
|
| 23628 |
ashik.ali |
604 |
model.addAttribute("rechargeProviderCreditWalletHistories", rechargeProviderCreditWalletHistories);
|
|
|
605 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
606 |
return "recharge-provider-wallet-add-moneys-paginated";
|
|
|
607 |
}
|
| 26228 |
amit.gupta |
608 |
|
| 23628 |
ashik.ali |
609 |
@RequestMapping(value = "/getDailyRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
610 |
public String getDailyRecharges(HttpServletRequest request,
|
|
|
611 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
612 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
613 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
614 |
List<DailyRecharge> dailyRecharges = dailyRechargeRepository.selectAll(offset, limit);
|
|
|
615 |
long size = dailyRechargeRepository.selectAllCount();
|
|
|
616 |
Map<Integer, String> rechargeProviderIdNameMap = this.dailyRechargesProviderIdNameMap(dailyRecharges);
|
|
|
617 |
model.addAttribute("dailyRecharges", dailyRecharges);
|
|
|
618 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
619 |
model.addAttribute("start", offset + 1);
|
|
|
620 |
model.addAttribute("size", size);
|
| 26228 |
amit.gupta |
621 |
if (dailyRecharges.size() < limit) {
|
| 23628 |
ashik.ali |
622 |
model.addAttribute("end", offset + dailyRecharges.size());
|
| 26228 |
amit.gupta |
623 |
} else {
|
| 23628 |
ashik.ali |
624 |
model.addAttribute("end", offset + limit);
|
|
|
625 |
}
|
|
|
626 |
return "daily-recharges";
|
|
|
627 |
}
|
| 26228 |
amit.gupta |
628 |
|
| 23628 |
ashik.ali |
629 |
@RequestMapping(value = "/getPaginatedDailyRecharges", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
630 |
public String getPaginatedDailyRecharges(HttpServletRequest request,
|
|
|
631 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
632 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
633 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
634 |
List<DailyRecharge> dailyRecharges = dailyRechargeRepository.selectAll(offset, limit);
|
|
|
635 |
Map<Integer, String> rechargeProviderIdNameMap = this.dailyRechargesProviderIdNameMap(dailyRecharges);
|
|
|
636 |
model.addAttribute("dailyRecharges", dailyRecharges);
|
|
|
637 |
model.addAttribute("rechargeProviderIdNameMap", rechargeProviderIdNameMap);
|
|
|
638 |
return "daily-recharges-paginated";
|
|
|
639 |
}
|
| 26228 |
amit.gupta |
640 |
|
| 23628 |
ashik.ali |
641 |
@RequestMapping(value = "/getBalanceByProviderId", method = RequestMethod.GET)
|
| 26228 |
amit.gupta |
642 |
public ResponseEntity<?> getBalanceByProviderId(HttpServletRequest request,
|
|
|
643 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_ID) int providerId,
|
|
|
644 |
@RequestParam(name = ProfitMandiConstants.PROVIDER_BALANCE_FROM) ProviderBalanceFrom providerBalanceFrom)
|
|
|
645 |
throws ProfitMandiBusinessException {
|
| 23628 |
ashik.ali |
646 |
RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();
|
|
|
647 |
thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);
|
|
|
648 |
thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
649 |
thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
650 |
thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 26228 |
amit.gupta |
651 |
return responseSender.ok(
|
|
|
652 |
rechargeService.checkBalance(thinkWalnutDigitalRechargeCredential, providerId, providerBalanceFrom));
|
| 23628 |
ashik.ali |
653 |
}
|
| 26228 |
amit.gupta |
654 |
}
|