| | |
| | | import com.mzl.flower.entity.customer.Collect; |
| | | import com.mzl.flower.entity.customer.Customer; |
| | | import com.mzl.flower.entity.flower.*; |
| | | import com.mzl.flower.entity.menber.Member; |
| | | import com.mzl.flower.entity.payment.Cart; |
| | | import com.mzl.flower.entity.payment.Order; |
| | | import com.mzl.flower.entity.payment.OrderItem; |
| | |
| | | } |
| | | try{ |
| | | |
| | | flowerMapper.updateTypeRankNull(flower.getCategory(),flower.getLevel()); |
| | | |
| | | QueryWrapper<Flower> queryWrapper=new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(Flower::getDeleted,false) |
| | | .eq(Objects.nonNull(flower.getCategory()),Flower::getCategory,flower.getCategory()) |
| | | .eq(StringUtils.isNotEmpty(flower.getLevel()),Flower::getLevel,flower.getLevel()) |
| | | .eq(Flower::getStatus,"UP") |
| | | .orderByAsc(Flower::getPrice); |
| | | final List<Flower> flowerList = flowerMapper.selectList(queryWrapper); |
| | | |
| | |
| | | } 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); |
| | | |
| | |
| | | dto.setZoneName(String.join(",", zoneNameLs)); |
| | | } |
| | | |
| | | //TODO 合伙人加价列表 |
| | | |
| | | return dto; |
| | | } |
| | | |
| | |
| | | //清除购物车商品 |
| | | cartMapper.delete(new QueryWrapper<Cart>().eq("flower_id", id)); |
| | | } |
| | | |
| | | //更新排名 |
| | | updateFlowTypeRank(null,f.getCategory(),f.getLevel()); |
| | | } |
| | | |
| | | public void deleteFlower(Long id){ |
| | | |
| | | final Flower flower = flowerMapper.selectById(id); |
| | | if(flower == null){ |
| | | throw new ValidationException("商品未找到"); |
| | | } |
| | | |
| | | flowerMapper.deleteById(id); |
| | | |
| | |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | dto.setParamId(paramService.getParamIdByCategoryId(dto.getCategory())); |
| | | List<FlowerShowListDTO> ls = flowerMapper.selectFlowerShowList(page, dto); |
| | | if(ls != null && ls.size() > 0){ |
| | | Long partnerId = getCurrentCustomerPartner(); |
| | | for(FlowerShowListDTO s : ls){ |
| | | BigDecimal price = getFinalPrice(partnerId, s.getCategory() |
| | | , s.getId(), s.getPrice(), s.getLevel()); |
| | | s.setPrice(price); |
| | | s.setCollection(s.getCollectCount() > 0); |
| | | s.setShopnum(s.getShopnum() == null ? 0 : s.getShopnum()); |
| | | |
| | | if(s.getSales() != null && s.getRealSales() != null){ |
| | | s.setSales(s.getSales() + s.getRealSales()); |
| | | } |
| | | } |
| | | } |
| | | prepareShowList(ls); |
| | | |
| | | page.setRecords(ls); |
| | | |
| | |
| | | if(pId == null){ |
| | | pId = getCurrentCustomerPartner(); |
| | | } |
| | | Customer p = getCurrentCustomerWithoutCheck(); |
| | | Long levelId = p == null ? null : p.getLevelId(); |
| | | Member member = getMember(levelId); |
| | | |
| | | BigDecimal price = getFinalPrice(pId, dto.getCategory() |
| | | , dto.getId(), dto.getPrice(), dto.getLevel()); |
| | | dto.setPrice(price); |
| | | dto.setPriceMember(calculateMemberPrice(price, member)); |
| | | |
| | | String userId = SecurityUtils.getUserId(); |
| | | if(StringUtils.isNotEmpty(userId)) { |
| | |
| | | |
| | | dto.setParamId(paramService.getParamIdByCategoryId(dto.getCategory())); |
| | | List<FlowerShowListDTO> flowerShowListDTOS = flowerMapper.myCollect(page, dto); |
| | | prepareShowList(flowerShowListDTOS); |
| | | |
| | | page.setRecords(flowerShowListDTOS); |
| | | return page; |
| | | } |
| | | |
| | | private void prepareShowList(List<FlowerShowListDTO> ls){ |
| | | if(ls != null && ls.size() > 0){ |
| | | Customer p = getCurrentCustomerWithoutCheck(); |
| | | Long partnerId = p == null ? null : p.getPartnerId(); |
| | | Long levelId = p == null ? null : p.getLevelId(); |
| | | Member member = getMember(levelId); |
| | | |
| | | for(FlowerShowListDTO s : ls){ |
| | | BigDecimal price = getFinalPrice(partnerId, s.getCategory() |
| | | , s.getId(), s.getPrice(), s.getLevel()); |
| | | s.setPrice(price); |
| | | s.setPriceMember(calculateMemberPrice(price, member)); |
| | | |
| | | s.setCollection(s.getCollectCount() > 0); |
| | | s.setShopnum(s.getShopnum() == null ? 0 : s.getShopnum()); |
| | | |
| | | if(s.getSales() != null && s.getRealSales() != null){ |
| | | s.setSales(s.getSales() + s.getRealSales()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public Page<FlowerShowListDTO> myBrowseHistory(Page page, FlowerShowQueryDTO dto) { |
| | |
| | | }*/ |
| | | dto.setParamId(paramService.getParamIdByCategoryId(dto.getCategory())); |
| | | List<FlowerShowListDTO> flowerShowListDTOS = flowerMapper.myBrowseHistory(page, dto); |
| | | prepareShowList(flowerShowListDTOS); |
| | | |
| | | page.setRecords(flowerShowListDTOS); |
| | | return page; |
| | | } |
| | |
| | | if(dto.getZoneId()!=null && dto.getZoneId().size()>0){//添加专区 |
| | | for (Long zoneId : dto.getZoneId()) { |
| | | for(Long flowerId : dto.getIds()) { |
| | | FlowerZoneMap fzp = flowerZoneMapMapper.selectOne(new QueryWrapper<FlowerZoneMap>().eq("flower_id", flowerId).eq("zone_id", zoneId)); |
| | | FlowerZoneMap fzp = flowerZoneMapMapper.selectOne(new QueryWrapper<FlowerZoneMap>() |
| | | .eq("flower_id", flowerId).eq("zone_id", zoneId)); |
| | | if(fzp==null){ |
| | | fzp = new FlowerZoneMap(); |
| | | fzp.setFlowerId(flowerId); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |