Subversion Repositories SmartDukaan

Rev

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

Rev 30014 Rev 30015
Line 27... Line 27...
27
import com.spice.profitmandi.common.services.mandii.MandiiService;
27
import com.spice.profitmandi.common.services.mandii.MandiiService;
28
import com.spice.profitmandi.common.services.mandii.TransactionSummaryResponseOut;
28
import com.spice.profitmandi.common.services.mandii.TransactionSummaryResponseOut;
29
import com.spice.profitmandi.common.web.util.ResponseSender;
29
import com.spice.profitmandi.common.web.util.ResponseSender;
30
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
30
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
31
import com.spice.profitmandi.dao.entity.dtr.CreditStatus;
31
import com.spice.profitmandi.dao.entity.dtr.CreditStatus;
32
import com.spice.profitmandi.dao.entity.dtr.FundFinaPreApproval;
-
 
33
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
32
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
34
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
33
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
35
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
34
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
36
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
35
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
37
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
36
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
38
import com.spice.profitmandi.dao.repository.dtr.FundFinaPreApprovalRepository;
-
 
39
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
37
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
40
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
38
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
41
import com.spice.profitmandi.dao.repository.transaction.PaymentRepository;
39
import com.spice.profitmandi.dao.repository.transaction.PaymentRepository;
42
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
40
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
43
import com.spice.profitmandi.service.wallet.WalletService;
41
import com.spice.profitmandi.service.wallet.WalletService;
Line 83... Line 81...
83
	ResponseSender<?> responseSender;
81
	ResponseSender<?> responseSender;
84
 
82
 
85
	@Autowired
83
	@Autowired
86
	CreditAccountRepository creditAccountRepository;
84
	CreditAccountRepository creditAccountRepository;
87
 
85
 
88
	@Autowired
-
 
89
	FundFinaPreApprovalRepository fundFinaPreApprovalRepository;
-
 
90
 
-
 
91
	@RequestMapping(value = "payment/gateway/status/{gateway}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
86
	@RequestMapping(value = "payment/gateway/status/{gateway}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
92
	public ResponseEntity<?> getLoanStatus(HttpServletRequest request, @PathVariable Gateway gateway)
87
	public ResponseEntity<?> getLoanStatus(HttpServletRequest request, @PathVariable Gateway gateway)
93
			throws ProfitMandiBusinessException {
88
			throws ProfitMandiBusinessException {
94
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
89
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
95
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
90
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
Line 136... Line 131...
136
				return responseSender.ok(accountStatusResponseOut);
131
				return responseSender.ok(accountStatusResponseOut);
137
			} catch (Exception e) {
132
			} catch (Exception e) {
138
				log.info("Trace {}\n{}", e.getMessage(), e);
133
				log.info("Trace {}\n{}", e.getMessage(), e);
139
				throw new ProfitMandiBusinessException("Loan Provider", gateway, "Can't fetch details for provider");
134
				throw new ProfitMandiBusinessException("Loan Provider", gateway, "Can't fetch details for provider");
140
			}
135
			}
141
		} else if (gateway != null && gateway.equals(Gateway.FUNDFINA)) {
-
 
142
 
-
 
143
			CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(retailerId,
-
 
144
					Gateway.FUNDFINA);
-
 
145
			if (creditAccount == null) {
-
 
146
				creditAccount = new CreditAccount();
-
 
147
				creditAccount.setCreditStatus(CreditStatus.UNKNOWN);
-
 
148
 
-
 
149
			} else {
-
 
150
				FundFinaPreApproval fpa = fundFinaPreApprovalRepository
-
 
151
						.selectByProductId(creditAccount.getLoanReferenceId());
-
 
152
 
-
 
153
				creditAccount.setExpiredOn(fpa.getExpiryDate());
-
 
154
				creditAccount.setProcessingFee(fpa.getProcessingFee());
-
 
155
 
-
 
156
			}
-
 
157
 
-
 
158
			return responseSender.ok(creditAccount);
-
 
159
		}
136
		}
160
 
137
 
161
		else {
138
		else {
162
			throw new ProfitMandiBusinessException("Provider", "Empty", "Provider can't be empty");
139
			throw new ProfitMandiBusinessException("Provider", "Empty", "Provider can't be empty");
163
		}
140
		}