| | |
| | | import cn.lili.common.enums.ResultUtil; |
| | | import cn.lili.common.exception.ServiceException; |
| | | 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 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; |
| | | |
| | | /** |
| | | * 买家端,购物车接口 |
| | |
| | | } |
| | | |
| | | |
| | | @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") |
| New file |
| | |
| | | package cn.lili.modules.order.cart.entity.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.Min; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 再次购买使用 |
| | | * |
| | | * @author peng |
| | | * @since 2025-06-24 |
| | | */ |
| | | @Data |
| | | public class BuyBackDTO { |
| | | |
| | | @NotBlank(message = "商品skuId不能为空") |
| | | private String skuId; |
| | | |
| | | @Min(value = 1, message = "最小不能小于一个") |
| | | private Integer num; |
| | | } |
| | |
| | | package cn.lili.modules.order.cart.service; |
| | | |
| | | |
| | | 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; |
| | |
| | | */ |
| | | void delete(String[] skuIds); |
| | | |
| | | |
| | | void buyBack(List<BuyBackDTO> backDTO); |
| | | |
| | | /** |
| | | * 清空购物车 |
| | | */ |
| | |
| | | import cn.lili.modules.member.entity.dos.MemberAddress; |
| | | import cn.lili.modules.member.service.MemberAddressService; |
| | | import cn.lili.modules.member.service.MemberService; |
| | | import cn.lili.modules.order.cart.entity.dto.BuyBackDTO; |
| | | import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; |
| | | import cn.lili.modules.order.cart.entity.dto.TradeDTO; |
| | | import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; |
| | |
| | | import cn.lili.modules.store.entity.dos.StoreAddress; |
| | | import cn.lili.modules.store.service.StoreAddressService; |
| | | import cn.lili.modules.store.service.StoreService; |
| | | import com.beust.ah.A; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private StoreAddressService storeAddressService; |
| | | |
| | | @Autowired |
| | | private CartService cartService; |
| | | |
| | | @Override |
| | | public void add(String skuId, Integer num, String cartType, Boolean cover) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void buyBack(List<BuyBackDTO> backDTO) { |
| | | //将原有的商品取消选中 |
| | | cartService.checkedAll(false); |
| | | //添加商品 |
| | | backDTO.forEach(buyBackDTO -> { |
| | | cartService.add(buyBackDTO.getSkuId(), buyBackDTO.getNum(), CartTypeEnum.CART.name(), true); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void clean() { |
| | | cache.remove(this.getOriginKey(CartTypeEnum.CART)); |
| | | } |