master:进货车功能调整;

pull/1121/head
liujiang 2025-05-11 23:48:57 +08:00
parent f26d2bf275
commit 30605f87cc
5 changed files with 73 additions and 19 deletions

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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());
}
/**