| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.goods.domain.dto.*; |
| | | import com.ruoyi.goods.domain.pojo.goods.GoodsTotal; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | private GoodsTotalService goodsTotalService; |
| | | |
| | | /** |
| | | * 获取推荐商品列表 |
| | | * @param page |
| | | * @return |
| | | */ |
| | | * @description 获取推荐商品列表 |
| | | * @param page shopId |
| | | * @return List<AppSimpleGoodsVo> |
| | | * @author jqs34 |
| | | * @date 2023/6/4 16:27 |
| | | */ |
| | | @Override |
| | | public List<AppSimpleGoodsVo> pageRecommendGoods(Page page, Long shopId){ |
| | | List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsMapper.pageRecommendGoods(page,shopId); |
| | |
| | | * @date: 2023/6/4 15:37 |
| | | */ |
| | | @Override |
| | | public void editMgtGoods(MgtGoodsEditDto mgtGoodsEditDto){ |
| | | public void editMgtGoods(MgtGoodsEditDto mgtGoodsEditDto) { |
| | | Goods goods; |
| | | Boolean newGoods = false; |
| | | String goodsId = mgtGoodsEditDto.getGoodsId(); |
| | | // 判断是否有商品ID 没有则新建 |
| | | if(goodsId != null){ |
| | | if (goodsId != null) { |
| | | goods = this.getById(goodsId); |
| | | }else{ |
| | | } else { |
| | | goods = new Goods(); |
| | | goodsId = IdUtils.simpleUUID(); |
| | | goods.setGoodsId(goodsId); |
| | |
| | | goods.setGoodsIntroduction(mgtGoodsEditDto.getGoodsIntroduction()); |
| | | goods.setSalesPrice(mgtGoodsEditDto.getSalesPrice()); |
| | | goods.setMininumPrice(mgtGoodsEditDto.getMininumPrice()); |
| | | if(mgtGoodsEditDto.getSubscription()!=null&&mgtGoodsEditDto.getSubscription().compareTo(BigDecimal.valueOf(0))>0){ |
| | | if (mgtGoodsEditDto.getSubscription() != null && mgtGoodsEditDto.getSubscription().compareTo(BigDecimal.valueOf(0)) > 0) { |
| | | goods.setSubscriptionFlag(1); |
| | | }else{ |
| | | } else { |
| | | goods.setSubscriptionFlag(0); |
| | | } |
| | | goods.setSubscription(mgtGoodsEditDto.getSubscription()); |
| | |
| | | goods.setGoodsNurses(mgtGoodsEditDto.getGoodsNurses()); |
| | | goods.setGoodsTags(mgtGoodsEditDto.getGoodsNurses()); |
| | | this.saveOrUpdate(goods); |
| | | //商品图片视频处理 |
| | | final String goodsIdFinal = goodsId; |
| | | saveGoodsFiles(goodsIdFinal, mgtGoodsEditDto.getGoodsPicture(), 1); |
| | | saveGoodsFiles(goodsIdFinal, mgtGoodsEditDto.getGoodsVideo(), 2); |
| | | saveGoodsFiles(goodsIdFinal, mgtGoodsEditDto.getGoodsBanners(), 3); |
| | | //如果是新建商品创建商品统计 |
| | | if(newGoods){ |
| | | if (newGoods) { |
| | | GoodsTotal goodsTotal = new GoodsTotal(); |
| | | goodsTotal.setGoodsId(goodsId); |
| | | goodsTotal.setBuyCount(0); |
| | |
| | | goodsTotalService.saveOrUpdate(goodsTotal); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description: 处理商品文件 |
| | | * @param: goodsId fileUrls fileType |
| | | * @return: void |
| | | * @author jqs34 |
| | | * @date: 2023/6/4 16:25 |
| | | */ |
| | | private void saveGoodsFiles(String goodsId, String fileUrls, int fileType) { |
| | | if (StringUtils.isNotEmpty(fileUrls)) { |
| | | List<GoodsFile> files = Arrays.stream(fileUrls.split(",")) |
| | | .map(str -> { |
| | | GoodsFile goodsFile = new GoodsFile(); |
| | | goodsFile.setDelFlag(0); |
| | | goodsFile.setGoodsId(goodsId); |
| | | goodsFile.setFileType(fileType); |
| | | goodsFile.setFileUrl(str); |
| | | return goodsFile; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | // 保存文件列表 |
| | | goodsFileService.saveBatch(files); |
| | | } |
| | | } |
| | | } |