| Line 12... |
Line 12... |
| 12 |
|
12 |
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
13 |
import org.apache.logging.log4j.LogManager;
|
| 14 |
import org.apache.logging.log4j.Logger;
|
14 |
import org.apache.logging.log4j.Logger;
|
| 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.cache.annotation.Cacheable;
|
| 17 |
import org.springframework.stereotype.Component;
|
18 |
import org.springframework.stereotype.Component;
|
| 18 |
|
19 |
|
| 19 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
- |
|
| 20 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
20 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21 |
import com.spice.profitmandi.common.model.CustomAddress;
|
21 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| 22 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
22 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 23 |
import com.spice.profitmandi.common.model.CustomShop;
|
23 |
import com.spice.profitmandi.common.model.CustomShop;
|
| 24 |
import com.spice.profitmandi.common.model.MapWrapper;
|
24 |
import com.spice.profitmandi.common.model.MapWrapper;
|
| Line 36... |
Line 36... |
| 36 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
36 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 37 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
37 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.FofoPartnerPaymentOption;
|
38 |
import com.spice.profitmandi.dao.entity.fofo.FofoPartnerPaymentOption;
|
| 39 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
39 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 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.user.Address;
|
42 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 42 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
43 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 43 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
44 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| 44 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
45 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| 45 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUserAddressMapping;
|
46 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUserAddressMapping;
|
| Line 58... |
Line 59... |
| 58 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
59 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
60 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
61 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
62 |
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
63 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
| - |
|
64 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
65 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
66 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
67 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
| 66 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserAddressMappingRepository;
|
68 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserAddressMappingRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
69 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
| Line 110... |
Line 112... |
| 110 |
@Autowired
|
112 |
@Autowired
|
| 111 |
private PrivateDealUserAddressMappingRepository privateDealUserAddressMappingRepository;
|
113 |
private PrivateDealUserAddressMappingRepository privateDealUserAddressMappingRepository;
|
| 112 |
|
114 |
|
| 113 |
@Autowired
|
115 |
@Autowired
|
| 114 |
private CounterRepository counterRepository;
|
116 |
private CounterRepository counterRepository;
|
| - |
|
117 |
|
| - |
|
118 |
@Autowired
|
| - |
|
119 |
private StateRepository stateRepository;
|
| 115 |
|
120 |
|
| 116 |
@Autowired
|
121 |
@Autowired
|
| 117 |
@Qualifier("userUserRepository")
|
122 |
@Qualifier("userUserRepository")
|
| 118 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
123 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 119 |
|
124 |
|
| Line 147... |
Line 152... |
| 147 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
152 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 148 |
|
153 |
|
| 149 |
}
|
154 |
}
|
| 150 |
}
|
155 |
}
|
| 151 |
Map<String, Object> map = new HashMap<>();
|
156 |
Map<String, Object> map = new HashMap<>();
|
| 152 |
map.put("stateNames", Utils.getAllStateNames());
|
157 |
map.put("stateNames", stateRepository.selectAll().stream().map(x->x.getName()).collect(Collectors.toList()));
|
| 153 |
|
158 |
|
| 154 |
if (user != null) {
|
159 |
if (user != null) {
|
| 155 |
|
160 |
|
| 156 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
161 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
| 157 |
|
162 |
|
| Line 193... |
Line 198... |
| 193 |
try {
|
198 |
try {
|
| 194 |
int retailerAddressId = retailerRegisteredAddressRepository
|
199 |
int retailerAddressId = retailerRegisteredAddressRepository
|
| 195 |
.selectAddressIdByRetailerId(retailer.getId());
|
200 |
.selectAddressIdByRetailerId(retailer.getId());
|
| 196 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
201 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
| 197 |
map.put("retailerAddress", retailerAddress);
|
202 |
map.put("retailerAddress", retailerAddress);
|
| - |
|
203 |
State state = stateRepository.selectByName(retailerAddress.getState());
|
| 198 |
// LOGGER.info("retailerAddress.." + retailerAddress);
|
204 |
// LOGGER.info("retailerAddress.." + retailerAddress);
|
| 199 |
StateInfo stateInfo = null;
|
- |
|
| 200 |
try {
|
- |
|
| 201 |
stateInfo = Utils.getStateInfo(retailerAddress.getState());
|
- |
|
| 202 |
// LOGGER.info("stateInfo" + stateInfo);
|
- |
|
| 203 |
} catch (Exception e) {
|
- |
|
| 204 |
e.printStackTrace();
|
- |
|
| 205 |
// throw new ProfitMandiBusinessException();
|
- |
|
| 206 |
}
|
- |
|
| 207 |
List<DistrictMaster> districtMasters = districtMasterRepository
|
205 |
List<DistrictMaster> districtMasters = districtMasterRepository
|
| 208 |
.selectByStateShortName(stateInfo.getShortName());
|
206 |
.selectByStateShortName(state.getShortName());
|
| 209 |
map.put("districtMasters", districtMasters);
|
207 |
map.put("districtMasters", districtMasters);
|
| 210 |
// LOGGER.info("districtMasters" + districtMasters);
|
208 |
// LOGGER.info("districtMasters" + districtMasters);
|
| 211 |
List<Shop> shops = shopRepository.selectByRetailerId(retailer.getId());
|
209 |
List<Shop> shops = shopRepository.selectByRetailerId(retailer.getId());
|
| 212 |
map.put("shops", shops);
|
210 |
map.put("shops", shops);
|
| 213 |
this.addAddress(shops);
|
211 |
this.addAddress(shops);
|
| Line 780... |
Line 778... |
| 780 |
address1.setLine2(address.getLine2());
|
778 |
address1.setLine2(address.getLine2());
|
| 781 |
address1.setPinCode(address.getPinCode());
|
779 |
address1.setPinCode(address.getPinCode());
|
| 782 |
address1.setName(address.getName());
|
780 |
address1.setName(address.getName());
|
| 783 |
customRetailer.setAddress(address1);
|
781 |
customRetailer.setAddress(address1);
|
| 784 |
customRetailer.setPartnerId(address.getRetaierId());
|
782 |
customRetailer.setPartnerId(address.getRetaierId());
|
| - |
|
783 |
customRetailer.setDisplayName(customRetailer.getBusinessName() + "-" + address1.getCity());
|
| 785 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
784 |
customRetailersMap.put(address.getRetaierId(), customRetailer);
|
| 786 |
}
|
785 |
}
|
| 787 |
return customRetailersMap;
|
786 |
return customRetailersMap;
|
| 788 |
}
|
787 |
}
|
| 789 |
|
788 |
|
| Line 851... |
Line 850... |
| 851 |
retailerIdEmailIdMap.put(userIdRetailerIdMap.get(user.getId()), user.getEmailId());
|
850 |
retailerIdEmailIdMap.put(userIdRetailerIdMap.get(user.getId()), user.getEmailId());
|
| 852 |
}
|
851 |
}
|
| 853 |
return retailerIdEmailIdMap;
|
852 |
return retailerIdEmailIdMap;
|
| 854 |
}
|
853 |
}
|
| 855 |
|
854 |
|
| 856 |
@Override
|
- |
|
| 857 |
public List<MapWrapper<Integer, String>> getFofoRetailerIdEmailIdMap() {
|
- |
|
| 858 |
List<MapWrapper<Integer, String>> mapWrappers = new ArrayList<>();
|
- |
|
| 859 |
for (Map.Entry<Integer, String> retailerIdEmailIdEntry : this.getAllFofoRetailerIdEmailIdMap().entrySet()) {
|
- |
|
| 860 |
MapWrapper<Integer, String> mapWrapper = new MapWrapper<>();
|
- |
|
| 861 |
mapWrapper.setKey(retailerIdEmailIdEntry.getKey());
|
- |
|
| 862 |
mapWrapper.setValue(retailerIdEmailIdEntry.getValue());
|
- |
|
| 863 |
mapWrappers.add(mapWrapper);
|
- |
|
| 864 |
}
|
- |
|
| 865 |
return mapWrappers;
|
- |
|
| 866 |
}
|
- |
|
| 867 |
|
- |
|
| 868 |
private Map<Integer, Integer> getUserIdRetailerIdMap(List<Integer> userIds) {
|
855 |
private Map<Integer, Integer> getUserIdRetailerIdMap(List<Integer> userIds) {
|
| 869 |
List<UserAccount> userAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userIds));
|
856 |
List<UserAccount> userAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userIds));
|
| 870 |
Map<Integer, Integer> userIdRetailerIdMap = new HashMap<>();
|
857 |
Map<Integer, Integer> userIdRetailerIdMap = new HashMap<>();
|
| 871 |
for (UserAccount userAccount : userAccounts) {
|
858 |
for (UserAccount userAccount : userAccounts) {
|
| 872 |
userIdRetailerIdMap.put(userAccount.getUserId(), userAccount.getAccountKey());
|
859 |
userIdRetailerIdMap.put(userAccount.getUserId(), userAccount.getAccountKey());
|
| Line 896... |
Line 883... |
| 896 |
retailerIdEmailIdMap.put(userAccount.getAccountKey(), userIdEmailIdMap.get(userAccount.getUserId()));
|
883 |
retailerIdEmailIdMap.put(userAccount.getAccountKey(), userIdEmailIdMap.get(userAccount.getUserId()));
|
| 897 |
}
|
884 |
}
|
| 898 |
return retailerIdEmailIdMap;
|
885 |
return retailerIdEmailIdMap;
|
| 899 |
}
|
886 |
}
|
| 900 |
@Override
|
887 |
@Override
|
| 901 |
public Map<Integer, String> getFofoRetailerIdNameMap(List<Integer> storeIds) {
|
888 |
public Map<Integer, String> getAllFofoRetailerIdNameMap(List<Integer> storeIds) {
|
| 902 |
Map<Integer, CustomRetailer> retailersMap = this.getFofoRetailers(storeIds);
|
889 |
Map<Integer, CustomRetailer> retailersMap = this.getFofoRetailers(storeIds);
|
| 903 |
Map<Integer, String> retailerIdNameMap = new HashMap<>();
|
890 |
Map<Integer, String> retailerIdNameMap = new HashMap<>();
|
| 904 |
for (Map.Entry<Integer, CustomRetailer> entry: retailersMap.entrySet()) {
|
891 |
for (Map.Entry<Integer, CustomRetailer> entry: retailersMap.entrySet()) {
|
| 905 |
retailerIdNameMap.put(entry.getKey(), entry.getValue().getBusinessName() + "(" + entry.getValue().getEmail() + ")");
|
892 |
retailerIdNameMap.put(entry.getKey(), entry.getValue().getBusinessName() + "-" + entry.getValue().getAddress().getCity());
|
| 906 |
}
|
893 |
}
|
| 907 |
return retailerIdNameMap;
|
894 |
return retailerIdNameMap;
|
| 908 |
}
|
895 |
}
|
| 909 |
|
896 |
|
| 910 |
@Override
|
897 |
@Override
|
| 911 |
public Map<Integer, String> getAllFofoRetailerIdNameMap() {
|
898 |
public Map<Integer, String> getAllFofoRetailerIdNameMap() {
|
| - |
|
899 |
List<FofoStore> stores = fofoStoreRepository.selectAll();
|
| - |
|
900 |
List<Integer> storeIds = stores.stream().map(x->x.getId()).collect(Collectors.toList());
|
| - |
|
901 |
return this.getAllFofoRetailerIdNameMap(storeIds);
|
| - |
|
902 |
}
|
| - |
|
903 |
|
| - |
|
904 |
@Override
|
| - |
|
905 |
public List<MapWrapper<Integer, String>> getAllFofoRetailerIdNameList() {
|
| - |
|
906 |
List<MapWrapper<Integer, String>> mapWrappers = new ArrayList<>();
|
| - |
|
907 |
// TODO Auto-generated method stub
|
| - |
|
908 |
Map<Integer, String> fofoIdNameMap = this.getAllFofoRetailerIdNameMap();
|
| - |
|
909 |
fofoIdNameMap .forEach((fofoId,name)->{
|
| - |
|
910 |
MapWrapper<Integer, String> idWrapper = new MapWrapper<>();
|
| - |
|
911 |
idWrapper.setKey(fofoId);
|
| - |
|
912 |
idWrapper.setValue(name);
|
| - |
|
913 |
mapWrappers.add(idWrapper);
|
| - |
|
914 |
});
|
| - |
|
915 |
return mapWrappers;
|
| - |
|
916 |
}
|
| - |
|
917 |
|
| - |
|
918 |
|
| - |
|
919 |
@Override
|
| - |
|
920 |
@Cacheable(value="retailerNames", cacheManager="cacheManager")
|
| - |
|
921 |
public Map<Integer, CustomRetailer> getFofoRetailers() {
|
| 912 |
// TODO Auto-generated method stub
|
922 |
// TODO Auto-generated method stub
|
| 913 |
List<FofoStore> stores = fofoStoreRepository.selectAll();
|
923 |
List<FofoStore> stores = fofoStoreRepository.selectAll();
|
| 914 |
List<Integer> storeIds = stores.stream().map(x->x.getId()).collect(Collectors.toList());
|
924 |
List<Integer> storeIds = stores.stream().map(x->x.getId()).collect(Collectors.toList());
|
| 915 |
return this.getFofoRetailerIdNameMap(storeIds);
|
925 |
return this.getFofoRetailers(storeIds);
|
| 916 |
}
|
926 |
}
|
| 917 |
|
927 |
|
| 918 |
}
|
928 |
}
|