提交 70107539 authored 作者: hzh's avatar hzh

交易订单增加权限

上级 e1b617a9
...@@ -61,4 +61,7 @@ public class TradeOrderPageReqVO extends PageParam { ...@@ -61,4 +61,7 @@ public class TradeOrderPageReqVO extends PageParam {
@InEnum(value = TerminalEnum.class, message = "订单来源 {value}") @InEnum(value = TerminalEnum.class, message = "订单来源 {value}")
private Integer terminal; private Integer terminal;
@Schema(description = "订单id集合")
private List<Long> orderIds;
} }
package org.dromara.mall.mapper.product; package org.dromara.mall.mapper.product;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.collections4.CollectionUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlusPlus; import org.dromara.common.mybatis.core.mapper.BaseMapperPlusPlus;
import org.dromara.common.mybatis.core.page.PageResult; import org.dromara.common.mybatis.core.page.PageResult;
import org.dromara.common.mybatis.core.query.LambdaQueryWrapperX; import org.dromara.common.mybatis.core.query.LambdaQueryWrapperX;
...@@ -13,6 +16,7 @@ import org.dromara.mall.domain.product.ProductSpuDO; ...@@ -13,6 +16,7 @@ import org.dromara.mall.domain.product.ProductSpuDO;
import org.dromara.mall.enums.product.ProductConstants; import org.dromara.mall.enums.product.ProductConstants;
import org.dromara.mall.enums.product.spu.ProductSpuStatusEnum; import org.dromara.mall.enums.product.spu.ProductSpuStatusEnum;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -173,4 +177,27 @@ public interface ProductSpuMapper extends BaseMapperPlusPlus<ProductSpuDO, Produ ...@@ -173,4 +177,27 @@ public interface ProductSpuMapper extends BaseMapperPlusPlus<ProductSpuDO, Produ
update(null, updateWrapper); update(null, updateWrapper);
} }
/**
* 获取有权限的spuId集合
*
* @return spuId集合
*/
default List<Long> selectSpuIdsByDataPermission() {
// 设置权限
if (CustomerDataPermissionHelper.isNeedFilter()) {
LambdaQueryWrapper<ProductSpuDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(ProductSpuDO::getId);
if (CustomerDataPermissionHelper.isNeedFilterDeptId()) {
queryWrapper.in(ProductSpuDO::getDeptId, CustomerDataPermissionHelper.getDeptIds());
} else {
queryWrapper.eq(ProductSpuDO::getCreateBy, LoginHelper.getUserId());
}
List<ProductSpuDO> spuList = selectList(queryWrapper);
return CollectionUtils.isEmpty(spuList) ? List.of(-1L) : StreamUtils.toList(spuList, ProductSpuDO::getId);
} else {
return List.of();
}
}
} }
...@@ -44,6 +44,7 @@ public interface TradeOrderMapper extends BaseMapperPlusPlus<TradeOrderDO, Trade ...@@ -44,6 +44,7 @@ public interface TradeOrderMapper extends BaseMapperPlusPlus<TradeOrderDO, Trade
.eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId())
.inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds())
.likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode())
.inIfPresent(TradeOrderDO::getId, reqVO.getOrderIds())
.betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TradeOrderDO::getId)); .orderByDesc(TradeOrderDO::getId));
} }
......
...@@ -5,7 +5,10 @@ import cn.hutool.core.map.MapUtil; ...@@ -5,7 +5,10 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.mybatis.core.page.PageResult; import org.dromara.common.mybatis.core.page.PageResult;
import org.dromara.mall.api.dto.member.MemberUserRespDTO; import org.dromara.mall.api.dto.member.MemberUserRespDTO;
import org.dromara.mall.api.service.member.MemberUserApi; import org.dromara.mall.api.service.member.MemberUserApi;
...@@ -21,6 +24,7 @@ import org.dromara.mall.enums.trade.order.TradeOrderStatusEnum; ...@@ -21,6 +24,7 @@ import org.dromara.mall.enums.trade.order.TradeOrderStatusEnum;
import org.dromara.mall.framework.trade.delivery.core.client.ExpressClientFactory; import org.dromara.mall.framework.trade.delivery.core.client.ExpressClientFactory;
import org.dromara.mall.framework.trade.delivery.core.client.dto.ExpressTrackQueryReqDTO; import org.dromara.mall.framework.trade.delivery.core.client.dto.ExpressTrackQueryReqDTO;
import org.dromara.mall.framework.trade.delivery.core.client.dto.ExpressTrackRespDTO; import org.dromara.mall.framework.trade.delivery.core.client.dto.ExpressTrackRespDTO;
import org.dromara.mall.mapper.product.ProductSpuMapper;
import org.dromara.mall.mapper.trade.TradeOrderItemMapper; import org.dromara.mall.mapper.trade.TradeOrderItemMapper;
import org.dromara.mall.mapper.trade.TradeOrderMapper; import org.dromara.mall.mapper.trade.TradeOrderMapper;
import org.dromara.mall.service.trade.delivery.DeliveryExpressService; import org.dromara.mall.service.trade.delivery.DeliveryExpressService;
...@@ -29,7 +33,6 @@ import org.springframework.stereotype.Service; ...@@ -29,7 +33,6 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import static org.dromara.common.mall.exception.util.ServiceExceptionUtil.exception; import static org.dromara.common.mall.exception.util.ServiceExceptionUtil.exception;
import static org.dromara.common.mall.util.collection.CollectionUtils.convertSet; import static org.dromara.common.mall.util.collection.CollectionUtils.convertSet;
import static org.dromara.mall.enums.trade.ErrorCodeConstants.EXPRESS_NOT_EXISTS; import static org.dromara.mall.enums.trade.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
...@@ -49,6 +52,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { ...@@ -49,6 +52,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
@Resource @Resource
private TradeOrderMapper tradeOrderMapper; private TradeOrderMapper tradeOrderMapper;
@Resource @Resource
private ProductSpuMapper productSpuMapper;
@Resource
private TradeOrderItemMapper tradeOrderItemMapper; private TradeOrderItemMapper tradeOrderItemMapper;
@Resource @Resource
...@@ -94,6 +99,20 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { ...@@ -94,6 +99,20 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 if (userIds == null) { // 没查询到用户,说明肯定也没他的订单
return PageResult.empty(); return PageResult.empty();
} }
// 获取有权限的商品
List<Long> spuIds = productSpuMapper.selectSpuIdsByDataPermission();
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(spuIds)) {
List<TradeOrderItemDO> itemList = tradeOrderItemMapper.selectList(
new LambdaQueryWrapper<TradeOrderItemDO>()
.in(TradeOrderItemDO::getSpuId, spuIds)
.select(TradeOrderItemDO::getOrderId)
);
if (CollectionUtils.isEmpty(itemList)) {
return PageResult.empty();
}
reqVO.setOrderIds(StreamUtils.toList(itemList, TradeOrderItemDO::getOrderId));
}
// 分页查询 // 分页查询
return tradeOrderMapper.selectPage(reqVO, userIds); return tradeOrderMapper.selectPage(reqVO, userIds);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论