| Line 6... |
Line 6... |
| 6 |
import java.util.List;
|
6 |
import java.util.List;
|
| 7 |
import java.util.Map;
|
7 |
import java.util.Map;
|
| 8 |
import java.util.Set;
|
8 |
import java.util.Set;
|
| 9 |
|
9 |
|
| 10 |
import org.apache.commons.collections.CollectionUtils;
|
10 |
import org.apache.commons.collections.CollectionUtils;
|
| - |
|
11 |
import org.slf4j.Logger;
|
| - |
|
12 |
import org.slf4j.LoggerFactory;
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 12 |
import org.springframework.stereotype.Component;
|
14 |
import org.springframework.stereotype.Component;
|
| 13 |
|
15 |
|
| 14 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
16 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 15 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
17 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| Line 55... |
Line 57... |
| 55 |
GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
57 |
GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
| 56 |
|
58 |
|
| 57 |
@Autowired
|
59 |
@Autowired
|
| 58 |
InventoryItemRepository inventoryItemRepository;
|
60 |
InventoryItemRepository inventoryItemRepository;
|
| 59 |
|
61 |
|
| - |
|
62 |
private static final Logger LOGGER = LoggerFactory.getLogger(PricingServiceImpl.class);
|
| - |
|
63 |
|
| 60 |
@Override
|
64 |
@Override
|
| 61 |
public Map<Integer, Float> getPrices(Set<Integer> itemIds, int retailerId) {
|
65 |
public Map<Integer, Float> getPrices(Set<Integer> itemIds, int retailerId) {
|
| 62 |
return getMopOrSellingPrice(itemIds, retailerId, false);
|
66 |
return getMopOrSellingPrice(itemIds, retailerId, false);
|
| 63 |
}
|
67 |
}
|
| 64 |
|
68 |
|
| Line 147... |
Line 151... |
| 147 |
}
|
151 |
}
|
| 148 |
}
|
152 |
}
|
| 149 |
return purchasePriceMap;
|
153 |
return purchasePriceMap;
|
| 150 |
}
|
154 |
}
|
| 151 |
|
155 |
|
| - |
|
156 |
|
| 152 |
@Override
|
157 |
@Override
|
| 153 |
public Map<Integer, Float> getPurchasePriceMopPriceNotFound(Set<Integer> itemIds, int retailerId) {
|
158 |
public Map<Integer, Float> getPurchasePriceMopPriceNotFound(Set<Integer> itemIds, int retailerId) {
|
| 154 |
Map<Integer, Float> mopPriceMap = this.getMopPrices(itemIds, retailerId);
|
159 |
Map<Integer, Float> mopPriceMap = this.getMopPrices(itemIds, retailerId);
|
| 155 |
boolean fetchPurchasePrice = false;
|
160 |
boolean fetchPurchasePrice = false;
|
| 156 |
for(Map.Entry<Integer, Float> entry : mopPriceMap.entrySet()){
|
161 |
for(Map.Entry<Integer, Float> entry : mopPriceMap.entrySet()){
|
| Line 158... |
Line 163... |
| 158 |
fetchPurchasePrice = true;
|
163 |
fetchPurchasePrice = true;
|
| 159 |
break;
|
164 |
break;
|
| 160 |
}
|
165 |
}
|
| 161 |
}
|
166 |
}
|
| 162 |
if(fetchPurchasePrice){
|
167 |
if(fetchPurchasePrice){
|
| 163 |
Map<Integer, Float> privateDealsPriceMap = this.getPurchasePrices(itemIds, retailerId);
|
168 |
Map<Integer, Float> purchasePriceMap = this.getPurchasePrices(itemIds, retailerId);
|
| - |
|
169 |
LOGGER.info("mopPrice [18000={}]", mopPriceMap.get(18000));
|
| - |
|
170 |
LOGGER.info("purchasePrice [18000={}]", purchasePriceMap.get(18000));
|
| 164 |
for(Map.Entry<Integer, Float> entry : mopPriceMap.entrySet()){
|
171 |
for(Map.Entry<Integer, Float> entry : mopPriceMap.entrySet()){
|
| 165 |
if(entry.getValue() == Float.MAX_VALUE){
|
172 |
if(entry.getValue() == Float.MAX_VALUE || entry.getValue() == 0f){
|
| 166 |
entry.setValue(privateDealsPriceMap.get(entry.getKey()));
|
173 |
entry.setValue(purchasePriceMap.get(entry.getKey()));
|
| 167 |
}
|
174 |
}
|
| 168 |
}
|
175 |
}
|
| 169 |
}
|
176 |
}
|
| 170 |
return mopPriceMap;
|
177 |
return mopPriceMap;
|
| 171 |
}
|
178 |
}
|
| 172 |
|
179 |
|
| 173 |
//Currently it only handles fofos
|
180 |
//Currently it only handles fofos
|
| 174 |
public List<Integer> getTagsIdsByRetailerId(int retailerId) throws Throwable{
|
181 |
public List<Integer> getTagsIdsByRetailerId(int retailerId) throws Throwable{
|
| 175 |
//Currently as pincode tags are hardly any its safe to use any hardcoded pin future need to be implemented
|
- |
|
| 176 |
//We specifically need to find out the way to identify valid pin in such scenarios
|
- |
|
| 177 |
/*int addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);
|
182 |
int addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);
|
| 178 |
Address retailerAddress = addressRepository.selectById(addressId);*/
|
183 |
Address retailerAddress = addressRepository.selectById(addressId);
|
| 179 |
Set<Integer> pinCodeTagIds = tagService.getFofoTagIdsByPinCode("110001");
|
184 |
Set<Integer> pinCodeTagIds = tagService.getFofoTagIdsByPinCode(retailerAddress.getPinCode());
|
| 180 |
Set<Integer> pinNegativeTagIds = tagService.getPinCodeNegativeTagIds();
|
185 |
Set<Integer> pinNegativeTagIds = tagService.getPinCodeNegativeTagIds();
|
| 181 |
Set<Integer> pinCodeIntersection = new HashSet<>(CollectionUtils.intersection(pinCodeTagIds, pinNegativeTagIds));
|
186 |
Set<Integer> pinCodeIntersection = new HashSet<>(CollectionUtils.intersection(pinCodeTagIds, pinNegativeTagIds));
|
| 182 |
|
187 |
|
| 183 |
Set<Integer> validTagIds = new HashSet<>(CollectionUtils.subtract(pinNegativeTagIds, pinCodeIntersection));
|
188 |
Set<Integer> validTagIds = new HashSet<>(CollectionUtils.subtract(pinNegativeTagIds, pinCodeIntersection));
|
| 184 |
Set<Integer> pinPositiveTagIds = tagService.getPinCodePositiveTagIds();
|
189 |
Set<Integer> pinPositiveTagIds = tagService.getPinCodePositiveTagIds();
|