master:进货车功能调整;
parent
f26d2bf275
commit
30605f87cc
|
|
@ -7,10 +7,7 @@ import com.ruoyi.common.core.domain.R;
|
|||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.web.controller.xkt.vo.userShoppingCart.*;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageResDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShoppingCartDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShoppingCartEditDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.*;
|
||||
import com.ruoyi.xkt.service.IShoppingCartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -19,6 +16,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Controller
|
||||
*
|
||||
|
|
@ -76,12 +75,12 @@ public class ShoppingCartController extends XktBaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 根据shoppingCartId获取详情
|
||||
* 进货车下单时及商品下单时获取商品列表
|
||||
*/
|
||||
@ApiOperation(value = "根据shoppingCartId获取详情", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/storeProdId/{storeProdId}")
|
||||
public R<ShopCartResVO> getByStoreProdId(@PathVariable Long storeProdId) {
|
||||
return R.ok(BeanUtil.toBean(shopCartService.getByStoreProdId(storeProdId), ShopCartResVO.class));
|
||||
@ApiOperation(value = "进货车下单时及商品下单时获取商品列表", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/list")
|
||||
public R<List<ShopCartResVO>> getList(@Validated @RequestBody ShopCartListVO listVO) {
|
||||
return R.ok(BeanUtil.copyToList(shopCartService.getList(BeanUtil.toBean(listVO, ShopCartListDTO.class)), ShopCartResVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家进货车下单")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartListVO {
|
||||
|
||||
@NotNull(message = "档口商品ID列表不可为空!")
|
||||
@ApiModelProperty(value = "档口商品ID列表")
|
||||
private List<Long> storeProdIdList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家进货车下单")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartListDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口商品ID列表")
|
||||
private List<Long> storeProdIdList;
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package com.ruoyi.xkt.service;
|
|||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Service接口
|
||||
*
|
||||
|
|
@ -54,9 +56,9 @@ public interface IShoppingCartService {
|
|||
/**
|
||||
* 根据storeProdid获取进货车详情
|
||||
*
|
||||
* @param storeProdId 商品ID
|
||||
* @param listDTO 档口商品ID列表
|
||||
* @return ShoppingCartDTO
|
||||
*/
|
||||
ShoppingCartDTO getByStoreProdId(Long storeProdId);
|
||||
List<ShoppingCartDTO> getList(ShopCartListDTO listDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alipay.api.domain.Shop;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
|
@ -267,20 +266,25 @@ public class ShoppingCartServiceImpl implements IShoppingCartService {
|
|||
/**
|
||||
* 根据storeProdid获取进货车详情
|
||||
*
|
||||
* @param storeProdId 商品ID
|
||||
* @param listDTO 商品ID列表
|
||||
* @return ShoppingCartDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ShoppingCartDTO getByStoreProdId(Long storeProdId) {
|
||||
ShoppingCart shoppingCart = this.shopCartMapper.selectOne(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.eq(ShoppingCart::getStoreProdId, storeProdId).eq(ShoppingCart::getDelFlag, Constants.UNDELETED)
|
||||
public List<ShoppingCartDTO> getList(ShopCartListDTO listDTO) {
|
||||
List<ShoppingCart> shoppingCartList = this.shopCartMapper.selectList(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.in(ShoppingCart::getStoreProdId, listDTO.getStoreProdIdList()).eq(ShoppingCart::getDelFlag, Constants.UNDELETED)
|
||||
.eq(ShoppingCart::getUserId, SecurityUtils.getUserId()));
|
||||
if (CollectionUtils.isEmpty(shoppingCartList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<ShoppingCartDetail> detailList = this.shopCartDetailMapper.selectList(new LambdaQueryWrapper<ShoppingCartDetail>()
|
||||
.eq(ShoppingCartDetail::getShoppingCartId, shoppingCart.getId())
|
||||
.in(ShoppingCartDetail::getShoppingCartId, shoppingCartList.stream().map(ShoppingCart::getId).collect(Collectors.toList()))
|
||||
.eq(ShoppingCartDetail::getDelFlag, Constants.UNDELETED));
|
||||
return BeanUtil.toBean(shoppingCart, ShoppingCartDTO.class)
|
||||
.setDetailList(BeanUtil.copyToList(detailList, ShoppingCartDTO.SCDetailDTO.class));
|
||||
Map<Long, List<ShoppingCartDetail>> detailMap = detailList.stream().collect(Collectors.groupingBy(ShoppingCartDetail::getShoppingCartId));
|
||||
return shoppingCartList.stream().map(x -> BeanUtil.toBean(x, ShoppingCartDTO.class)
|
||||
.setDetailList(BeanUtil.copyToList(detailMap.get(x.getId()), ShoppingCartDTO.SCDetailDTO.class)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue