| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.util.Date;
|
3 |
import java.util.Date;
|
| 4 |
import java.util.List;
|
- |
|
| 5 |
import java.util.Set;
|
4 |
import java.util.Set;
|
| 6 |
|
5 |
|
| 7 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 8 |
|
7 |
|
| 9 |
import org.slf4j.Logger;
|
8 |
import org.slf4j.Logger;
|
| Line 269... |
Line 268... |
| 269 |
ur.setUserId(user.getId());
|
268 |
ur.setUserId(user.getId());
|
| 270 |
userRoleRepository.persist(ur);
|
269 |
userRoleRepository.persist(ur);
|
| 271 |
|
270 |
|
| 272 |
if(foundRetailer){
|
271 |
if(foundRetailer){
|
| 273 |
LOGGER.info("\n\n\n****retailer found\n\n\n");
|
272 |
LOGGER.info("\n\n\n****retailer found\n\n\n");
|
| - |
|
273 |
PrivateDealUser privateDealUser = null;
|
| - |
|
274 |
try{
|
| 274 |
PrivateDealUser privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
275 |
privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
| - |
|
276 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
277 |
LOGGER.error("PrivateDealUser not found : ", profitMandiBusinessException);
|
| - |
|
278 |
}
|
| 275 |
if(privateDealUser == null) {
|
279 |
if(privateDealUser == null) {
|
| 276 |
privateDealUser = new PrivateDealUser();
|
280 |
privateDealUser = new PrivateDealUser();
|
| 277 |
privateDealUser.setActive(true);
|
281 |
privateDealUser.setActive(true);
|
| 278 |
privateDealUser.setBulkShipmentAmountLimit(50000);
|
282 |
privateDealUser.setBulkShipmentAmountLimit(50000);
|
| 279 |
privateDealUser.setId(saholicUser.getId());
|
283 |
privateDealUser.setId(saholicUser.getId());
|
| Line 294... |
Line 298... |
| 294 |
LOGGER.info("retailer not found");
|
298 |
LOGGER.info("retailer not found");
|
| 295 |
//gst number intergration with counter
|
299 |
//gst number intergration with counter
|
| 296 |
Integer counterId = this.createCounter(user.getEmailId(), createRetailerRequest.getGstNumber(), user.getMobileNumber(), retailer.getName(), addressRetailer.getId());
|
300 |
Integer counterId = this.createCounter(user.getEmailId(), createRetailerRequest.getGstNumber(), user.getMobileNumber(), retailer.getName(), addressRetailer.getId());
|
| 297 |
|
301 |
|
| 298 |
|
302 |
|
| - |
|
303 |
PrivateDealUser privateDealUser = null;
|
| - |
|
304 |
try{
|
| 299 |
PrivateDealUser privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
305 |
privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
| - |
|
306 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
307 |
LOGGER.error("PrivateDealUser not found : ", profitMandiBusinessException);
|
| - |
|
308 |
}
|
| - |
|
309 |
|
| 300 |
if(privateDealUser != null){
|
310 |
if(privateDealUser != null){
|
| 301 |
//LOGGER.info("PrivateDealUser found with id [{}]", saholicUser.getId());
|
311 |
//LOGGER.info("PrivateDealUser found with id [{}]", saholicUser.getId());
|
| 302 |
privateDealUser.setCounterId(counterId);
|
312 |
privateDealUser.setCounterId(counterId);
|
| 303 |
privateDealUserRepository.update(privateDealUser);
|
313 |
privateDealUserRepository.update(privateDealUser);
|
| 304 |
}else{
|
314 |
}else{
|
| Line 378... |
Line 388... |
| 378 |
public ResponseEntity<?> createFofoStore(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DISTRICT_NAME) String districtName) throws ProfitMandiBusinessException, Exception{
|
388 |
public ResponseEntity<?> createFofoStore(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DISTRICT_NAME) String districtName) throws ProfitMandiBusinessException, Exception{
|
| 379 |
try{
|
389 |
try{
|
| 380 |
UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
|
390 |
UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
|
| 381 |
LOGGER.info("requestAttribute [userInfo={}]", userInfo);
|
391 |
LOGGER.info("requestAttribute [userInfo={}]", userInfo);
|
| 382 |
User user = userRepository.selectById(userInfo.getUserId());
|
392 |
User user = userRepository.selectById(userInfo.getUserId());
|
| 383 |
List<RoleType> roleTypes = userRoleRepository.selectRoleTypesByUserId(user.getId());
|
393 |
// = userAccountRepository.selectRetailerIdByUserId(user.getId());
|
| 384 |
|
- |
|
| 385 |
UserAccounts userAccounts = userAccountRepository.selectSaholicByUserId(user.getId());
|
394 |
UserAccounts userAccounts = userAccountRepository.selectSaholicByUserId(user.getId());
|
| - |
|
395 |
Retailer retailer = retailerRepository.selectById(Integer.parseInt(userAccounts.getAccount_key()));
|
| 386 |
|
396 |
try{
|
| 387 |
if(!roleTypes.contains(RoleType.FOFO)){
|
397 |
userRoleRepository.selectByUserIdAndRoleType(user.getId(), RoleType.FOFO);
|
| - |
|
398 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 388 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, user.getId(), "USR_1013");
|
399 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, user.getId(), "USR_1013");
|
| 389 |
}
|
400 |
}
|
| 390 |
|
401 |
|
| 391 |
boolean foundFofoStore = false;
|
402 |
boolean foundFofoStore = false;
|
| 392 |
Retailer retailer = retailerRepository.selectById(Integer.parseInt(userAccounts.getAccount_key()));
|
- |
|
| 393 |
try{
|
403 |
try{
|
| 394 |
fofoStoreRepository.selectByRetailerId(retailer.getId());
|
404 |
fofoStoreRepository.selectByRetailerId(retailer.getId());
|
| 395 |
foundFofoStore = true;
|
405 |
foundFofoStore = true;
|
| 396 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
406 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 397 |
|
407 |
|