| Line 15... |
Line 15... |
| 15 |
import org.springframework.beans.factory.annotation.Autowired;
|
15 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 17 |
import org.springframework.stereotype.Component;
|
17 |
import org.springframework.stereotype.Component;
|
| 18 |
|
18 |
|
| 19 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
19 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 20 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
- |
|
| 21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
20 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 22 |
import com.spice.profitmandi.common.model.CustomAddress;
|
21 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| 23 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
22 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 24 |
import com.spice.profitmandi.common.model.CustomShop;
|
23 |
import com.spice.profitmandi.common.model.CustomShop;
|
| 25 |
import com.spice.profitmandi.common.model.MapWrapper;
|
24 |
import com.spice.profitmandi.common.model.MapWrapper;
|
| Line 52... |
Line 51... |
| 52 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
52 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 54 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
53 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
54 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
55 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepositoryImpl;
|
- |
|
| 58 |
import com.spice.profitmandi.dao.repository.dtr.ShopAddressRepository;
|
56 |
import com.spice.profitmandi.dao.repository.dtr.ShopAddressRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
|
57 |
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
58 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
59 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
60 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| Line 753... |
Line 751... |
| 753 |
}
|
751 |
}
|
| 754 |
|
752 |
|
| 755 |
@Override
|
753 |
@Override
|
| 756 |
public Map<Integer, CustomRetailer> getFofoRetailers(List<Integer> fofoIds) {
|
754 |
public Map<Integer, CustomRetailer> getFofoRetailers(List<Integer> fofoIds) {
|
| 757 |
List<com.spice.profitmandi.dao.entity.user.User> saholicUsers = userUserRepository.selectByIds(fofoIds);
|
755 |
List<com.spice.profitmandi.dao.entity.user.User> saholicUsers = userUserRepository.selectByIds(fofoIds);
|
| 758 |
Map<Integer, com.spice.profitmandi.dao.entity.user.User> userAddressMap = saholicUsers.stream()
|
756 |
Map<Integer, com.spice.profitmandi.dao.entity.user.User> userAddressMap = saholicUsers.stream().filter(x->x.getAddressId()!=null).collect(Collectors.toMap(x->x.getAddressId(), x->x));
|
| 759 |
.filter(x -> x.getAddressId() != null).collect(Collectors.toMap(x -> x.getAddressId(), x -> x));
|
- |
|
| 760 |
List<Address> addresses = addressRepository.selectByIds(new ArrayList<>(userAddressMap.keySet()));
|
757 |
List<Address> addresses = addressRepository.selectByIds(new ArrayList<>(userAddressMap.keySet()));
|
| 761 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
758 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
| 762 |
for (Address address : addresses) {
|
759 |
for(Address address: addresses) {
|
| 763 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
760 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
| 764 |
CustomRetailer customRetailer = new CustomRetailer();
|
761 |
CustomRetailer customRetailer = new CustomRetailer();
|
| 765 |
customRetailer.setEmail(user.getEmailId());
|
762 |
customRetailer.setEmail(user.getEmailId());
|
| 766 |
customRetailer.setBusinessName(address.getName());
|
763 |
customRetailer.setBusinessName(address.getName());
|
| 767 |
customRetailer.setMobileNumber(address.getPhoneNumber());
|
764 |
customRetailer.setMobileNumber(address.getPhoneNumber());
|
| Line 784... |
Line 781... |
| 784 |
customRetailer.setPartnerId(address.getRetaierId());
|
781 |
customRetailer.setPartnerId(address.getRetaierId());
|
| 785 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
782 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
| 786 |
}
|
783 |
}
|
| 787 |
return customRetailersMap;
|
784 |
return customRetailersMap;
|
| 788 |
}
|
785 |
}
|
| 789 |
|
786 |
|
| - |
|
787 |
@Override
|
| - |
|
788 |
public CustomRetailer getFofoRetailer(int fofoId) throws ProfitMandiBusinessException {
|
| - |
|
789 |
com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(fofoId);
|
| - |
|
790 |
Address address = null;
|
| - |
|
791 |
try {
|
| - |
|
792 |
address = addressRepository.selectById(saholicUser.getAddressId());
|
| - |
|
793 |
} catch (ProfitMandiBusinessException e1) {
|
| - |
|
794 |
// TODO Auto-generated catch block
|
| - |
|
795 |
e1.printStackTrace();
|
| - |
|
796 |
}
|
| - |
|
797 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
| - |
|
798 |
CustomRetailer customRetailer = new CustomRetailer();
|
| - |
|
799 |
customRetailer.setEmail(saholicUser.getEmailId());
|
| - |
|
800 |
customRetailer.setBusinessName(address.getName());
|
| - |
|
801 |
customRetailer.setMobileNumber(address.getPhoneNumber());
|
| - |
|
802 |
try {
|
| - |
|
803 |
customRetailer.setCartId(saholicUser.getActiveCartId());
|
| - |
|
804 |
PrivateDealUser pdu = privateDealUserRepository.selectById(address.getRetaierId());
|
| - |
|
805 |
Counter counter = counterRepository.selectById(pdu.getCounterId());
|
| - |
|
806 |
customRetailer.setGstNumber(counter.getGstin());
|
| - |
|
807 |
} catch(Exception e) {
|
| - |
|
808 |
customRetailer.setGstNumber(null);
|
| - |
|
809 |
}
|
| - |
|
810 |
CustomAddress address1 = new CustomAddress();
|
| - |
|
811 |
address1.setCity(address.getCity());
|
| - |
|
812 |
address1.setState(address.getState());
|
| - |
|
813 |
address1.setLine1(address.getLine1());
|
| - |
|
814 |
address1.setLine2(address.getLine2());
|
| - |
|
815 |
address1.setPinCode(address.getPinCode());
|
| - |
|
816 |
address1.setName(address.getName());
|
| - |
|
817 |
customRetailer.setAddress(address1);
|
| - |
|
818 |
customRetailer.setPartnerId(address.getRetaierId());
|
| - |
|
819 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
| - |
|
820 |
return customRetailer;
|
| - |
|
821 |
|
| - |
|
822 |
}
|
| - |
|
823 |
|
| 790 |
@Override
|
824 |
@Override
|
| 791 |
public Map<Integer, String> getAllFofoRetailerIdEmailIdMap() {
|
825 |
public Map<Integer, String> getAllFofoRetailerIdEmailIdMap() {
|
| 792 |
Role roleFofo = null;
|
826 |
Role roleFofo = null;
|
| 793 |
try {
|
827 |
try {
|
| 794 |
roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
|
828 |
roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
|
| Line 834... |
Line 868... |
| 834 |
for (UserAccount userAccount : userAccounts) {
|
868 |
for (UserAccount userAccount : userAccounts) {
|
| 835 |
userIdRetailerIdMap.put(userAccount.getUserId(), userAccount.getAccountKey());
|
869 |
userIdRetailerIdMap.put(userAccount.getUserId(), userAccount.getAccountKey());
|
| 836 |
}
|
870 |
}
|
| 837 |
return userIdRetailerIdMap;
|
871 |
return userIdRetailerIdMap;
|
| 838 |
}
|
872 |
}
|
| 839 |
|
873 |
|
| 840 |
private Map<Integer, String> getUserIdEmailIdMap(Set<Integer> userIds) {
|
874 |
private Map<Integer, String> getUserIdEmailIdMap(Set<Integer> userIds){
|
| 841 |
List<User> users = userRepository.selectAllByIds(userIds);
|
875 |
List<User> users = userRepository.selectAllByIds(userIds);
|
| 842 |
Map<Integer, String> userIdEmailIdMap = new HashMap<>();
|
876 |
Map<Integer, String> userIdEmailIdMap = new HashMap<>();
|
| 843 |
for (User user : users) {
|
877 |
for (User user : users) {
|
| 844 |
userIdEmailIdMap.put(user.getId(), user.getEmailId());
|
878 |
userIdEmailIdMap.put(user.getId(), user.getEmailId());
|
| 845 |
}
|
879 |
}
|