| | |
| | | } 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()); |
| | | g.setLimited(dto.getLimited()); |
| | | 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); |
| | | |
| | |
| | | public Page<FlowerShowListDTO> myCollect(Page page, FlowerShowQueryDTO dto) { |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | if (StringUtils.isNotEmpty(dto.getColumn())) { |
| | | if(dto.getColumn().contains("sales") |
| | | || dto.getColumn().contains("stock")){ |
| | | if(dto.getColumn().contains("stock")){ |
| | | dto.setColumn(dto.getColumn() + " desc"); |
| | | } else if (dto.getColumn().contains("sales")) { |
| | | dto.setColumn("ifnull(sales, 0) + ifnull(real_sales, 0) desc"); |
| | | } |
| | | } |
| | | |
| | |
| | | s.setCollection(s.getCollectCount() > 0); |
| | | s.setShopnum(s.getShopnum() == null ? 0 : s.getShopnum()); |
| | | |
| | | if(s.getSales() != null && s.getRealSales() != null){ |
| | | /*if(s.getSales() != null && s.getRealSales() != null){ |
| | | s.setSales(s.getSales() + s.getRealSales()); |
| | | } |
| | | }*/ |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | for (Long id : ids) { |
| | | Flower f = flowerMapper.selectById(id); |
| | | f.setLimited(dto.getLimited()); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | public Flower selectFlowerById(Long id) { |
| | | return flowerMapper.selectFlowerById(id); |
| | | } |
| | | |
| | | public List<Flower> selectFlowersByIds(List<Long> ids) { |
| | | return flowerMapper.selectFlowersByIds(ids); |
| | | } |
| | | } |