| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.panzhihua.common.model.vos.shop.*; |
| | | import com.panzhihua.common.utlis.DifferentLongListUtil; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.*; |
| | | import com.panzhihua.service_community.model.dos.*; |
| | | import com.panzhihua.service_community.service.ComShopFlowerGoodsAttrService; |
| | |
| | | shopFlowerGoodsAttrDAO.selectList(new QueryWrapper<ComShopFlowerGoodsAttrDO>().lambda() |
| | | .eq(ComShopFlowerGoodsAttrDO::getGoodsId, shopGoods.getId())); |
| | | ArrayList<AddShopFlowerGoodsAttrVO> goodsAttrVOList = Lists.newArrayList(); |
| | | StringBuilder sbr = new StringBuilder(); |
| | | int stock = 0; |
| | | int sale = 0; |
| | | for (ComShopFlowerGoodsAttrDO oneGoodsAttrDO : goodsAttrDOs) { |
| | | AddShopFlowerGoodsAttrVO goodsAttrVO = new AddShopFlowerGoodsAttrVO(); |
| | | BeanUtils.copyProperties(oneGoodsAttrDO, goodsAttrVO); |
| | | goodsAttrVO.setGoodsAttrId(oneGoodsAttrDO.getId()); |
| | | goodsAttrVO.setId(oneGoodsAttrDO.getId()); |
| | | goodsAttrVOList.add(goodsAttrVO); |
| | | sale = sale + oneGoodsAttrDO.getSale(); |
| | | stock = stock +oneGoodsAttrDO.getStock(); |
| | | sbr.append(oneGoodsAttrDO.getGoodsAttrName()).append(" "); |
| | | } |
| | | shopGoods.setGoodsAttrName(sbr.toString()); |
| | | shopGoods.setGoodsAttrs(goodsAttrVOList); |
| | | if (CollUtil.isNotEmpty(goodsAttrDOs)){ |
| | | shopGoods.setGoodsPic(goodsAttrDOs.get(0).getAttrPic()); |
| | | } |
| | | //设置商品总浏览量 |
| | | shopGoods.setViewNum(comShopFlowerGoodsViewStatisticsDAO.selectTotalViewNum(shopGoods.getId())); |
| | | String categoryNames = convenientGoodsCategoryDAO.selectCategoryScopeByGoodsId(shopGoods.getId()); |
| | | shopGoods.setCategoryName(categoryNames); |
| | | shopGoods.setStock(stock); |
| | | shopGoods.setSale(sale); |
| | | }); |
| | | } |
| | | return R.ok(comShopStoreVOIPage); |
| | |
| | | if (goodsDO == null || goodsDO.getDeleteStatus().equals(ComShopFlowerGoodsDO.deleteStatus.yes)) { |
| | | return R.fail(403, "商品不存在"); |
| | | } |
| | | if (!goodsDO.getStatus().equals(ComShopFlowerGoodsDO.status.sell)) { |
| | | return R.fail(405, "商品已下架"); |
| | | } |
| | | // if (!goodsDO.getStatus().equals(ComShopFlowerGoodsDO.status.sell)) { |
| | | // return R.fail(405, "商品已下架"); |
| | | // } |
| | | |
| | | // 根据商品id查询商品规格信息 |
| | | List<ComShopFlowerGoodsAttrVO> goodsAttrList = new ArrayList<>(); |
| | |
| | | } else { |
| | | List<Long> attrIds = |
| | | comShopFlowerGoodsAttrDOS.stream().map(ComShopFlowerGoodsAttrDO::getId).collect(Collectors.toList()); |
| | | List<Long> voAttrIds = addShopFlowerGoodsVO.getGoodsAttrVOList().stream().map(AddShopFlowerGoodsAttrVO::getGoodsAttrId) |
| | | List<Long> voAttrIds = addShopFlowerGoodsVO.getGoodsAttrVOList().stream().map(AddShopFlowerGoodsAttrVO::getId) |
| | | .collect(Collectors.toList()); |
| | | // 需要删除的规格ID——针对编辑时删除了规格的情况 |
| | | List<Long> deleteIds = DifferentLongListUtil.getDiffrent(attrIds, voAttrIds); |
| | |
| | | shopFlowerGoodsAttrDAO.deleteBatchIds(deleteIds); |
| | | } |
| | | addShopFlowerGoodsVO.getGoodsAttrVOList().forEach(goodsAttr -> { |
| | | ComShopFlowerGoodsAttrDO comShopGoodsAttrDO = shopFlowerGoodsAttrDAO.selectById(goodsAttr.getGoodsAttrId()); |
| | | ComShopFlowerGoodsAttrDO comShopGoodsAttrDO = shopFlowerGoodsAttrDAO.selectById(goodsAttr.getId()); |
| | | if (comShopGoodsAttrDO != null) { |
| | | comShopGoodsAttrDO.setPrice(goodsAttr.getPrice()); |
| | | comShopGoodsAttrDO.setCollatePrice(goodsAttr.getCollatePrice()); |