public void updateInfoOfProductInEshop(ProductInEshopInfoUpdateDto priceUpdateDto) { val.notNull(priceUpdateDto, "priceUpdateDto is null"); val.notNull(priceUpdateDto.getId(), "id is null"); // TODO validacie ProductInEshopEntity entity = productInEshopDao.readMandatory(priceUpdateDto.getId()); entity.setPriceForUnit(priceUpdateDto.getPriceForUnit()); entity.setPriceForPackage(priceUpdateDto.getPriceForPackage()); entity.setPriceForOneItemInPackage(priceUpdateDto.getPriceForOneItemInPackage()); entity.setLastUpdatedPrice(new Date()); entity.setUpdateStatus(ProductInEshopUpdateStatus.OK); // TODO ako jeden // nastavenie best price if (notExistBestPrice(entity)) { entity.setBestPrice(priceUpdateDto.getPriceForPackage()); } else { if (isBestPriceGreaterThanActualPriceForPackage(priceUpdateDto, entity)) { // nastav lepsiu cenu entity.setBestPrice(priceUpdateDto.getPriceForPackage()); } } entity.setProductAction(priceUpdateDto.getProductAction()); entity.setActionValidTo(priceUpdateDto.getActionValidTo()); entity.setProductNameInEhop(priceUpdateDto.getProductName()); entity.setProductPictureUrl(priceUpdateDto.getPictureUrl()); productInEshopDao.update(entity); }
// TODO zmenit nazov metody lebo sa voal ked sa upstate npodaril public void changeUpdateStatus(Long productInEshopId, ProductInEshopUpdateStatus updateStatus) { ProductInEshopEntity productInEshopEntity = productInEshopDao.readMandatory(productInEshopId); productInEshopEntity.setLastModified(new Date()); // musi tyu byt lebo inak stale ten isty produkt vytahuje ze ho chce upatovat productInEshopEntity.setLastUpdatedPrice(new Date()); productInEshopEntity.setUpdateStatus(updateStatus); productInEshopEntity.setPriceForOneItemInPackage(new BigDecimal(-1)); productInEshopEntity.setPriceForPackage(new BigDecimal(-1)); productInEshopEntity.setPriceForUnit(new BigDecimal(-1)); productInEshopDao.update(productInEshopEntity); }