| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
| - |
|
4 |
import java.util.Collection;
|
| - |
|
5 |
import java.util.Collections;
|
| - |
|
6 |
import java.util.HashMap;
|
| - |
|
7 |
import java.util.HashSet;
|
| - |
|
8 |
import java.util.LinkedHashSet;
|
| 4 |
import java.util.List;
|
9 |
import java.util.List;
|
| 5 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| - |
|
11 |
import java.util.Optional;
|
| - |
|
12 |
import java.util.Set;
|
| - |
|
13 |
import java.util.stream.Collector;
|
| - |
|
14 |
import java.util.stream.Collectors;
|
| 6 |
|
15 |
|
| - |
|
16 |
import javax.annotation.PostConstruct;
|
| 7 |
import javax.servlet.http.HttpServletRequest;
|
17 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
18 |
import javax.swing.SortOrder;
|
| - |
|
19 |
|
| 8 |
import org.apache.thrift.TException;
|
20 |
import org.apache.thrift.TException;
|
| 9 |
import org.apache.thrift.transport.TTransportException;
|
21 |
import org.apache.thrift.transport.TTransportException;
|
| 10 |
import org.apache.logging.log4j.Logger;
|
22 |
import org.slf4j.Logger;
|
| 11 |
import org.apache.logging.log4j.LogManager;
|
23 |
import org.slf4j.LoggerFactory;
|
| 12 |
import org.springframework.beans.factory.annotation.Autowired;
|
24 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
25 |
import org.springframework.beans.factory.annotation.Value;
|
| 13 |
import org.springframework.http.MediaType;
|
26 |
import org.springframework.http.MediaType;
|
| 14 |
import org.springframework.http.ResponseEntity;
|
27 |
import org.springframework.http.ResponseEntity;
|
| 15 |
import org.springframework.stereotype.Controller;
|
28 |
import org.springframework.stereotype.Controller;
|
| 16 |
import org.springframework.transaction.annotation.Transactional;
|
29 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
30 |
import org.springframework.ui.Model;
|
| 17 |
import org.springframework.web.bind.annotation.RequestBody;
|
31 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
32 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
33 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 20 |
import org.springframework.web.bind.annotation.RequestParam;
|
34 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21 |
|
35 |
|
| - |
|
36 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| - |
|
37 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 22 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
39 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
| - |
|
40 |
import com.spice.profitmandi.common.model.OperatorType;
|
| 23 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
41 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
42 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| - |
|
43 |
import com.spice.profitmandi.common.model.RechargeRequest;
|
| - |
|
44 |
import com.spice.profitmandi.common.model.RechargeResponse;
|
| 24 |
import com.spice.profitmandi.common.util.Utils;
|
45 |
import com.spice.profitmandi.common.util.Utils;
|
| 25 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
46 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| - |
|
47 |
import com.spice.profitmandi.dao.entity.dtr.RechargeCommission;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.dtr.RechargeOperator;
|
| - |
|
49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| - |
|
50 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 26 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
51 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 27 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
52 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
53 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| - |
|
54 |
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
|
| - |
|
55 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| - |
|
56 |
import com.spice.profitmandi.dao.repository.dtr.RechargeCommissionRepository;
|
| - |
|
57 |
import com.spice.profitmandi.dao.repository.dtr.RechargeOperatorRepository;
|
| - |
|
58 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| - |
|
59 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
60 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
61 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.transaction.PendingRechargeCommissionRepository;
|
62 |
import com.spice.profitmandi.dao.repository.transaction.PendingRechargeCommissionRepository;
|
| - |
|
63 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| - |
|
64 |
import com.spice.profitmandi.service.recharge.RechargeService;
|
| 32 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
65 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| 33 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
66 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| 34 |
import com.spice.profitmandi.web.req.CreateRechargeRequest;
|
67 |
import com.spice.profitmandi.web.req.CreateRechargeRequest;
|
| 35 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
68 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
| 36 |
import com.spice.profitmandi.web.res.CreateRechargeResponse;
|
69 |
import com.spice.profitmandi.web.res.CreateRechargeResponse;
|
| 37 |
import com.spice.profitmandi.web.res.MyRechargesResponse;
|
70 |
import com.spice.profitmandi.web.res.MyRechargesResponse;
|
| 38 |
import com.spice.profitmandi.web.res.RechargeResultPojo;
|
71 |
import com.spice.profitmandi.web.res.RechargeResultPojo;
|
| - |
|
72 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| - |
|
73 |
|
| 39 |
import in.shop2020.model.v1.order.DenominationType;
|
74 |
import in.shop2020.model.v1.order.DenominationType;
|
| 40 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
75 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
| 41 |
import in.shop2020.model.v1.order.OrderType;
|
76 |
import in.shop2020.model.v1.order.OrderType;
|
| 42 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
77 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
| 43 |
import in.shop2020.model.v1.order.RechargeOrder;
|
78 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 44 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
79 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
| 45 |
import in.shop2020.model.v1.order.RechargeType;
|
- |
|
| 46 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
80 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 47 |
import in.shop2020.model.v1.order.UserWallet;
|
- |
|
| - |
|
81 |
|
| 48 |
import in.shop2020.payments.Payment;
|
82 |
import in.shop2020.payments.Payment;
|
| 49 |
import in.shop2020.payments.PaymentException;
|
83 |
import in.shop2020.payments.PaymentException;
|
| 50 |
import in.shop2020.payments.PaymentStatus;
|
84 |
import in.shop2020.payments.PaymentStatus;
|
| 51 |
import io.swagger.annotations.ApiImplicitParam;
|
85 |
import io.swagger.annotations.ApiImplicitParam;
|
| 52 |
import io.swagger.annotations.ApiImplicitParams;
|
86 |
import io.swagger.annotations.ApiImplicitParams;
|
| Line 54... |
Line 88... |
| 54 |
|
88 |
|
| 55 |
@Controller
|
89 |
@Controller
|
| 56 |
@Transactional(rollbackFor=Throwable.class)
|
90 |
@Transactional(rollbackFor=Throwable.class)
|
| 57 |
public class RechargeController {
|
91 |
public class RechargeController {
|
| 58 |
|
92 |
|
| 59 |
private static final Logger log=LogManager.getLogger(RechargeController.class);
|
93 |
private static final Logger log=LoggerFactory.getLogger(RechargeController.class);
|
| 60 |
private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
|
94 |
private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
|
| 61 |
private static final String X_REAL_IP = "X-Real-IP";
|
95 |
private static final String X_REAL_IP = "X-Real-IP";
|
| - |
|
96 |
@Value("${oxigen.recharge.transaction.url}")
|
| - |
|
97 |
private String oxigenRechargeTransactionUrl;
|
| - |
|
98 |
|
| - |
|
99 |
@Value("${oxigen.recharge.enquiry.url}")
|
| - |
|
100 |
private String oxigenRechargeEnquiryUrl;
|
| - |
|
101 |
|
| - |
|
102 |
@Value("${oxigen.recharge.auth.key}")
|
| - |
|
103 |
private String oxigenRechargeAuthKey;
|
| - |
|
104 |
|
| - |
|
105 |
@Value("${oxigen.recharge.validation.url}")
|
| - |
|
106 |
private String oxigenRechargeValidationUrl;
|
| - |
|
107 |
|
| - |
|
108 |
@Value("${oxigen.recharge.validation.auth.key}")
|
| - |
|
109 |
private String oxigenRechargeValidationAuthKey;
|
| - |
|
110 |
|
| - |
|
111 |
@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
|
| - |
|
112 |
private String thinkWalnutDigitalRechargeTransactionMobileUrl;
|
| - |
|
113 |
|
| - |
|
114 |
@Value("${think.walnut.digital.recharge.transaction.mobile.username}")
|
| - |
|
115 |
private String thinkWalnutDigitalRechargeTransactionMobileUserName;
|
| - |
|
116 |
|
| - |
|
117 |
@Value("${think.walnut.digital.recharge.transaction.mobile.password}")
|
| - |
|
118 |
private String thinkWalnutDigitalRechargeTransactionMobilePassword;
|
| - |
|
119 |
|
| - |
|
120 |
@Value("${think.walnut.digital.recharge.transaction.dth.url}")
|
| - |
|
121 |
private String thinkWalnutDigitalRechargeTransactionDthUrl;
|
| - |
|
122 |
|
| - |
|
123 |
@Value("${think.walnut.digital.recharge.transaction.dth.username}")
|
| - |
|
124 |
private String thinkWalnutDigitalRechargeTransactionDthUserName;
|
| - |
|
125 |
|
| - |
|
126 |
@Value("${think.walnut.digital.recharge.transaction.dth.password}")
|
| - |
|
127 |
private String thinkWalnutDigitalRechargeTransactionDthPassword;
|
| - |
|
128 |
|
| - |
|
129 |
@Value("${think.walnut.digital.recharge.enquiry.url}")
|
| - |
|
130 |
private String thinkWalnutDigitalRechargeEnquiryUrl;
|
| - |
|
131 |
|
| - |
|
132 |
@Value("${think.walnut.digital.recharge.enquiry.username}")
|
| - |
|
133 |
private String thinkWalnutDigitalRechargeEnquiryUserName;
|
| - |
|
134 |
|
| - |
|
135 |
@Value("${think.walnut.digital.recharge.enquiry.password}")
|
| - |
|
136 |
private String thinkWalnutDigitalRechargeEnquiryPassword;
|
| - |
|
137 |
|
| - |
|
138 |
@Value("${think.walnut.digital.recharge.auth.key}")
|
| - |
|
139 |
private String thinkWalnutDigitalRechargeAuthKey;
|
| - |
|
140 |
|
| - |
|
141 |
@Autowired
|
| - |
|
142 |
UserWalletRepository userWalletRepository;
|
| - |
|
143 |
|
| - |
|
144 |
@Autowired
|
| - |
|
145 |
private GenericRepository genericRepository;
|
| - |
|
146 |
|
| - |
|
147 |
@Autowired
|
| - |
|
148 |
private RechargeCommissionRepository rechargeCommissionRepository;
|
| 62 |
|
149 |
|
| 63 |
@Autowired
|
150 |
@Autowired
|
| 64 |
private UserAccountRepository userAccountRepository;
|
151 |
private UserAccountRepository userAccountRepository;
|
| - |
|
152 |
|
| - |
|
153 |
@Autowired
|
| - |
|
154 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 65 |
|
155 |
|
| 66 |
@Autowired
|
156 |
@Autowired
|
| - |
|
157 |
private RechargeProviderRepository rechargeProviderRepository;
|
| - |
|
158 |
|
| - |
|
159 |
@Autowired
|
| 67 |
private UserRepository userRepository;
|
160 |
private UserRepository userRepository;
|
| 68 |
|
161 |
|
| 69 |
@Autowired
|
162 |
@Autowired
|
| - |
|
163 |
private RechargeOperatorRepository rechargeOperatorRepository;
|
| - |
|
164 |
|
| - |
|
165 |
@Autowired
|
| - |
|
166 |
private RechargeService rechargeService;
|
| - |
|
167 |
|
| - |
|
168 |
@Autowired
|
| 70 |
private PendingRechargeCommissionRepository pendingRechargeCommissionRepository;
|
169 |
private PendingRechargeCommissionRepository pendingRechargeCommissionRepository;
|
| 71 |
|
170 |
|
| 72 |
@Autowired
|
171 |
@Autowired
|
| 73 |
private ResponseSender<?> responseSender;
|
172 |
private ResponseSender<?> responseSender;
|
| - |
|
173 |
|
| - |
|
174 |
private RechargeCredential rechargeTransactionMobileCredential;
|
| - |
|
175 |
private RechargeCredential rechargeTransactionDthCredential;
|
| - |
|
176 |
private RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential;
|
| 74 |
|
177 |
|
| 75 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
178 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 76 |
@ApiImplicitParams({
|
179 |
@ApiImplicitParams({
|
| 77 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
180 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 78 |
required = true, dataType = "string", paramType = "header")
|
181 |
required = true, dataType = "string", paramType = "header")
|
| Line 81... |
Line 184... |
| 81 |
public ResponseEntity<?> getServiceProvider(HttpServletRequest request, @RequestParam(value="deviceNumber") String deviceNumber, @RequestParam(value="rechargeType") String rechargeType){
|
184 |
public ResponseEntity<?> getServiceProvider(HttpServletRequest request, @RequestParam(value="deviceNumber") String deviceNumber, @RequestParam(value="rechargeType") String rechargeType){
|
| 82 |
DeviceNumberInfo deviceInfo = null;
|
185 |
DeviceNumberInfo deviceInfo = null;
|
| 83 |
TransactionClient tcl;
|
186 |
TransactionClient tcl;
|
| 84 |
try {
|
187 |
try {
|
| 85 |
tcl = new TransactionClient();
|
188 |
tcl = new TransactionClient();
|
| 86 |
deviceInfo = tcl.getClient().getServiceProviderForDevice(RechargeType.valueOf(rechargeType), deviceNumber.substring(0,4));
|
189 |
//deviceInfo = tcl.getClient().getServiceProviderForDevice(RechargeType.valueOf(rechargeType), deviceNumber.substring(0,4));
|
| 87 |
} catch (Exception e) {
|
190 |
} catch (Exception e) {
|
| 88 |
log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " + rechargeType, e);
|
191 |
log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " + rechargeType, e);
|
| 89 |
}
|
192 |
}
|
| 90 |
return responseSender.ok(deviceInfo);
|
193 |
return responseSender.ok(deviceInfo);
|
| 91 |
}
|
194 |
}
|
| Line 106... |
Line 209... |
| 106 |
log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleCode : " + circleCode + " and DenominationType : " + denominationType, e);
|
209 |
log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleCode : " + circleCode + " and DenominationType : " + denominationType, e);
|
| 107 |
}
|
210 |
}
|
| 108 |
return responseSender.ok(rechargeDenominations);
|
211 |
return responseSender.ok(rechargeDenominations);
|
| 109 |
}
|
212 |
}
|
| 110 |
|
213 |
|
| 111 |
@RequestMapping(value = ProfitMandiConstants.URL_MOBILE_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
214 |
@RequestMapping(value = ProfitMandiConstants.URL_MOBILE_OPERATORS, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 112 |
@ApiImplicitParams({
|
215 |
@ApiImplicitParams({
|
| 113 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
216 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 114 |
required = true, dataType = "string", paramType = "header")
|
217 |
required = true, dataType = "string", paramType = "header")
|
| 115 |
})
|
218 |
})
|
| - |
|
219 |
|
| 116 |
@ApiOperation(value = "")
|
220 |
@ApiOperation(value = "")
|
| 117 |
public ResponseEntity<?> getAllMobileOperators(HttpServletRequest request){
|
221 |
public ResponseEntity<?> getAllMobileOperators(HttpServletRequest request,@RequestParam(name = ProfitMandiConstants.OPERATOR_TYPE) OperatorType operatorType){
|
| 118 |
Map<Long, String> mobileProviderMap = Utils.getMobileProvidersMap();
|
222 |
Map<Integer, String> mobileProviderMap = new HashMap<>();
|
| - |
|
223 |
List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByOperatorType(operatorType);
|
| - |
|
224 |
// List<RechargeOperator> rechargeOperators = rechargeOperatorRepository.selectAllByRechargeType(RechargeType.MOBILE);
|
| - |
|
225 |
for(RechargeOperator rechargeOperator : rechargeOperators) {
|
| - |
|
226 |
mobileProviderMap.put(rechargeOperator.getId(), rechargeOperator.getName());
|
| - |
|
227 |
}
|
| 119 |
return responseSender.ok(mobileProviderMap);
|
228 |
return responseSender.ok(mobileProviderMap);
|
| 120 |
}
|
229 |
}
|
| 121 |
|
230 |
|
| 122 |
@RequestMapping(value = ProfitMandiConstants.URL_DTH_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
231 |
@RequestMapping(value = ProfitMandiConstants.URL_DTH_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 123 |
@ApiImplicitParams({
|
232 |
@ApiImplicitParams({
|
| 124 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
233 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 125 |
required = true, dataType = "string", paramType = "header")
|
234 |
required = true, dataType = "string", paramType = "header")
|
| 126 |
})
|
235 |
})
|
| 127 |
@ApiOperation(value = "")
|
236 |
@ApiOperation(value = "")
|
| 128 |
public ResponseEntity<?> getAllDTHOperators(HttpServletRequest request){
|
237 |
public ResponseEntity<?> getAllDTHOperators(HttpServletRequest request){
|
| 129 |
Map<Long, String> dthProviderMap = Utils.getDthProvidersMap();
|
238 |
Map<Integer, String> dthProviderMap = new HashMap<>();
|
| - |
|
239 |
List<RechargeOperator> dthOperators = rechargeOperatorRepository.selectAllByRechargeType(RechargeType.DTH);
|
| - |
|
240 |
for(RechargeOperator dthOperator : dthOperators) {
|
| - |
|
241 |
dthProviderMap.put(dthOperator.getId(), dthOperator.getName());
|
| - |
|
242 |
}
|
| 130 |
return responseSender.ok(dthProviderMap);
|
243 |
return responseSender.ok(dthProviderMap);
|
| - |
|
244 |
|
| - |
|
245 |
|
| 131 |
}
|
246 |
}
|
| 132 |
|
247 |
|
| 133 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_CONFIRM, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
248 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_CONFIRM, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 134 |
@ApiImplicitParams({
|
249 |
@ApiImplicitParams({
|
| 135 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
250 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| Line 147... |
Line 262... |
| 147 |
|
262 |
|
| 148 |
userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
|
263 |
userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
|
| 149 |
|
264 |
|
| 150 |
try {
|
265 |
try {
|
| 151 |
TransactionClient tc = new TransactionClient();
|
266 |
TransactionClient tc = new TransactionClient();
|
| 152 |
wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccountKey()));
|
267 |
//wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccountKey()));
|
| 153 |
} catch (NumberFormatException | TException e) {
|
268 |
} catch (NumberFormatException | TException e) {
|
| 154 |
return responseSender.internalServerError(e);
|
269 |
return responseSender.internalServerError(e);
|
| 155 |
}
|
270 |
}
|
| 156 |
|
271 |
|
| 157 |
ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
|
272 |
ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
|
| 158 |
crr.setWalletAmount(wallet.getAmount());
|
273 |
//crr.setWalletAmount(wallet.getAmount());
|
| 159 |
crr.setWalletAmountLeft(wallet.getAmount() - rechargeAmount);
|
274 |
crr.setWalletAmountLeft(wallet.getAmount() - rechargeAmount);
|
| 160 |
crr.setCanProceed(true);
|
275 |
crr.setCanProceed(true);
|
| 161 |
if (crr.getWalletAmountLeft() < 0){
|
276 |
if (crr.getWalletAmountLeft() < 0){
|
| 162 |
crr.setCanProceed(false);
|
277 |
crr.setCanProceed(false);
|
| 163 |
crr.setReason("You don't have sufficient wallet balance");
|
278 |
crr.setReason("You don't have sufficient wallet balance");
|
| Line 175... |
Line 290... |
| 175 |
throws ProfitMandiBusinessException{
|
290 |
throws ProfitMandiBusinessException{
|
| 176 |
int userId = (int)request.getAttribute(ProfitMandiConstants.USER_ID);
|
291 |
int userId = (int)request.getAttribute(ProfitMandiConstants.USER_ID);
|
| 177 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
292 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
| 178 |
return responseSender.ok(pendingRechargeCommissionRepository.selectByRetailerId(retailerId));
|
293 |
return responseSender.ok(pendingRechargeCommissionRepository.selectByRetailerId(retailerId));
|
| 179 |
}
|
294 |
}
|
| 180 |
|
295 |
|
| - |
|
296 |
private RechargeRequest convertRechargeRequest (CreateRechargeRequest createRechargeRequest ){
|
| - |
|
297 |
RechargeRequest rr= new RechargeRequest();
|
| - |
|
298 |
rr.setAmount(createRechargeRequest.getRechargeAmount());
|
| - |
|
299 |
rr.setOperatorId((int) createRechargeRequest.getOperatorId());
|
| - |
|
300 |
rr.setOperatorType(createRechargeRequest.getPlan());
|
| - |
|
301 |
rr.setReferenceNumber(createRechargeRequest.getNumber());
|
| - |
|
302 |
rr.setRechargeType(createRechargeRequest.getRechargeType());
|
| - |
|
303 |
|
| - |
|
304 |
Set<CustomPaymentOption> pp = new LinkedHashSet<>();
|
| - |
|
305 |
CustomPaymentOption cpo = new CustomPaymentOption();
|
| - |
|
306 |
cpo.setPaymentOption("cash");
|
| - |
|
307 |
cpo.setPaymentOptionId(1);
|
| - |
|
308 |
cpo.setAmount(createRechargeRequest.getRechargeAmount());
|
| - |
|
309 |
pp.add(cpo);
|
| - |
|
310 |
rr.setPaymentOptions(pp);
|
| - |
|
311 |
return rr;
|
| - |
|
312 |
}
|
| 181 |
@RequestMapping(value = ProfitMandiConstants.URL_CREATE_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
313 |
@RequestMapping(value = ProfitMandiConstants.URL_CREATE_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 182 |
@ApiImplicitParams({
|
314 |
@ApiImplicitParams({
|
| 183 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
315 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 184 |
required = true, dataType = "string", paramType = "header")
|
316 |
required = true, dataType = "string", paramType = "header")
|
| 185 |
})
|
317 |
})
|
| - |
|
318 |
|
| - |
|
319 |
@PostConstruct
|
| - |
|
320 |
private void setRechargeCredentials() {
|
| - |
|
321 |
rechargeTransactionMobileCredential = new RechargeCredential();
|
| - |
|
322 |
rechargeTransactionMobileCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionMobileUrl);
|
| - |
|
323 |
rechargeTransactionMobileCredential.setRechargeUserName(thinkWalnutDigitalRechargeTransactionMobileUserName);
|
| - |
|
324 |
rechargeTransactionMobileCredential.setRechargePassword(thinkWalnutDigitalRechargeTransactionMobilePassword);
|
| - |
|
325 |
rechargeTransactionMobileCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| - |
|
326 |
|
| - |
|
327 |
rechargeTransactionDthCredential = new RechargeCredential();
|
| - |
|
328 |
rechargeTransactionDthCredential.setRechargeUrl(thinkWalnutDigitalRechargeTransactionDthUrl);
|
| - |
|
329 |
rechargeTransactionDthCredential.setRechargeUserName(thinkWalnutDigitalRechargeTransactionDthUserName);
|
| - |
|
330 |
rechargeTransactionDthCredential.setRechargePassword(thinkWalnutDigitalRechargeTransactionDthPassword);
|
| - |
|
331 |
rechargeTransactionDthCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| - |
|
332 |
}
|
| - |
|
333 |
|
| - |
|
334 |
|
| - |
|
335 |
|
| - |
|
336 |
|
| 186 |
public ResponseEntity<?> createRecharge(HttpServletRequest request, @RequestBody CreateRechargeRequest createRechargeRequest)
|
337 |
public ResponseEntity<?> createRecharge(HttpServletRequest request, @RequestBody CreateRechargeRequest createRechargeRequest)
|
| 187 |
throws ProfitMandiBusinessException{
|
338 |
throws ProfitMandiBusinessException{
|
| - |
|
339 |
int userId = (int)request.getAttribute(ProfitMandiConstants.USER_ID);
|
| - |
|
340 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
| 188 |
String ipAddress = remoteAddr(request);
|
341 |
String ipAddress = remoteAddr(request);
|
| 189 |
String errorMessage = validateRecharge(RechargeType.valueOf(createRechargeRequest.getRechargeType()), createRechargeRequest.getNumber(), createRechargeRequest.getOperatorId(), ipAddress);
|
- |
|
| - |
|
342 |
|
| 190 |
CreateRechargeResponse crr = new CreateRechargeResponse();
|
343 |
CreateRechargeResponse crr = new CreateRechargeResponse();
|
| 191 |
if(!errorMessage.equals("SUCCESS")){
|
- |
|
| 192 |
crr.setReason(errorMessage);
|
- |
|
| 193 |
crr.setResult(false);
|
- |
|
| 194 |
return responseSender.badRequest(crr);
|
- |
|
| 195 |
}
|
344 |
|
| 196 |
int userId = (int)request.getAttribute("userId");
|
- |
|
| 197 |
UserAccount userAccount = null;
|
345 |
UserAccount userAccount = null;
|
| 198 |
UserWallet wallet = null;
|
346 |
UserWallet wallet = null;
|
| - |
|
347 |
wallet = userWalletRepository.selectByRetailerId(retailerId);
|
| - |
|
348 |
|
| 199 |
if (createRechargeRequest.getRechargeAmount() <=0){
|
349 |
if (createRechargeRequest.getRechargeAmount() <=0){
|
| 200 |
crr.setReason("Illegal recharge amount");
|
350 |
crr.setReason("Illegal recharge amount");
|
| 201 |
crr.setResult(false);
|
351 |
crr.setResult(false);
|
| 202 |
return responseSender.badRequest(crr);
|
352 |
return responseSender.badRequest(crr);
|
| 203 |
}
|
353 |
}
|
| 204 |
|
354 |
|
| 205 |
userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
|
- |
|
| 206 |
|
- |
|
| 207 |
try {
|
- |
|
| 208 |
TransactionClient tc = new TransactionClient();
|
- |
|
| 209 |
wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccountKey()));
|
- |
|
| 210 |
} catch (NumberFormatException | TException e) {
|
- |
|
| 211 |
log.error("Unable to get user wallet ",e);
|
- |
|
| 212 |
crr.setReason("We are experiencing some problem right now.");
|
- |
|
| 213 |
crr.setResult(false);
|
- |
|
| 214 |
return responseSender.internalServerError(e);
|
- |
|
| 215 |
}
|
- |
|
| 216 |
|
- |
|
| 217 |
if (wallet.getAmount() < createRechargeRequest.getRechargeAmount()){
|
355 |
if (wallet.getAmount() < createRechargeRequest.getRechargeAmount()){
|
| 218 |
crr.setReason("You don't have sufficient wallet balance.");
|
356 |
crr.setReason("You don't have sufficient wallet balance.");
|
| 219 |
crr.setResult(false);
|
357 |
crr.setResult(false);
|
| 220 |
return responseSender.badRequest(crr);
|
358 |
return responseSender.badRequest(crr);
|
| 221 |
}
|
359 |
}
|
| Line 228... |
Line 366... |
| 228 |
crr.setReason("We are experiencing some problem right now.");
|
366 |
crr.setReason("We are experiencing some problem right now.");
|
| 229 |
crr.setResult(false);
|
367 |
crr.setResult(false);
|
| 230 |
return responseSender.internalServerError(e);
|
368 |
return responseSender.internalServerError(e);
|
| 231 |
}
|
369 |
}
|
| 232 |
|
370 |
|
| - |
|
371 |
|
| - |
|
372 |
RechargeRequest rechargeRequest = convertRechargeRequest(createRechargeRequest);
|
| 233 |
|
373 |
|
| 234 |
RechargeOrder t_rechargeOrder = new RechargeOrder();
|
- |
|
| 235 |
t_rechargeOrder.setTotalAmount(createRechargeRequest.getRechargeAmount());
|
- |
|
| 236 |
t_rechargeOrder.setUserEmailId(user.getEmailId());
|
- |
|
| 237 |
t_rechargeOrder.setUserId(Long.valueOf(userAccount.getAccountKey()));
|
- |
|
| 238 |
t_rechargeOrder.setDeviceNumber(createRechargeRequest.getNumber());
|
- |
|
| 239 |
t_rechargeOrder.setPlan(createRechargeRequest.getPlan()==null?"":createRechargeRequest.getPlan());
|
374 |
RechargeResponse rechargeResponse = rechargeService.doRecharge(oxigenRechargeTransactionUrl, oxigenRechargeAuthKey, oxigenRechargeValidationUrl,
|
| 240 |
t_rechargeOrder.setOperatorId(createRechargeRequest.getOperatorId());
|
- |
|
| 241 |
t_rechargeOrder.setRechargeType(RechargeType.valueOf(createRechargeRequest.getRechargeType()));
|
375 |
oxigenRechargeValidationAuthKey, rechargeTransactionMobileCredential, rechargeTransactionDthCredential, retailerId, rechargeRequest);
|
| 242 |
t_rechargeOrder.setStatus(RechargeOrderStatus.PAYMENT_PENDING);
|
- |
|
| 243 |
t_rechargeOrder.setOrderType(OrderType.B2C);
|
- |
|
| 244 |
t_rechargeOrder.setWalletAmount(createRechargeRequest.getRechargeAmount());
|
- |
|
| 245 |
t_rechargeOrder.setCouponAmount(0);
|
- |
|
| 246 |
t_rechargeOrder.setCouponCode("");
|
- |
|
| 247 |
t_rechargeOrder.setIpAddress(ipAddress);
|
- |
|
| 248 |
TransactionClient tc = null;
|
- |
|
| 249 |
RechargeOrder rechargeOrder;
|
- |
|
| 250 |
try {
|
376 |
|
| 251 |
tc = new TransactionClient();
|
- |
|
| 252 |
rechargeOrder = tc.getClient().createRechargeOrder(t_rechargeOrder);
|
377 |
crr.setResult(rechargeResponse.getStatus().equals(RechargeStatus.SUCCESS));
|
| 253 |
} catch (TransactionServiceException | TException e) {
|
- |
|
| 254 |
log.error("Unable to create recharge order",e);
|
- |
|
| 255 |
crr.setReason("We are experiencing some problem right now.");
|
378 |
crr.setRequestId(rechargeResponse.getRequestId());
|
| 256 |
crr.setResult(false);
|
- |
|
| 257 |
return responseSender.internalServerError(e);
|
- |
|
| 258 |
}
|
379 |
|
| 259 |
|
- |
|
| 260 |
log.info("Recharge Order:" + rechargeOrder);
|
380 |
if(RechargeType.valueOf(rechargeRequest.getRechargeType()) == RechargeType.MOBILE) {
|
| 261 |
PaymentClient paymentServiceClient = null;
|
381 |
return responseSender.ok(crr);
|
| 262 |
try {
|
382 |
}else {
|
| 263 |
paymentServiceClient = new PaymentClient();
|
- |
|
| 264 |
} catch (TTransportException e) {
|
- |
|
| 265 |
log.error("Unable to create payment client",e);
|
- |
|
| 266 |
crr.setReason("We are experiencing some problem right now.");
|
- |
|
| 267 |
crr.setResult(false);
|
- |
|
| 268 |
return responseSender.internalServerError(e);
|
383 |
return responseSender.ok(crr);
|
| 269 |
}
|
384 |
}
|
| 270 |
try {
|
385 |
}
|
| 271 |
RechargeOrder d_rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrder.getId());
|
- |
|
| - |
|
386 |
|
| 272 |
List<Payment> payments = paymentServiceClient.getClient().getPaymentForRechargeTxnId(d_rechargeOrder.getTransactionId());
|
387 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_SUMMARY , method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 273 |
if(payments.size() > 0) {
|
388 |
@ApiImplicitParams({
|
| - |
|
389 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 274 |
throw new PaymentException(d_rechargeOrder.getId(), "Payment already exists for recharge");
|
390 |
required = true, dataType = "string", paramType = "header")
|
| 275 |
}
|
391 |
})
|
| 276 |
Long merchantPaymentId = 0l;
|
392 |
public ResponseEntity<?>rechargeSummary (HttpServletRequest request ,@RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit)
|
| 277 |
if (d_rechargeOrder.getWalletAmount() + d_rechargeOrder.getCouponAmount() != d_rechargeOrder.getTotalAmount()) {
|
393 |
throws ProfitMandiBusinessException{
|
| 278 |
log.error("Wallet amount : " + d_rechargeOrder.getWalletAmount() + ", coupon amount : " + d_rechargeOrder.getCouponAmount() + " and total amount : " + d_rechargeOrder.getTotalAmount());
|
- |
|
| 279 |
merchantPaymentId = paymentServiceClient.getClient().createPayment(d_rechargeOrder.getUserId(), d_rechargeOrder.getTotalAmount(), 8, d_rechargeOrder.getTransactionId(), true);
|
394 |
int userId = (int)request.getAttribute(ProfitMandiConstants.USER_ID);
|
| 280 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, "","", "0", "", "", "", "", "", PaymentStatus.FAILED, "", null);
|
395 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
| 281 |
tc.getClient().updateRechargeOrderStatus(d_rechargeOrder.getId(), RechargeOrderStatus.PAYMENT_FAILED);
|
396 |
RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
|
| 282 |
} else {
|
- |
|
| 283 |
merchantPaymentId = paymentServiceClient.getClient().createPayment(d_rechargeOrder.getUserId(), d_rechargeOrder.getTotalAmount(), 8, d_rechargeOrder.getTransactionId(), true);
|
397 |
List<RechargeTransaction> rechargeTransactions =rechargeTransactionRepository.selectAllByRetailerIdAndType(retailerId, rechargeType, offset, limit);
|
| 284 |
//Update payment status as authorized
|
398 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| 285 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, "","", "0", "", "", "", "", "", PaymentStatus.SUCCESS, "", null);
|
399 |
String operatorName=rechargeOperatorRepository.selectById(rechargeTransaction.getOperatorId()).getName();
|
| 286 |
tc.getClient().updateRechargeOrderStatus(d_rechargeOrder.getId(), RechargeOrderStatus.PAYMENT_SUCCESSFUL);
|
400 |
rechargeTransaction.setOperatorName(operatorName);
|
| 287 |
}
|
401 |
}
|
| 288 |
crr.setRechargeOrderId(d_rechargeOrder.getId());
|
402 |
if(RechargeType.valueOf(rechargeTypeString) == RechargeType.MOBILE) {
|
| 289 |
crr.setResult(true);
|
- |
|
| 290 |
} catch (Exception e) {
|
- |
|
| 291 |
log.error("Unable to mark the payment as authorized", e);
|
403 |
return responseSender.ok(rechargeTransactions);
|
| 292 |
crr.setReason("We are experiencing some problem right now.");
|
- |
|
| 293 |
crr.setResult(false);
|
404 |
}else {
|
| 294 |
return responseSender.internalServerError(e);
|
405 |
return responseSender.ok(rechargeTransactions);
|
| 295 |
}
|
406 |
}
|
| 296 |
return responseSender.ok(crr);
|
407 |
|
| 297 |
}
|
408 |
}
|
| - |
|
409 |
|
| - |
|
410 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_COMMISSIONS , method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
411 |
@ApiImplicitParams({
|
| - |
|
412 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
413 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
414 |
})
|
| - |
|
415 |
public ResponseEntity<?>rechargeCommissions (HttpServletRequest request,@RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "60") int limit)
|
| - |
|
416 |
throws ProfitMandiBusinessException{
|
| - |
|
417 |
List<RechargeCommission> rechargeCommissions = rechargeCommissionRepository.selectAllPaginated(offset, limit);
|
| - |
|
418 |
for (RechargeCommission rechargeCommission : rechargeCommissions) {
|
| - |
|
419 |
String operatorName=rechargeOperatorRepository.selectById(rechargeCommission.getOperatorId()).getName();
|
| - |
|
420 |
RechargeType rechargeType=rechargeOperatorRepository.selectById(rechargeCommission.getOperatorId()).getRechargeType();
|
| - |
|
421 |
OperatorType operatorType=rechargeOperatorRepository.selectById(rechargeCommission.getOperatorId()).getOperatorType();
|
| - |
|
422 |
rechargeCommission.setOperatorName(operatorName);
|
| - |
|
423 |
rechargeCommission.setRechargeType(rechargeType);
|
| - |
|
424 |
rechargeCommission.setOperatorType(operatorType);
|
| - |
|
425 |
}
|
| - |
|
426 |
Map<Integer,RechargeCommission> commissionMap = rechargeCommissions.stream().collect(Collectors.groupingBy(RechargeCommission::getOperatorId, Collectors.collectingAndThen(
|
| - |
|
427 |
Collectors.reducing((RechargeCommission d1,RechargeCommission d2) -> d1.getAmount() > d2.getAmount() ? d1 : d2),
|
| - |
|
428 |
Optional::get)));
|
| - |
|
429 |
|
| - |
|
430 |
return responseSender.ok(commissionMap.values());
|
| - |
|
431 |
}
|
| 298 |
|
432 |
|
| 299 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_RESULT , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
433 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_RESULT , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 300 |
@ApiImplicitParams({
|
434 |
@ApiImplicitParams({
|
| 301 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
435 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 302 |
required = true, dataType = "string", paramType = "header")
|
436 |
required = true, dataType = "string", paramType = "header")
|
| 303 |
})
|
437 |
})
|
| - |
|
438 |
|
| - |
|
439 |
@PostConstruct
|
| - |
|
440 |
private void setRechargeEnquiryCredentials() {
|
| - |
|
441 |
thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
|
| - |
|
442 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
| - |
|
443 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeEnquiryUserName);
|
| - |
|
444 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargeEnquiryPassword);
|
| - |
|
445 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| - |
|
446 |
}
|
| 304 |
public ResponseEntity<?> rechargeResult(HttpServletRequest request, @RequestParam(value="rechargeOrderId") long rechargeOrderId){
|
447 |
public ResponseEntity<?> rechargeResult(HttpServletRequest request, @RequestParam(value="requestId") String requestId ) throws ProfitMandiBusinessException{
|
| 305 |
TransactionClient tc=null;
|
- |
|
| 306 |
RechargeOrder rechargeOrder = null;
|
448 |
RechargeOrder rechargeOrder = null;
|
| 307 |
RechargeResultPojo rrp = null;
|
449 |
RechargeResultPojo rrp = null;
|
| - |
|
450 |
|
| - |
|
451 |
|
| - |
|
452 |
//RechargeResponse rr = new RechargeResponse();
|
| - |
|
453 |
//String requestId = rr.getRequestId();
|
| - |
|
454 |
int userId = (int)request.getAttribute(ProfitMandiConstants.USER_ID);
|
| - |
|
455 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
| - |
|
456 |
|
| - |
|
457 |
RechargeResponse rechargeResponse = rechargeService.checkStatus(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey, thinkWalnutDigitalRechargeEnquiryCredential,retailerId , requestId);
|
| - |
|
458 |
return responseSender.ok(rechargeResponse);
|
| - |
|
459 |
|
| 308 |
try {
|
460 |
/* try {
|
| 309 |
tc = new TransactionClient();
|
461 |
tc = new TransactionClient();
|
| 310 |
rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrderId);
|
462 |
//rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrderId);
|
| 311 |
} catch (TransactionServiceException | TException e) {
|
463 |
} catch (TransactionServiceException | TException e) {
|
| 312 |
// return with internal server error
|
464 |
// return with internal server error
|
| 313 |
e.printStackTrace();
|
465 |
e.printStackTrace();
|
| 314 |
rrp = new RechargeResultPojo();
|
466 |
rrp = new RechargeResultPojo();
|
| 315 |
rrp.setIsError(true);
|
467 |
rrp.setIsError(true);
|
| Line 331... |
Line 483... |
| 331 |
rrp.setIsError(Boolean.parseBoolean(os[0]));
|
483 |
rrp.setIsError(Boolean.parseBoolean(os[0]));
|
| 332 |
rrp.setRechargeStatus(os[1]);
|
484 |
rrp.setRechargeStatus(os[1]);
|
| 333 |
rrp.setDetailDisplayMessage(os[2]);
|
485 |
rrp.setDetailDisplayMessage(os[2]);
|
| 334 |
if (rechargeOrder.getStatus().equals(RechargeOrderStatus.RECHARGE_UNKNOWN)){
|
486 |
if (rechargeOrder.getStatus().equals(RechargeOrderStatus.RECHARGE_UNKNOWN)){
|
| 335 |
rrp.setPoll(true);
|
487 |
rrp.setPoll(true);
|
| - |
|
488 |
}*/
|
| 336 |
}
|
489 |
|
| 337 |
return responseSender.ok(rrp);
|
- |
|
| 338 |
}
|
490 |
}
|
| 339 |
|
491 |
|
| 340 |
@RequestMapping(value = ProfitMandiConstants.URL_POLL_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
492 |
@RequestMapping(value = ProfitMandiConstants.URL_POLL_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 341 |
@ApiImplicitParams({
|
493 |
@ApiImplicitParams({
|
| 342 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
494 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| Line 389... |
Line 541... |
| 389 |
return responseSender.internalServerError(e);
|
541 |
return responseSender.internalServerError(e);
|
| 390 |
}
|
542 |
}
|
| 391 |
List<MyRechargesResponse> myRechargesList = new ArrayList<MyRechargesResponse>();
|
543 |
List<MyRechargesResponse> myRechargesList = new ArrayList<MyRechargesResponse>();
|
| 392 |
for (RechargeOrder rechargeOrder : rechargeOrders){
|
544 |
for (RechargeOrder rechargeOrder : rechargeOrders){
|
| 393 |
MyRechargesResponse rp = new MyRechargesResponse();
|
545 |
MyRechargesResponse rp = new MyRechargesResponse();
|
| 394 |
if(rechargeOrder.getRechargeType() == RechargeType.MOBILE){
|
546 |
/* if(rechargeOrder.getRechargeType() == RechargeType.MOBILE){
|
| 395 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
547 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
| 396 |
rp.setOperatorType("MOBILE");
|
548 |
rp.setOperatorType("MOBILE");
|
| 397 |
}
|
549 |
}
|
| 398 |
if(rechargeOrder.getRechargeType() == RechargeType.DTH){
|
550 |
if(rechargeOrder.getRechargeType() == RechargeType.DTH){
|
| 399 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
551 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
| 400 |
rp.setOperatorType("DTH");
|
552 |
rp.setOperatorType("DTH");
|
| 401 |
}
|
553 |
}*/
|
| 402 |
rp.setOrderId(rechargeOrder.getId());
|
554 |
rp.setOrderId(rechargeOrder.getId());
|
| 403 |
rp.setOperatorId(rechargeOrder.getOperatorId());
|
555 |
rp.setOperatorId(rechargeOrder.getOperatorId());
|
| 404 |
rp.setDate(rechargeOrder.getCreationTimestamp());
|
556 |
rp.setDate(rechargeOrder.getCreationTimestamp());
|
| 405 |
rp.setNumber(rechargeOrder.getDeviceNumber());
|
557 |
rp.setNumber(rechargeOrder.getDeviceNumber());
|
| 406 |
rp.setAmount(rechargeOrder.getTotalAmount());
|
558 |
rp.setAmount(rechargeOrder.getTotalAmount());
|
| Line 428... |
Line 580... |
| 428 |
log.info("Value of remoteAddr is [{}]", remoteAddr);
|
580 |
log.info("Value of remoteAddr is [{}]", remoteAddr);
|
| 429 |
}
|
581 |
}
|
| 430 |
return remoteAddr;
|
582 |
return remoteAddr;
|
| 431 |
}
|
583 |
}
|
| 432 |
|
584 |
|
| 433 |
private String validateRecharge(RechargeType rechargeType, String number, long operatorId, String ipAddress){
|
585 |
/*private String validateRecharge(RechargeType rechargeType, String number, long operatorId, String ipAddress){
|
| 434 |
TransactionClient tcl;
|
586 |
TransactionClient tcl;
|
| 435 |
try {
|
587 |
try {
|
| 436 |
tcl = new TransactionClient();
|
588 |
tcl = new TransactionClient();
|
| 437 |
String result = tcl.getClient().validateRecharge(rechargeType, number, operatorId, ipAddress);
|
589 |
// String result = tcl.getClient().validateRecharge(rechargeType, number, operatorId, ipAddress);
|
| 438 |
log.info("validateRecharge Called" + number + " and rechargeType : " + rechargeType + ", IP:" + ipAddress + ", Operator:" + operatorId + ", Result:" + result);
|
590 |
//log.info("validateRecharge Called" + number + " and rechargeType : " + rechargeType + ", IP:" + ipAddress + ", Operator:" + operatorId + ", Result:" + result);
|
| 439 |
return result;
|
591 |
//return result;
|
| 440 |
} catch (Exception e) {
|
592 |
} catch (Exception e) {
|
| 441 |
log.error("Unable to get service provider for Device number " + number + " and rechargeType : " + rechargeType, e);
|
593 |
log.error("Unable to get service provider for Device number " + number + " and rechargeType : " + rechargeType, e);
|
| 442 |
}
|
594 |
}
|
| 443 |
return "Oops! There seems to be a problem. Please try after some time";
|
595 |
return "Oops! There seems to be a problem. Please try after some time";
|
| 444 |
}
|
596 |
}*/
|
| 445 |
|
597 |
|
| 446 |
|
598 |
|
| 447 |
}
|
599 |
}
|
| 448 |
|
- |
|
| 449 |
|
- |
|
| 450 |
|
- |
|