| | |
| | | package cn.lili.controller.order; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; |
| | | import cn.lili.common.enums.ResultCode; |
| | | import cn.lili.common.enums.ResultUtil; |
| | | import cn.lili.common.exception.ServiceException; |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.common.vo.ResultMessage; |
| | | import cn.lili.modules.order.cart.entity.dto.BuyBackDTO; |
| | | import cn.lili.modules.order.cart.entity.dto.TradeDTO; |
| | |
| | | import cn.lili.modules.order.cart.entity.vo.TradeParams; |
| | | import cn.lili.modules.order.cart.service.CartService; |
| | | import cn.lili.modules.order.order.entity.vo.ReceiptVO; |
| | | import cn.lili.utils.COSUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | */ |
| | | @Autowired |
| | | private CartService cartService; |
| | | @Autowired |
| | | private COSUtil cosUtil; |
| | | |
| | | |
| | | @ApiOperation(value = "向购物车中添加一个产品") |
| | |
| | | @ApiOperation(value = "获取购物车页面购物车详情") |
| | | @GetMapping("/all") |
| | | public ResultMessage<TradeDTO> cartAll() { |
| | | return ResultUtil.data(this.cartService.getAllTradeDTO()); |
| | | TradeDTO allTradeDTO = this.cartService.getAllTradeDTO(); |
| | | allTradeDTO.getSkuList().forEach(item->{ |
| | | String goodsVideo = item.getGoodsSku().getGoodsVideo(); |
| | | if (StringUtils.isNotBlank(goodsVideo)&&!goodsVideo.contains("http")) { |
| | | item.getGoodsSku().setGoodsVideo(cosUtil.getPreviewUrl(goodsVideo)); |
| | | } |
| | | |
| | | String thumbnail = item.getGoodsSku().getThumbnail(); |
| | | if (StringUtils.isNotBlank(thumbnail)&&!thumbnail.contains("http")) { |
| | | item.getGoodsSku().setThumbnail(cosUtil.getPreviewUrl(thumbnail)); |
| | | } |
| | | }); |
| | | return ResultUtil.data(allTradeDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取购物车数量") |
| | |
| | | public ResultMessage<TradeDTO> cartChecked(@NotNull(message = "读取选中列表") String way) { |
| | | try { |
| | | //读取选中的列表 |
| | | return ResultUtil.data(this.cartService.getCheckedTradeDTO(CartTypeEnum.valueOf(way))); |
| | | TradeDTO checkedTradeDTO = this.cartService.getCheckedTradeDTO(CartTypeEnum.valueOf(way)); |
| | | checkedTradeDTO.getSkuList().forEach(item->{ |
| | | |
| | | |
| | | String goodsVideo = item.getGoodsSku().getGoodsVideo(); |
| | | if (StringUtils.isNotBlank(goodsVideo)&&!goodsVideo.contains("http")) { |
| | | item.getGoodsSku().setGoodsVideo(cosUtil.getPreviewUrl(goodsVideo)); |
| | | } |
| | | |
| | | String thumbnail = item.getGoodsSku().getThumbnail(); |
| | | if (StringUtils.isNotBlank(thumbnail)&&!thumbnail.contains("http")) { |
| | | item.getGoodsSku().setThumbnail(cosUtil.getPreviewUrl(thumbnail)); |
| | | } |
| | | }); |
| | | System.err.println(JSONUtil.toJsonStr(checkedTradeDTO)); |
| | | return ResultUtil.data(checkedTradeDTO); |
| | | } catch (ServiceException se) { |
| | | log.error(se.getMsg(), se); |
| | | throw se; |