| Line 40... |
Line 40... |
| 40 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
40 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
| 41 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
41 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| 42 |
import com.spice.profitmandi.dao.entity.user.Address;
|
42 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 43 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
43 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 44 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
44 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| - |
|
45 |
import com.spice.profitmandi.dao.entity.user.LoginRequestResponseModel;
|
| 45 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
46 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| 46 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUserAddressMapping;
|
47 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUserAddressMapping;
|
| 47 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
48 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 48 |
import com.spice.profitmandi.dao.enumuration.dtr.RetailerType;
|
49 |
import com.spice.profitmandi.dao.enumuration.dtr.RetailerType;
|
| 49 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
50 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| Line 403... |
Line 404... |
| 403 |
LOGGER.info("created....");
|
404 |
LOGGER.info("created....");
|
| 404 |
}
|
405 |
}
|
| 405 |
return saholicUser.getId();
|
406 |
return saholicUser.getId();
|
| 406 |
}
|
407 |
}
|
| 407 |
|
408 |
|
| - |
|
409 |
private com.spice.profitmandi.dao.entity.user.User createSaholicUser(
|
| - |
|
410 |
LoginRequestResponseModel loginRequestResponseModel) {
|
| - |
|
411 |
com.spice.profitmandi.dao.entity.user.User saholicUser = null;
|
| - |
|
412 |
try {
|
| - |
|
413 |
saholicUser = userUserRepository.selectByEmailId(loginRequestResponseModel.getEmail());
|
| - |
|
414 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
415 |
LOGGER.info("User doesnt exist in old system");
|
| - |
|
416 |
}
|
| - |
|
417 |
if (saholicUser == null) {
|
| - |
|
418 |
Cart cart = new Cart();
|
| - |
|
419 |
cart.setCartStatus(CartStatus.ACTIVE);
|
| - |
|
420 |
cartRepository.persist(cart);
|
| - |
|
421 |
saholicUser = new com.spice.profitmandi.dao.entity.user.User();
|
| - |
|
422 |
saholicUser.setPassword(loginRequestResponseModel.getPassword());
|
| - |
|
423 |
saholicUser.setEmailId(loginRequestResponseModel.getEmail());
|
| - |
|
424 |
saholicUser.setName(loginRequestResponseModel.getCustomerName());
|
| - |
|
425 |
saholicUser.setActiveCartId(cart.getId());
|
| - |
|
426 |
saholicUser.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
427 |
loginRequestResponseModel.setPassword(null);
|
| - |
|
428 |
userUserRepository.persist(saholicUser);
|
| - |
|
429 |
}
|
| - |
|
430 |
return saholicUser;
|
| - |
|
431 |
}
|
| - |
|
432 |
|
| 408 |
private Retailer updateRetailer(User user, Retailer retailer, UpdateRetailerRequest updateRetailerRequest)
|
433 |
private Retailer updateRetailer(User user, Retailer retailer, UpdateRetailerRequest updateRetailerRequest)
|
| 409 |
throws ProfitMandiBusinessException {
|
434 |
throws ProfitMandiBusinessException {
|
| 410 |
if (retailer == null) {
|
435 |
if (retailer == null) {
|
| 411 |
LOGGER.info("createSaholicUser.....");
|
436 |
LOGGER.info("createSaholicUser.....");
|
| 412 |
int saholicUserId = this.createSaholicUser(user, updateRetailerRequest.getName());
|
437 |
int saholicUserId = this.createSaholicUser(user, updateRetailerRequest.getName());
|
| Line 440... |
Line 465... |
| 440 |
|
465 |
|
| 441 |
private void updateSaholicUser(int retailerId, int retailerAddressId) {
|
466 |
private void updateSaholicUser(int retailerId, int retailerAddressId) {
|
| 442 |
try {
|
467 |
try {
|
| 443 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(retailerId);
|
468 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(retailerId);
|
| 444 |
user.setAddressId(retailerAddressId);
|
469 |
user.setAddressId(retailerAddressId);
|
| 445 |
userUserRepository.persist(user);
|
- |
|
| 446 |
} catch (ProfitMandiBusinessException e) {
|
470 |
} catch (ProfitMandiBusinessException e) {
|
| 447 |
|
471 |
|
| 448 |
}
|
472 |
}
|
| 449 |
}
|
473 |
}
|
| 450 |
|
474 |
|
| Line 835... |
Line 859... |
| 835 |
address1.setLine2(address.getLine2());
|
859 |
address1.setLine2(address.getLine2());
|
| 836 |
address1.setPinCode(address.getPinCode());
|
860 |
address1.setPinCode(address.getPinCode());
|
| 837 |
address1.setName(address.getName());
|
861 |
address1.setName(address.getName());
|
| 838 |
customRetailer.setAddress(address1);
|
862 |
customRetailer.setAddress(address1);
|
| 839 |
customRetailer.setPartnerId(address.getRetaierId());
|
863 |
customRetailer.setPartnerId(address.getRetaierId());
|
| - |
|
864 |
customRetailer.setDisplayName(
|
| 840 |
customRetailer.setDisplayName(customRetailer.getBusinessName() + "-" + customRetailer.getCode() + "- "+ address1.getCity());
|
865 |
customRetailer.getBusinessName() + "-" + customRetailer.getCode() + "- " + address1.getCity());
|
| 841 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
866 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
| 842 |
}
|
867 |
}
|
| 843 |
return customRetailersMap;
|
868 |
return customRetailersMap;
|
| 844 |
}
|
869 |
}
|
| 845 |
|
870 |
|
| Line 1025... |
Line 1050... |
| 1025 |
List<FofoStore> stores = fofoStoreRepository.selectAll();
|
1050 |
List<FofoStore> stores = fofoStoreRepository.selectAll();
|
| 1026 |
List<Integer> storeIds = stores.stream().map(x -> x.getId()).collect(Collectors.toList());
|
1051 |
List<Integer> storeIds = stores.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 1027 |
return this.getFofoRetailers(storeIds);
|
1052 |
return this.getFofoRetailers(storeIds);
|
| 1028 |
}
|
1053 |
}
|
| 1029 |
|
1054 |
|
| - |
|
1055 |
@Override
|
| - |
|
1056 |
public LoginRequestResponseModel registerWebUser(LoginRequestResponseModel loginRequestModel)
|
| - |
|
1057 |
throws ProfitMandiBusinessException {
|
| - |
|
1058 |
|
| - |
|
1059 |
com.spice.profitmandi.dao.entity.user.User saholicUser = this.createSaholicUser(loginRequestModel);
|
| - |
|
1060 |
loginRequestModel.setUserId(saholicUser.getId());
|
| - |
|
1061 |
|
| - |
|
1062 |
this.createRetailerAddress(loginRequestModel);
|
| - |
|
1063 |
|
| - |
|
1064 |
this.createPrivateDealUser(loginRequestModel);
|
| - |
|
1065 |
this.updateSaholicUser(saholicUser.getId(), loginRequestModel.getBusinessAddress().getId());
|
| - |
|
1066 |
|
| - |
|
1067 |
return loginRequestModel;
|
| - |
|
1068 |
|
| - |
|
1069 |
}
|
| - |
|
1070 |
|
| - |
|
1071 |
private void createPrivateDealUser(LoginRequestResponseModel loginRequestModel) {
|
| - |
|
1072 |
|
| - |
|
1073 |
Integer counterId = this.createCounter(loginRequestModel.getEmail(), loginRequestModel.getGstNumber(),
|
| - |
|
1074 |
loginRequestModel.getBusinessAddress().getPhoneNumber(),
|
| - |
|
1075 |
loginRequestModel.getBusinessAddress().getName(), loginRequestModel.getBusinessAddress().getId());
|
| - |
|
1076 |
try {
|
| - |
|
1077 |
this.createPrivateDealUser(loginRequestModel.getUserId(), counterId, false);
|
| - |
|
1078 |
} catch (Exception e) {
|
| - |
|
1079 |
LOGGER.error("ERROR : ", e);
|
| - |
|
1080 |
}
|
| - |
|
1081 |
|
| - |
|
1082 |
PrivateDealUserAddressMapping privateDealUserAddressMapping = new PrivateDealUserAddressMapping();
|
| - |
|
1083 |
privateDealUserAddressMapping.setUserId(loginRequestModel.getUserId());
|
| - |
|
1084 |
privateDealUserAddressMapping.setAddressId(loginRequestModel.getBusinessAddress().getId());
|
| - |
|
1085 |
privateDealUserAddressMappingRepository.persist(privateDealUserAddressMapping);
|
| - |
|
1086 |
|
| - |
|
1087 |
}
|
| - |
|
1088 |
|
| - |
|
1089 |
private void createRetailerAddress(LoginRequestResponseModel loginRequestResponseModel)
|
| - |
|
1090 |
throws ProfitMandiBusinessException {
|
| - |
|
1091 |
Address businessAddress = loginRequestResponseModel.getBusinessAddress();
|
| - |
|
1092 |
businessAddress.setRetaierId(loginRequestResponseModel.getUserId());
|
| - |
|
1093 |
addressRepository.persist(businessAddress);
|
| - |
|
1094 |
}
|
| 1030 |
}
|
1095 |
}
|