| | |
| | | } else { |
| | | g.setPrice(dto.getPrice()); |
| | | g.setStock(dto.getStock()); |
| | | g.setLimited(dto.getLimited()); |
| | | } |
| | | |
| | | g.update(SecurityUtils.getUserId()); |
| | |
| | | public Long editFlowerAdmin(FlowerUpdateAdminDTO dto){ |
| | | Flower g = flowerMapper.selectById(dto.getId()); |
| | | g.setSales(dto.getSales()); |
| | | if (!org.springframework.util.StringUtils.isEmpty(dto.getLimited())) { |
| | | if (g.getStock() == 0 || org.springframework.util.StringUtils.isEmpty(g.getStock())) { |
| | | throw new ValidationException("库存为0或者空时不能修改限购数量"); |
| | | } |
| | | if(g.getStock()<dto.getLimited()){ |
| | | throw new ValidationException("限购数量不能大于库存"); |
| | | } |
| | | g.setLimited(dto.getLimited()); |
| | | }else{ |
| | | g.setLimited(null); |
| | | } |
| | | g.update(SecurityUtils.getUserId()); |
| | | flowerMapper.updateById(g); |
| | | |
| | |
| | | return flowerDeleteDO; |
| | | } |
| | | |
| | | public void setFlowersLimited(FlowerLimitedDTO dto) { |
| | | List<Long> ids = dto.getIds(); |
| | | if (ids == null || ids.size() == 0) { |
| | | throw new ValidationException("请选择商品"); |
| | | } |
| | | for (Long id : ids) { |
| | | Flower f = flowerMapper.selectById(id); |
| | | if (!org.springframework.util.StringUtils.isEmpty(dto.getLimited())) { |
| | | if (f.getStock() == 0 || org.springframework.util.StringUtils.isEmpty(f.getStock())) { |
| | | throw new ValidationException("商品" + f.getName() + "库存为0或者空时不能修改限购数量"); |
| | | } |
| | | if(f.getStock()<dto.getLimited()){ |
| | | throw new ValidationException("商品" + f.getName() + "限购数量不能大于库存"); |
| | | } |
| | | f.setLimited(dto.getLimited()); |
| | | }else{ |
| | | f.setLimited(null); |
| | | } |
| | | flowerMapper.updateById(f); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |