| | |
| | | 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.enums.CartTypeEnum; |
| | | 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; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.Min; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 买家端,购物车接口 |
| | |
| | | */ |
| | | @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 = "获取购物车数量") |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "再次购买") |
| | | @Validated |
| | | @PostMapping(value = "/sku/buyBack") |
| | | public ResultMessage<Object> buyBack(@RequestBody @Valid @NotEmpty List<BuyBackDTO> backDTO) { |
| | | cartService.buyBack(backDTO); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取结算页面购物车详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query") |
| | |
| | | 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; |