| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.awt.event.WindowStateListener; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | return shoppingGoodsDao.selectByModelData(shoppingGoods); |
| | | } |
| | | |
| | | /** |
| | | * 计算失效时间 |
| | | * |
| | | * @param shoppingGoods |
| | | * @param type 1 - 购买时 2 - 消耗时 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type) { |
| | | if (StringUtils.isBlank(shoppingGoods.getBuyValid()) && StringUtils.isBlank(shoppingGoods.getUseValid()) && shoppingGoods.getInvalidTime() == null) { |
| | | return null; |
| | | } |
| | | Date target = null; |
| | | Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit()); |
| | | Date useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit()); |
| | | |
| | | if (buyValidDate.after(useValidDate)) { |
| | | target = useValidDate; |
| | | } else { |
| | | target = buyValidDate; |
| | | } |
| | | |
| | | if (shoppingGoods.getInvalidTime() != null) { |
| | | if (target.after(shoppingGoods.getInvalidTime())) { |
| | | target = shoppingGoods.getInvalidTime(); |
| | | } |
| | | } |
| | | return target; |
| | | } |
| | | } |