Subversion Repositories SmartDukaan

Rev

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

Rev 25100 Rev 25547
Line 43... Line 43...
43
import com.spice.profitmandi.dao.entity.dtr.User;
43
import com.spice.profitmandi.dao.entity.dtr.User;
44
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
44
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
45
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
45
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
46
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
46
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
47
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
47
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
48
import com.spice.profitmandi.dao.model.UserCart;
-
 
49
import com.spice.profitmandi.dao.repository.GenericRepository;
48
import com.spice.profitmandi.dao.repository.GenericRepository;
50
import com.spice.profitmandi.dao.repository.dtr.RechargeCommissionRepository;
49
import com.spice.profitmandi.dao.repository.dtr.RechargeCommissionRepository;
51
import com.spice.profitmandi.dao.repository.dtr.RechargeOperatorRepository;
50
import com.spice.profitmandi.dao.repository.dtr.RechargeOperatorRepository;
52
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
51
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
53
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
52
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
54
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
53
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
55
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
54
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
56
import com.spice.profitmandi.dao.repository.transaction.PendingRechargeCommissionRepository;
55
import com.spice.profitmandi.dao.repository.transaction.PendingRechargeCommissionRepository;
57
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
56
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
58
import com.spice.profitmandi.service.recharge.RechargeService;
57
import com.spice.profitmandi.service.recharge.RechargeService;
-
 
58
import com.spice.profitmandi.service.wallet.WalletService;
59
import com.spice.profitmandi.thrift.clients.TransactionClient;
59
import com.spice.profitmandi.thrift.clients.TransactionClient;
60
import com.spice.profitmandi.web.req.CreateRechargeRequest;
60
import com.spice.profitmandi.web.req.CreateRechargeRequest;
61
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
61
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
62
import com.spice.profitmandi.web.res.CreateRechargeResponse;
62
import com.spice.profitmandi.web.res.CreateRechargeResponse;
63
import com.spice.profitmandi.web.res.MyRechargesResponse;
63
import com.spice.profitmandi.web.res.MyRechargesResponse;
Line 125... Line 125...
125
	@Value("${think.walnut.digital.recharge.auth.key}")
125
	@Value("${think.walnut.digital.recharge.auth.key}")
126
	private String thinkWalnutDigitalRechargeAuthKey;
126
	private String thinkWalnutDigitalRechargeAuthKey;
127
 
127
 
128
	@Autowired
128
	@Autowired
129
	UserWalletRepository userWalletRepository;
129
	UserWalletRepository userWalletRepository;
-
 
130
	
-
 
131
	@Autowired
-
 
132
	WalletService walletService;
130
 
133
 
131
	@Autowired
134
	@Autowired
132
	private GenericRepository genericRepository;
135
	private GenericRepository genericRepository;
133
 
136
 
134
	@Autowired
137
	@Autowired
Line 240... Line 243...
240
	@ApiOperation(value = "")
243
	@ApiOperation(value = "")
241
	public ResponseEntity<?> confirmRecharge(HttpServletRequest request,
244
	public ResponseEntity<?> confirmRecharge(HttpServletRequest request,
242
			@RequestParam(value = "rechargeAmount") long rechargeAmount) throws ProfitMandiBusinessException {
245
			@RequestParam(value = "rechargeAmount") long rechargeAmount) throws ProfitMandiBusinessException {
243
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
246
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
244
		UserAccount userAccount = null;
247
		UserAccount userAccount = null;
245
		UserWallet wallet = null;
-
 
246
		if (rechargeAmount <= 0) {
248
		if (rechargeAmount <= 0) {
247
			return responseSender.badRequest(null);
249
			return responseSender.badRequest(null);
248
		}
250
		}
249
 
251
 
250
		userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
252
		userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
251
 
253
 
252
		try {
-
 
253
			TransactionClient tc = new TransactionClient();
-
 
254
			// wallet =
-
 
255
			// tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccountKey()));
254
		long walletAmount = walletService.getWalletAmount(userAccount.getAccountKey());
256
		} catch (NumberFormatException | TException e) {
-
 
257
			return responseSender.internalServerError(e);
-
 
258
		}
-
 
259
 
255
 
260
		ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
256
		ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
261
		// crr.setWalletAmount(wallet.getAmount());
257
		// crr.setWalletAmount(wallet.getAmount());
262
		crr.setWalletAmountLeft(wallet.getAmount() - rechargeAmount);
258
		crr.setWalletAmountLeft(walletAmount - rechargeAmount);
263
		crr.setCanProceed(true);
259
		crr.setCanProceed(true);
264
		if (crr.getWalletAmountLeft() < 0) {
260
		if (crr.getWalletAmountLeft() < 0) {
265
			crr.setCanProceed(false);
261
			crr.setCanProceed(false);
266
			crr.setReason("You don't have sufficient wallet balance");
262
			crr.setReason("You don't have sufficient wallet balance");
267
		}
263
		}
Line 350... Line 346...
350
		String ipAddress = remoteAddr(request);
346
		String ipAddress = remoteAddr(request);
351
 
347
 
352
		CreateRechargeResponse crr = new CreateRechargeResponse();
348
		CreateRechargeResponse crr = new CreateRechargeResponse();
353
 
349
 
354
		UserAccount userAccount = null;
350
		UserAccount userAccount = null;
355
		UserWallet wallet = null;
-
 
356
		wallet = userWalletRepository.selectByRetailerId(retailerId);
351
		long walletAmount = walletService.getWalletAmount(retailerId);
357
 
352
 
358
		if (createRechargeRequest.getRechargeAmount() <= 0) {
353
		if (createRechargeRequest.getRechargeAmount() <= 0) {
359
			crr.setReason("Illegal recharge amount");
354
			crr.setReason("Illegal recharge amount");
360
			crr.setResult(false);
355
			crr.setResult(false);
361
			return responseSender.badRequest(crr);
356
			return responseSender.badRequest(crr);
362
		}
357
		}
363
 
358
 
364
		if (wallet.getAmount() < createRechargeRequest.getRechargeAmount()) {
359
		if (walletAmount < createRechargeRequest.getRechargeAmount()) {
365
			crr.setReason("You don't have sufficient wallet balance.");
360
			crr.setReason("You don't have sufficient wallet balance.");
366
			crr.setResult(false);
361
			crr.setResult(false);
367
			return responseSender.badRequest(crr);
362
			return responseSender.badRequest(crr);
368
		}
363
		}
369
 
364