| Line 25... |
Line 25... |
| 25 |
import com.spice.profitmandi.dao.repository.dtr.GadgetCopsInsuranceCalcRepository;
|
25 |
import com.spice.profitmandi.dao.repository.dtr.GadgetCopsInsuranceCalcRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
28 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| - |
|
30 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 30 |
import com.spice.profitmandi.service.tag.TagService;
|
31 |
import com.spice.profitmandi.service.tag.TagService;
|
| 31 |
|
32 |
|
| 32 |
@Component
|
33 |
@Component
|
| 33 |
public class PricingServiceImpl implements PricingService{
|
34 |
public class PricingServiceImpl implements PricingService{
|
| 34 |
|
35 |
|
| Line 37... |
Line 38... |
| 37 |
|
38 |
|
| 38 |
@Autowired
|
39 |
@Autowired
|
| 39 |
private AddressRepository addressRepository;
|
40 |
private AddressRepository addressRepository;
|
| 40 |
|
41 |
|
| 41 |
@Autowired
|
42 |
@Autowired
|
| - |
|
43 |
private SchemeService schemeService;
|
| - |
|
44 |
|
| - |
|
45 |
@Autowired
|
| 42 |
private TagService tagService;
|
46 |
private TagService tagService;
|
| 43 |
|
47 |
|
| 44 |
@Autowired
|
48 |
@Autowired
|
| 45 |
private TagListingRepository tagListingRepository;
|
49 |
private TagListingRepository tagListingRepository;
|
| 46 |
|
50 |
|
| Line 137... |
Line 141... |
| 137 |
return tagListings;
|
141 |
return tagListings;
|
| 138 |
}
|
142 |
}
|
| 139 |
|
143 |
|
| 140 |
@Override
|
144 |
@Override
|
| 141 |
public Map<Integer, PriceModel> getMopPrices(Set<Integer> itemIds, int retailerId) {
|
145 |
public Map<Integer, PriceModel> getMopPrices(Set<Integer> itemIds, int retailerId) {
|
| - |
|
146 |
//Set Price with max value
|
| 142 |
Map<Integer, PriceModel> itemIdPrice = this.preparePriceModelDefaultValues(itemIds);
|
147 |
Map<Integer, PriceModel> itemPriceMap = this.preparePriceModelDefaultValues(itemIds);
|
| 143 |
List<TagListing> tagListings = this.getTagListing(itemIds, retailerId);
|
148 |
List<TagListing> tagListings = this.getTagListing(itemIds, retailerId);
|
| 144 |
for(TagListing tagListing : tagListings){
|
149 |
for(TagListing tagListing : tagListings){
|
| 145 |
PriceModel priceModel = itemIdPrice.get(tagListing.getItemId());
|
150 |
PriceModel priceModel = itemPriceMap.get(tagListing.getItemId());
|
| 146 |
//In case of hot deal mop is set to 0
|
151 |
//In case of hot deal mop is set to retailer buying price
|
| 147 |
if(tagListing.isHotDeals()) {
|
152 |
if(tagListing.isHotDeals()) {
|
| 148 |
priceModel.setMop(true);
|
153 |
priceModel.setMop(true);
|
| 149 |
priceModel.setPrice(0);
|
154 |
priceModel.setPrice(tagListing.getSellingPrice());
|
| 150 |
priceModel.setPurchasePrice(tagListing.getSellingPrice());
|
155 |
priceModel.setPurchasePrice(tagListing.getSellingPrice());
|
| 151 |
priceModel.setMrp(tagListing.getMrp());
|
156 |
priceModel.setMrp(tagListing.getMrp());
|
| 152 |
} else if(itemIdPrice.get(tagListing.getItemId()).getPrice() > tagListing.getMop()){
|
157 |
} else if(itemPriceMap.get(tagListing.getItemId()).getPrice() > tagListing.getMop()){
|
| 153 |
priceModel.setPrice(tagListing.getMop());
|
158 |
priceModel.setPrice(tagListing.getMop());
|
| 154 |
priceModel.setMop(true);
|
159 |
priceModel.setMop(true);
|
| - |
|
160 |
if(schemeService.getItemSchemeCashBack().get(tagListing.getItemId())!= null) {
|
| - |
|
161 |
priceModel.setMaxDiscountAmount(schemeService.getItemSchemeCashBack().get(tagListing.getItemId()));
|
| - |
|
162 |
}
|
| 155 |
priceModel.setPurchasePrice(tagListing.getSellingPrice());
|
163 |
priceModel.setPurchasePrice(tagListing.getSellingPrice());
|
| 156 |
priceModel.setMrp(tagListing.getMrp());
|
164 |
priceModel.setMrp(tagListing.getMrp());
|
| 157 |
}
|
165 |
}
|
| 158 |
}
|
166 |
}
|
| 159 |
return itemIdPrice;
|
167 |
return itemPriceMap;
|
| 160 |
}
|
168 |
}
|
| 161 |
|
169 |
|
| 162 |
@Override
|
170 |
@Override
|
| 163 |
public Map<Float, GadgetCopsInsuranceCalc> getInsurancePrices(Set<Float> prices, String providerName) throws ProfitMandiBusinessException{
|
171 |
public Map<Float, GadgetCopsInsuranceCalc> getInsurancePrices(Set<Float> prices, String providerName) throws ProfitMandiBusinessException{
|
| 164 |
insuranceProviderRepository.selectByName(providerName);
|
172 |
insuranceProviderRepository.selectByName(providerName);
|
| Line 177... |
Line 185... |
| 177 |
}
|
185 |
}
|
| 178 |
return pricesMap;
|
186 |
return pricesMap;
|
| 179 |
}
|
187 |
}
|
| 180 |
|
188 |
|
| 181 |
@Override
|
189 |
@Override
|
| 182 |
public Map<Integer, Float> getPurchasePrices(Set<Integer> itemIds, int retailerId) {
|
- |
|
| 183 |
Map<Integer, Float> purchasePriceMap = this.preparePriceDefaultValues(itemIds);
|
- |
|
| 184 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdItemIds(retailerId, itemIds);
|
- |
|
| 185 |
for(InventoryItem inventoryItem : inventoryItems){
|
- |
|
| 186 |
if(inventoryItem.getUnitPrice() < purchasePriceMap.get(inventoryItem.getItemId())){
|
- |
|
| 187 |
purchasePriceMap.put(inventoryItem.getItemId(), inventoryItem.getUnitPrice());
|
- |
|
| 188 |
}
|
- |
|
| 189 |
}
|
- |
|
| 190 |
return purchasePriceMap;
|
- |
|
| 191 |
}
|
- |
|
| 192 |
|
- |
|
| 193 |
|
- |
|
| 194 |
@Override
|
- |
|
| 195 |
public Map<Integer, PriceModel> getPurchasePriceMopPriceNotFound(Set<Integer> itemIds, int retailerId) {
|
190 |
public Map<Integer, PriceModel> getPurchasePriceMopPriceNotFound(Set<Integer> itemIds, int retailerId) {
|
| 196 |
Map<Integer, PriceModel> mopPriceModelMap = this.getMopPrices(itemIds, retailerId);
|
191 |
return this.getMopPrices(itemIds, retailerId);
|
| 197 |
Set<Integer> purchasePriceItemIds = new HashSet<>();
|
- |
|
| 198 |
for(Map.Entry<Integer, PriceModel> entry : mopPriceModelMap.entrySet()){
|
- |
|
| 199 |
//If mop is not set then, set value to purchase price
|
- |
|
| 200 |
if(!entry.getValue().isMop()) {
|
- |
|
| 201 |
purchasePriceItemIds.add(entry.getKey());
|
- |
|
| 202 |
}
|
- |
|
| 203 |
}
|
- |
|
| 204 |
|
- |
|
| 205 |
if(!purchasePriceItemIds.isEmpty()){
|
- |
|
| 206 |
Map<Integer, Float> purchasePriceMap = this.getPurchasePrices(purchasePriceItemIds, retailerId);
|
- |
|
| 207 |
for(Map.Entry<Integer, Float> entry : purchasePriceMap.entrySet()){
|
- |
|
| 208 |
PriceModel pm = mopPriceModelMap.get(entry.getKey());
|
- |
|
| 209 |
pm.setMop(false);
|
- |
|
| 210 |
pm.setPrice(entry.getValue());
|
- |
|
| 211 |
pm.setPurchasePrice(entry.getValue());
|
- |
|
| 212 |
pm.setMaxDiscountAmount(0);
|
- |
|
| 213 |
}
|
- |
|
| 214 |
}
|
- |
|
| 215 |
|
- |
|
| 216 |
return mopPriceModelMap;
|
- |
|
| 217 |
}
|
192 |
}
|
| 218 |
|
193 |
|
| 219 |
//Currently it only handles fofos
|
194 |
//Currently it only handles fofos
|
| 220 |
@SuppressWarnings("unchecked")
|
195 |
@SuppressWarnings("unchecked")
|
| 221 |
public List<Integer> getTagsIdsByRetailerId(int retailerId){
|
196 |
public List<Integer> getTagsIdsByRetailerId(int retailerId){
|