Subversion Repositories SmartDukaan

Rev

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

Rev 23548 Rev 23559
Line 19... Line 19...
19
import org.springframework.web.bind.annotation.RequestBody;
19
import org.springframework.web.bind.annotation.RequestBody;
20
import org.springframework.web.bind.annotation.RequestMapping;
20
import org.springframework.web.bind.annotation.RequestMapping;
21
import org.springframework.web.bind.annotation.RequestMethod;
21
import org.springframework.web.bind.annotation.RequestMethod;
22
import org.springframework.web.bind.annotation.RequestParam;
22
import org.springframework.web.bind.annotation.RequestParam;
23
 
23
 
24
import com.spice.profitmandi.common.enumuration.SchemeType;
-
 
25
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
24
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
26
import com.spice.profitmandi.common.model.OperatorType;
25
import com.spice.profitmandi.common.model.OperatorType;
27
import com.spice.profitmandi.common.model.ProfitMandiConstants;
26
import com.spice.profitmandi.common.model.ProfitMandiConstants;
28
import com.spice.profitmandi.common.model.RechargeCommissionRequest;
27
import com.spice.profitmandi.common.model.RechargeCommissionRequest;
29
import com.spice.profitmandi.common.model.RechargeCredential;
28
import com.spice.profitmandi.common.model.RechargeCredential;
Line 46... Line 45...
46
@Transactional(rollbackFor=Throwable.class)
45
@Transactional(rollbackFor=Throwable.class)
47
public class RechargeController {
46
public class RechargeController {
48
 
47
 
49
	private static final Logger LOGGER = LoggerFactory.getLogger(RechargeController.class);
48
	private static final Logger LOGGER = LoggerFactory.getLogger(RechargeController.class);
50
	
49
	
51
	@Value("${recharge.transaction.scheme.type}")
50
	@Value("${recharge.transaction.mobile.url}")
52
	private String rechargeTransactionSchemeType;
51
	private String rechargeMobileUrl;
53
	
52
	
54
	@Value("${recharge.transaction.host}")
53
	@Value("${recharge.transaction.mobile.username}")
55
	private String rechargeTransactionHost;
54
	private String rechargeMobileUserName;
56
		
-
 
57
	@Value("${recharge.transaction.port}")
-
 
58
	private int rechargeTransactionPort;
-
 
59
	
55
	
60
	@Value("${recharge.transaction.uri}")
56
	@Value("${recharge.transaction.mobile.password}")
61
	private String rechargeTransactionUri;
57
	private String rechargeMobilePassword;
62
	
58
	
63
	@Value("${recharge.auth.key}")
59
	@Value("${recharge.transaction.dth.url}")
64
	private String rechargeAuthKey;
60
	private String rechargeDthUrl;
65
	
61
	
66
	@Value("${recharge.transaction.scheme.type}")
62
	@Value("${recharge.transaction.dth.username}")
67
	private String rechargeEnquirySchemeType;
63
	private String rechargeDthUserName;
68
	
64
	
69
	@Value("${recharge.transaction.host}")
65
	@Value("${recharge.transaction.dth.password}")
70
	private String rechargeEnquiryHost;
66
	private String rechargeDthPassword;
71
		
-
 
72
	@Value("${recharge.transaction.port}")
-
 
73
	private int rechargeEnquiryPort;
-
 
74
	
67
	
75
	@Value("${recharge.transaction.uri}")
68
	@Value("${recharge.enquiry.url}")
76
	private String rechargeEnquiryUri;
69
	private String rechargeEnquiryUrl;
77
	
70
	
78
	@Value("${recharge.validation.scheme.type}")
71
	@Value("${recharge.enquiry.username}")
79
	private String rechargeValidationSchemeType;
72
	private String rechargeEnquiryUserName;
80
	
73
	
81
	@Value("${recharge.validation.host}")
74
	@Value("${recharge.enquiry.password}")
82
	private String rechargeValidationHost;
75
	private String rechargeEnquiryPassword;
83
		
-
 
84
	@Value("${recharge.validation.port}")
-
 
85
	private int rechargeValidationPort;
-
 
86
	
76
	
-
 
77
	@Value("${recharge.auth.key}")
-
 
78
	private String rechargeAuthKey;
-
 
79
	
87
	@Value("${recharge.validation.uri}")
80
	@Value("${recharge.validation.url}")
88
	private String rechargeValidationUri;
81
	private String rechargeValidationUrl;
89
	
82
	
90
	@Value("${recharge.validation.auth.key}")
83
	@Value("${recharge.validation.auth.key}")
91
	private String rechargeValidationAuthKey;
84
	private String rechargeValidationAuthKey;
92
	
85
	
93
	@Autowired
86
	@Autowired
Line 168... Line 161...
168
	
161
	
169
	@RequestMapping(value = "/createRecharge", method = RequestMethod.POST)
162
	@RequestMapping(value = "/createRecharge", method = RequestMethod.POST)
170
	public String createRecharge(HttpServletRequest request, @RequestBody RechargeRequest rechargeRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
163
	public String createRecharge(HttpServletRequest request, @RequestBody RechargeRequest rechargeRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
171
		LOGGER.info("Recharge request body {}", rechargeRequest);
164
		LOGGER.info("Recharge request body {}", rechargeRequest);
172
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
165
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
173
		RechargeCredential rechargeTransactionCredential = new RechargeCredential();
166
		RechargeCredential rechargeTransactionMobileCredential = new RechargeCredential();
174
		rechargeTransactionCredential.setRechargeSchemeType(SchemeType.valueOf(rechargeTransactionSchemeType.toUpperCase()));
-
 
175
		rechargeTransactionCredential.setRechargeHost(rechargeTransactionHost);
167
		rechargeTransactionMobileCredential.setRechargeUrl(rechargeMobileUrl);
176
		rechargeTransactionCredential.setRechargePort(rechargeTransactionPort);
168
		rechargeTransactionMobileCredential.setRechargeUserName(rechargeMobileUserName);
177
		rechargeTransactionCredential.setRechargeAuthKey(rechargeAuthKey);
169
		rechargeTransactionMobileCredential.setRechargePassword(rechargeMobilePassword);
178
		rechargeTransactionCredential.setRechargeUri(rechargeTransactionUri);
170
		rechargeTransactionMobileCredential.setRechargeAuthKey(rechargeAuthKey);
179
		
171
		
180
		RechargeCredential rechargeValidationCredential = new RechargeCredential();
172
		RechargeCredential rechargeTransactionDthCredential = new RechargeCredential();
181
		rechargeValidationCredential.setRechargeSchemeType(SchemeType.valueOf(rechargeValidationSchemeType.toUpperCase()));
-
 
182
		rechargeValidationCredential.setRechargeHost(rechargeValidationHost);
173
		rechargeTransactionDthCredential.setRechargeUrl(rechargeDthUrl);
183
		rechargeValidationCredential.setRechargePort(rechargeValidationPort);
174
		rechargeTransactionDthCredential.setRechargeUserName(rechargeDthUserName);
184
		rechargeValidationCredential.setRechargeAuthKey(rechargeValidationAuthKey);
175
		rechargeTransactionDthCredential.setRechargePassword(rechargeDthPassword);
185
		rechargeValidationCredential.setRechargeUri(rechargeValidationUri);
176
		rechargeTransactionDthCredential.setRechargeAuthKey(rechargeAuthKey);
186
		
177
		
187
		rechargeService.doRecharge(rechargeTransactionCredential, rechargeValidationCredential, loginDetails.getFofoId(), rechargeRequest);
178
		rechargeService.doRecharge(rechargeTransactionMobileCredential, rechargeTransactionDthCredential, rechargeValidationUrl, rechargeValidationAuthKey, loginDetails.getFofoId(), rechargeRequest);
188
		RechargeType rechargeType = RechargeType.valueOf(rechargeRequest.getRechargeType());
179
		RechargeType rechargeType = RechargeType.valueOf(rechargeRequest.getRechargeType());
189
		List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
180
		List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
190
		long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(), rechargeType);
181
		long size = rechargeTransactionRepository.selectCountByRetailerIdAndType(loginDetails.getFofoId(), rechargeType);
191
		Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
182
		Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
192
		model.addAttribute("rechargeTransactions", rechargeTransactions);
183
		model.addAttribute("rechargeTransactions", rechargeTransactions);
Line 207... Line 198...
207
	
198
	
208
	@RequestMapping(value = "/checkStatus", method = RequestMethod.GET)
199
	@RequestMapping(value = "/checkStatus", method = RequestMethod.GET)
209
	public String checkStatus(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.REQUEST_ID) String requestId, @RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
200
	public String checkStatus(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.REQUEST_ID) String requestId, @RequestParam(name = ProfitMandiConstants.RECHARGE_TYPE) String rechargeTypeString, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
210
		LOGGER.info("RequestId [{}], rechargeType [{}]", requestId, rechargeTypeString);
201
		LOGGER.info("RequestId [{}], rechargeType [{}]", requestId, rechargeTypeString);
211
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
202
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
212
		RechargeCredential rechargeEnquiryCredential = new RechargeCredential();
203
		RechargeCredential rechargeTransactionEnquiryCredential = new RechargeCredential();
213
		rechargeEnquiryCredential.setRechargeSchemeType(SchemeType.valueOf(rechargeEnquirySchemeType.toUpperCase()));
-
 
214
		rechargeEnquiryCredential.setRechargeHost(rechargeEnquiryHost);
204
		rechargeTransactionEnquiryCredential.setRechargeUrl(rechargeEnquiryUrl);
215
		rechargeEnquiryCredential.setRechargePort(rechargeEnquiryPort);
205
		rechargeTransactionEnquiryCredential.setRechargeUserName(rechargeEnquiryUserName);
216
		rechargeEnquiryCredential.setRechargeAuthKey(rechargeAuthKey);
206
		rechargeTransactionEnquiryCredential.setRechargePassword(rechargeEnquiryPassword);
217
		rechargeEnquiryCredential.setRechargeUri(rechargeEnquiryUri);
207
		rechargeTransactionEnquiryCredential.setRechargeAuthKey(rechargeAuthKey);
218
		rechargeService.checkStatus(rechargeEnquiryCredential, loginDetails.getFofoId(), requestId);
208
		rechargeService.checkStatus(rechargeTransactionEnquiryCredential, loginDetails.getFofoId(), requestId);
219
		RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
209
		RechargeType rechargeType = RechargeType.valueOf(rechargeTypeString);
220
		List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
210
		List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllByRetailerIdAndType(loginDetails.getFofoId(), rechargeType, offset, limit);
221
		//long size = rechargeTransactionRepository.selectCountByRetailerId(loginDetails.getFofoId());
211
		//long size = rechargeTransactionRepository.selectCountByRetailerId(loginDetails.getFofoId());
222
		Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
212
		Map<Integer, String> rechargeOperatorIdRechargeOperatorNameMap = this.rechargeTransactionsToRechargeOperatorIdNameMap(rechargeTransactions);
223
		model.addAttribute("rechargeTransactions", rechargeTransactions);
213
		model.addAttribute("rechargeTransactions", rechargeTransactions);