Subversion Repositories SmartDukaan

Rev

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

Rev 24867 Rev 25249
Line 62... Line 62...
62
	@Qualifier("userRepository")
62
	@Qualifier("userRepository")
63
	private UserRepository userRepository;
63
	private UserRepository userRepository;
64
 
64
 
65
	@Autowired
65
	@Autowired
66
	private UserAccountRepository userAccountRepository;
66
	private UserAccountRepository userAccountRepository;
67
	
67
 
68
	@Autowired
68
	@Autowired
69
	private RetailerService retailerService;
69
	private RetailerService retailerService;
70
 
70
 
71
 
-
 
72
	@Autowired
71
	@Autowired
73
	ResponseSender<?> responseSender;
72
	ResponseSender<?> responseSender;
74
 
73
 
75
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
74
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
76
	@ApiImplicitParams({
75
	@ApiImplicitParams({
77
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
76
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
78
	@ApiOperation(value = "")
77
	@ApiOperation(value = "")
79
	public ResponseEntity<?> getMyWallet(HttpServletRequest request) throws ProfitMandiBusinessException {
78
	public ResponseEntity<?> getMyWallet(HttpServletRequest request) throws ProfitMandiBusinessException {
80
		int userId = (int) request.getAttribute("userId");
79
		int userId = (int) request.getAttribute("userId");
81
		/*boolean underMaintainance = true;
-
 
82
		if(underMaintainance) {
-
 
83
			return responseSender.badRequest(new ProfitMandiBusinessException(null, null, "Wallet is under maintainance, please try after"));
-
 
84
		}*/
-
 
85
		try {
-
 
86
			return responseSender.ok(walletService.getUserWalletByUserId(userId));
80
		return responseSender.ok(walletService.getUserWalletByUserId(userId));
87
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
88
			return responseSender.badRequest(profitMandiBusinessException);
-
 
89
		}
-
 
90
	}
81
	}
91
 
82
 
92
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
83
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
93
	@ApiImplicitParams({
84
	@ApiImplicitParams({
94
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
85
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
95
	public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request) throws ProfitMandiBusinessException {
86
	public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request) throws ProfitMandiBusinessException {
96
		/*boolean underMaintainance = true;
-
 
97
		if(underMaintainance) {
-
 
98
			return responseSender.badRequest(new ProfitMandiBusinessException(null, null, "Wallet is under maintainance, please try after"));
-
 
99
		}*/
-
 
100
		int userId = (int) request.getAttribute("userId");
87
		int userId = (int) request.getAttribute("userId");
101
		try {
88
		try {
102
			return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));
89
			return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));
103
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
90
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
104
			return responseSender.badRequest(profitMandiBusinessException);
91
			return responseSender.badRequest(profitMandiBusinessException);
Line 109... Line 96...
109
	@ApiImplicitParams({
96
	@ApiImplicitParams({
110
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
97
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
111
	public ResponseEntity<?> AddMoneyToWallet(HttpServletRequest request,
98
	public ResponseEntity<?> AddMoneyToWallet(HttpServletRequest request,
112
			@RequestBody CreateAddMoneyRequest createAddMoneyRequest) throws Exception {
99
			@RequestBody CreateAddMoneyRequest createAddMoneyRequest) throws Exception {
113
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
100
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
114
		log.info("user_id"+userId);
101
		log.info("user_id" + userId);
115
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
102
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
116
		CustomRetailer customRetailer=retailerService.getFofoRetailer(retailerId);
103
		CustomRetailer customRetailer = retailerService.getFofoRetailer(retailerId);
117
		AddWalletRequest addWalletrequest = new AddWalletRequest();
104
		AddWalletRequest addWalletrequest = new AddWalletRequest();
118
		addWalletrequest.setRetailerId(retailerId);
105
		addWalletrequest.setRetailerId(retailerId);
119
		addWalletrequest.setAmount(createAddMoneyRequest.getAmount());
106
		addWalletrequest.setAmount(createAddMoneyRequest.getAmount());
120
		addWalletrequest.setTransaction_reference(createAddMoneyRequest.getTransaction_reference());
107
		addWalletrequest.setTransaction_reference(createAddMoneyRequest.getTransaction_reference());
121
		addWalletrequest.setReference_date(createAddMoneyRequest.getReference_date());
108
		addWalletrequest.setReference_date(createAddMoneyRequest.getReference_date());
122
		addWalletrequest.setBank_name(createAddMoneyRequest.getBank_name());
109
		addWalletrequest.setBank_name(createAddMoneyRequest.getBank_name());
123
		addWalletrequest.setStatus(AddWalletRequestStatus.pending);
110
		addWalletrequest.setStatus(AddWalletRequestStatus.pending);
124
		log.info("info"+ addWalletrequest); 
111
		log.info("info" + addWalletrequest);
125
		addWalletRequestRepository.persist(addWalletrequest);
112
		addWalletRequestRepository.persist(addWalletrequest);
126
		log.info("fofoinfo" + customRetailer);
113
		log.info("fofoinfo" + customRetailer);
127
		String subject = "Add money to wallet request";
114
		String subject = "Add money to wallet request";
-
 
115
		String messageText = MessageFormat.format(
128
		String messageText = MessageFormat.format("User Id - {0}\n Name -{1}\n Email -{2}\n Reference - {3}\n Amount - Rs.{4} \n link - {5}",
116
				"User Id - {0}\n Name -{1}\n Email -{2}\n Reference - {3}\n Amount - Rs.{4} \n link - {5}",
129
				new Integer(addWalletrequest.getRetailerId()),customRetailer.getBusinessName(),customRetailer.getEmail(), addWalletrequest.getTransaction_reference(),
117
				new Integer(addWalletrequest.getRetailerId()), customRetailer.getBusinessName(),
-
 
118
				customRetailer.getEmail(), addWalletrequest.getTransaction_reference(),
130
				new Float(addWalletrequest.getAmount()),"http://partners.smartdukaan.com/dashboard");
119
				new Float(addWalletrequest.getAmount()), "http://partners.smartdukaan.com/dashboard");
131
		String email = "neeraj.gupta@smartdukaan.com";
120
		String email = "neeraj.gupta@smartdukaan.com";
132
		this.sendMailWithAttachments(email, subject, messageText);
121
		this.sendMailWithAttachments(email, subject, messageText);
133
 
122
 
134
		return responseSender.ok(true);
123
		return responseSender.ok(true);
135
	}
124
	}
Line 139... Line 128...
139
		MimeMessage message = mailSender.createMimeMessage();
128
		MimeMessage message = mailSender.createMimeMessage();
140
		MimeMessageHelper helper = new MimeMessageHelper(message, true);
129
		MimeMessageHelper helper = new MimeMessageHelper(message, true);
141
		helper.setSubject(subject);
130
		helper.setSubject(subject);
142
		helper.setText(messageText);
131
		helper.setText(messageText);
143
		helper.setTo(email);
132
		helper.setTo(email);
144
	//helper.setCc("neerajgupta2021@gmail.com");
133
		// helper.setCc("neerajgupta2021@gmail.com");
145
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "ProfitMandi Admin");
134
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "ProfitMandi Admin");
146
		helper.setFrom(senderAddress);
135
		helper.setFrom(senderAddress);
147
		mailSender.send(message);
136
		mailSender.send(message);
148
 
137
 
149
	}
138
	}
150
	
-
 
151
	
139
 
152
	@RequestMapping(value = ProfitMandiConstants.URL_ADD_MONEY_TO_WALLET_HISTORY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
140
	@RequestMapping(value = ProfitMandiConstants.URL_ADD_MONEY_TO_WALLET_HISTORY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
153
	@ApiImplicitParams({
141
	@ApiImplicitParams({
154
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
142
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
155
	public ResponseEntity<?> getAddMoneyToWalletHistory(HttpServletRequest request,@RequestParam(name = "offset", defaultValue = "0") int offset,
143
	public ResponseEntity<?> getAddMoneyToWalletHistory(HttpServletRequest request,
-
 
144
			@RequestParam(name = "offset", defaultValue = "0") int offset,
156
			@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
145
			@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
157
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
146
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
158
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
147
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
159
		List<AddWalletRequest> walletRequest= addWalletRequestRepository.selectByRetailerId(offset, limit, retailerId);
148
		List<AddWalletRequest> walletRequest = addWalletRequestRepository.selectByRetailerId(offset, limit, retailerId);
160
		return  responseSender.ok(walletRequest);
149
		return responseSender.ok(walletRequest);
161
	}
150
	}
162
	
-
 
163
	
151
 
164
}
152
}
165
153