| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service.user;
|
1 |
package com.spice.profitmandi.service.user;
|
| 2 |
|
2 |
|
| 3 |
import com.google.common.hash.Hashing;
|
3 |
import com.google.common.hash.Hashing;
|
| - |
|
4 |
import com.spice.profitmandi.common.enumuration.ActivationType;
|
| - |
|
5 |
import com.spice.profitmandi.common.enumuration.FofoType;
|
| 4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 5 |
import com.spice.profitmandi.common.model.*;
|
7 |
import com.spice.profitmandi.common.model.*;
|
| 6 |
import com.spice.profitmandi.common.util.StringUtils;
|
8 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 7 |
import com.spice.profitmandi.common.util.Utils;
|
9 |
import com.spice.profitmandi.common.util.Utils;
|
| 8 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
10 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| Line 779... |
Line 781... |
| 779 |
private FofoStore createFofoStoreCodeByRetailerId(int retailerId, String districtName, String stateName,
|
781 |
private FofoStore createFofoStoreCodeByRetailerId(int retailerId, String districtName, String stateName,
|
| 780 |
UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
782 |
UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
| 781 |
FofoStore fofoStore = null;
|
783 |
FofoStore fofoStore = null;
|
| 782 |
try {
|
784 |
try {
|
| 783 |
fofoStore = fofoStoreRepository.selectByRetailerId(retailerId);
|
785 |
fofoStore = fofoStoreRepository.selectByRetailerId(retailerId);
|
| - |
|
786 |
fofoStore.setActivationType(ActivationType.ACTIVE);
|
| - |
|
787 |
|
| 784 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
788 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 785 |
|
789 |
|
| 786 |
}
|
790 |
}
|
| 787 |
|
791 |
|
| 788 |
if (fofoStore != null) {
|
792 |
if (fofoStore != null) {
|
| Line 816... |
Line 820... |
| 816 |
String fofoStoreCode = StringUtils.generateFofoStoreSequence(
|
820 |
String fofoStoreCode = StringUtils.generateFofoStoreSequence(
|
| 817 |
districtMaster.getStateShortName() + districtMaster.getShortName(), latestCodeCounter + 1);
|
821 |
districtMaster.getStateShortName() + districtMaster.getShortName(), latestCodeCounter + 1);
|
| 818 |
fofoStore.setCode(fofoStoreCode);
|
822 |
fofoStore.setCode(fofoStoreCode);
|
| 819 |
fofoStore.setBagsLastCredited(LocalDateTime.now());
|
823 |
fofoStore.setBagsLastCredited(LocalDateTime.now());
|
| 820 |
fofoStore.setFofoType(updateRetailerRequest.getFofoType());
|
824 |
fofoStore.setFofoType(updateRetailerRequest.getFofoType());
|
| - |
|
825 |
fofoStore.setActivationType(ActivationType.ACTIVE);
|
| 821 |
fofoStoreRepository.persist(fofoStore);
|
826 |
fofoStoreRepository.persist(fofoStore);
|
| 822 |
|
827 |
|
| 823 |
// Auto fill in onboarding Panel
|
828 |
// Auto fill in onboarding Panel
|
| 824 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository
|
829 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository
|
| 825 |
.selectByPhoneNumber(Long.parseLong(retailerAddress.getPhoneNumber()));
|
830 |
.selectByPhoneNumber(Long.parseLong(retailerAddress.getPhoneNumber()));
|
| Line 889... |
Line 894... |
| 889 |
try {
|
894 |
try {
|
| 890 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(address.getRetaierId());
|
895 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(address.getRetaierId());
|
| 891 |
customRetailer.setCode(fs.getCode());
|
896 |
customRetailer.setCode(fs.getCode());
|
| 892 |
customRetailer.setWarehouseId(fs.getWarehouseId());
|
897 |
customRetailer.setWarehouseId(fs.getWarehouseId());
|
| 893 |
customRetailer.setPartnerId(fs.getId());
|
898 |
customRetailer.setPartnerId(fs.getId());
|
| - |
|
899 |
customRetailer.setFofoType(fs.getFofoType());
|
| 894 |
} catch (Exception e) {
|
900 |
} catch (Exception e) {
|
| 895 |
continue;
|
901 |
continue;
|
| 896 |
}
|
902 |
}
|
| 897 |
try {
|
903 |
try {
|
| 898 |
customRetailer.setCartId(user.getActiveCartId());
|
904 |
customRetailer.setCartId(user.getActiveCartId());
|
| Line 1233... |
Line 1239... |
| 1233 |
.map(x -> ProfitMandiConstants.WAREHOUSE_MAP.get(x)).collect(Collectors.toList())));
|
1239 |
.map(x -> ProfitMandiConstants.WAREHOUSE_MAP.get(x)).collect(Collectors.toList())));
|
| 1234 |
}
|
1240 |
}
|
| 1235 |
}
|
1241 |
}
|
| 1236 |
return sb.toString();
|
1242 |
return sb.toString();
|
| 1237 |
}
|
1243 |
}
|
| - |
|
1244 |
|
| - |
|
1245 |
@Override
|
| - |
|
1246 |
public Map<Integer, CustomRetailer> getFofoRetailersPaginated(boolean activeOnly, int offset, int limit,
|
| - |
|
1247 |
FofoType fofoType) {
|
| - |
|
1248 |
Stream<FofoStore> storeStream = fofoStoreRepository.selectAll(offset, limit).stream();
|
| - |
|
1249 |
if (activeOnly) {
|
| - |
|
1250 |
storeStream = storeStream.filter(x -> x.isActive());
|
| - |
|
1251 |
}
|
| - |
|
1252 |
|
| - |
|
1253 |
storeStream = storeStream.filter(x -> x.getFofoType().equals(fofoType));
|
| - |
|
1254 |
List<Integer> storeIds = storeStream.map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
1255 |
return this.getFofoRetailers(storeIds);
|
| - |
|
1256 |
}
|
| - |
|
1257 |
|
| 1238 |
}
|
1258 |
}
|