Rev 21803 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.service.pricing;import java.util.HashSet;import java.util.List;import java.util.Set;import org.springframework.beans.factory.annotation.Autowired;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.dao.entity.fofo.RetailerTag;import com.spice.profitmandi.dao.entity.fofo.TagListing;import com.spice.profitmandi.dao.entity.user.Address;import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;import com.spice.profitmandi.dao.repository.fofo.PinCodeTagRepository;import com.spice.profitmandi.dao.repository.fofo.RetailerTagRepository;import com.spice.profitmandi.dao.repository.fofo.TagListingRepository;import com.spice.profitmandi.dao.repository.user.AddressRepository;import com.spice.profitmandi.service.tag.TagService;public class PricingServiceImpl implements PricingService{@AutowiredRetailerRegisteredAddressRepository retailerRegisteredAddressRepository;@AutowiredAddressRepository addressRepository;@AutowiredPinCodeTagRepository pinCodeTagRepository;@AutowiredTagService tagService;@AutowiredRetailerTagRepository retailerTagRepository;@AutowiredTagListingRepository tagListingRepository;@Overridepublic float getPrice(int itemId, int retailerId) {int addressId;try {addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);Address retailerAddress = addressRepository.selectById(addressId);Set<Integer> pinCodeTagIds = tagService.getFofoTagIdsByPinCode(retailerAddress.getPinCode());if(pinCodeTagIds.isEmpty()){return 0;}List<RetailerTag> retailerTags = retailerTagRepository.selectByTagIds(pinCodeTagIds);if(retailerTags.isEmpty()){return 0;}Set<Integer> retailerTagIds = new HashSet<>();for(RetailerTag retailerTag : retailerTags){retailerTagIds.add(retailerTag.getTagId());}List<TagListing> tagListings = tagListingRepository.selectByItemIdAndTagIds(itemId, retailerTagIds);if(tagListings.isEmpty()){return 0;}float price = Float.MAX_VALUE;for(TagListing tagListing : tagListings){if(price > tagListing.getSellingPrice()){price = tagListing.getSellingPrice();}}if(price == Float.MAX_VALUE){price = 0;}} catch (ProfitMandiBusinessException e) {// TODO Auto-generated catch blocke.printStackTrace();}return 0;}}