| | |
| | | import com.webmanage.mapper.OrderDetailMapper; |
| | | import com.webmanage.mapper.OrderEvaluationMapper; |
| | | import com.webmanage.mapper.OrderInfoMapper; |
| | | import com.webmanage.mapper.ReportResultSubmissionMapper; |
| | | import com.webmanage.service.OrderInfoService; |
| | | import com.webmanage.service.OrderNoService; |
| | | import com.webmanage.service.MinioService; |
| | |
| | | @Resource |
| | | private MinioService minioService; |
| | | |
| | | @Resource |
| | | private ReportResultSubmissionMapper reportResultSubmissionMapper; |
| | | |
| | | @Override |
| | | public PageResult<OrderInfo> getBuyerOrderPage(OrderQueryDTO queryDTO) { |
| | | public PageResult<OrderDetailVO> getBuyerOrderPage(OrderQueryDTO queryDTO) { |
| | | // 参数校验 |
| | | if (queryDTO.getUserId() == null) { |
| | | throw new BusinessException("用户ID不能为空"); |
| | |
| | | queryDTO.getCreateTimeEnd() != null ? queryDTO.getCreateTimeEnd().toString() : null, |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection() |
| | | ); |
| | | // 将订单与详情联表封装到VO |
| | | List<OrderDetailVO> voList = result.getRecords().stream().map(order -> { |
| | | OrderDetailVO vo = new OrderDetailVO(); |
| | | BeanUtils.copyProperties(order, vo); |
| | | List<OrderDetail> details = orderDetailMapper.selectByOrderId(order.getOrderId()); |
| | | List<OrderDetailItemVO> items = details.stream().map(d -> { |
| | | OrderDetailItemVO item = new OrderDetailItemVO(); |
| | | BeanUtils.copyProperties(d, item); |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderInfo>( |
| | | result.getRecords(), |
| | | return new PageResult<OrderDetailVO>( |
| | | voList, |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<OrderInfo> getSellerOrderPage(OrderQueryDTO queryDTO) { |
| | | public PageResult<OrderDetailVO> getSellerOrderPage(OrderQueryDTO queryDTO) { |
| | | // 参数校验 |
| | | if (queryDTO.getProviderId() == null) { |
| | | throw new BusinessException("提供者ID不能为空"); |
| | |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection() |
| | | ); |
| | | |
| | | // 将订单与详情联表封装到VO |
| | | List<OrderDetailVO> voList = result.getRecords().stream().map(order -> { |
| | | OrderDetailVO vo = new OrderDetailVO(); |
| | | BeanUtils.copyProperties(order, vo); |
| | | List<OrderDetail> details = orderDetailMapper.selectByOrderId(order.getOrderId()); |
| | | List<OrderDetailItemVO> items = details.stream().map(d -> { |
| | | OrderDetailItemVO item = new OrderDetailItemVO(); |
| | | BeanUtils.copyProperties(d, item); |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderInfo>( |
| | | result.getRecords(), |
| | | return new PageResult<OrderDetailVO>( |
| | | voList, |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderInfo>( |
| | | result.getRecords(), |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | result.getPages() |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<OrderInfo> getPendingApprovalOrderPageWithProductConditions(OrderQueryDTO queryDTO) { |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | | // 如果没有找到匹配的产品,直接返回空结果 |
| | | if (CollectionUtils.isEmpty(productIds)) { |
| | | return new PageResult<OrderInfo>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | 0L |
| | | ); |
| | | } |
| | | } |
| | | |
| | | // 创建分页对象 |
| | | Page<OrderInfo> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize()); |
| | | |
| | | // 执行分页查询 |
| | | IPage<OrderInfo> result = baseMapper.selectPendingApprovalOrderPageWithProductConditions( |
| | | page, queryDTO.getOrderStatus(), queryDTO.getProductName(), queryDTO.getProviderName(), |
| | | queryDTO.getOrderId(), |
| | | queryDTO.getApplyTimeStart() != null ? queryDTO.getApplyTimeStart().toString() : null, |
| | | queryDTO.getApplyTimeEnd() != null ? queryDTO.getApplyTimeEnd().toString() : null, |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection(), productIds |
| | | ); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderInfo>( |
| | | result.getRecords(), |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | result.getPages() |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<OrderDetailVO> getBuyerOrderPageWithProductConditions(OrderQueryDTO queryDTO) { |
| | | // 参数校验 |
| | | if (queryDTO.getUserId() == null) { |
| | | throw new BusinessException("用户ID不能为空"); |
| | | } |
| | | |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | | // 如果没有找到匹配的产品,直接返回空结果 |
| | | if (CollectionUtils.isEmpty(productIds)) { |
| | | return new PageResult<OrderDetailVO>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | 0L |
| | | ); |
| | | } |
| | | } |
| | | |
| | | // 创建分页对象 |
| | | Page<OrderInfo> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize()); |
| | | |
| | | // 执行分页查询 |
| | | IPage<OrderInfo> result = baseMapper.selectBuyerOrderPageWithProductConditions( |
| | | page, queryDTO.getUserId(), queryDTO.getUnitId(), queryDTO.getOrderStatus(), |
| | | queryDTO.getPaymentStatus(), queryDTO.getPaymentType(), queryDTO.getProductName(), |
| | | queryDTO.getProviderName(), queryDTO.getOrderId(), |
| | | queryDTO.getApplyTimeStart() != null ? queryDTO.getApplyTimeStart().toString() : null, |
| | | queryDTO.getApplyTimeEnd() != null ? queryDTO.getApplyTimeEnd().toString() : null, |
| | | queryDTO.getCreateTimeStart() != null ? queryDTO.getCreateTimeStart().toString() : null, |
| | | queryDTO.getCreateTimeEnd() != null ? queryDTO.getCreateTimeEnd().toString() : null, |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection(), productIds |
| | | ); |
| | | |
| | | // 将订单与详情联表封装到VO |
| | | List<OrderDetailVO> voList = result.getRecords().stream().map(order -> { |
| | | OrderDetailVO vo = new OrderDetailVO(); |
| | | BeanUtils.copyProperties(order, vo); |
| | | List<OrderDetail> details = orderDetailMapper.selectByOrderId(order.getOrderId()); |
| | | List<OrderDetailItemVO> items = details.stream().map(d -> { |
| | | OrderDetailItemVO item = new OrderDetailItemVO(); |
| | | BeanUtils.copyProperties(d, item); |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderDetailVO>( |
| | | voList, |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | result.getPages() |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<OrderDetailVO> getSellerOrderPageWithProductConditions(OrderQueryDTO queryDTO) { |
| | | // 参数校验 |
| | | if (queryDTO.getProviderId() == null) { |
| | | throw new BusinessException("提供者ID不能为空"); |
| | | } |
| | | |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | | // 如果没有找到匹配的产品,直接返回空结果 |
| | | if (CollectionUtils.isEmpty(productIds)) { |
| | | return new PageResult<OrderDetailVO>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | 0L |
| | | ); |
| | | } |
| | | } |
| | | |
| | | // 创建分页对象 |
| | | Page<OrderInfo> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize()); |
| | | |
| | | // 执行分页查询 |
| | | IPage<OrderInfo> result = baseMapper.selectSellerOrderPageWithProductConditions( |
| | | page, queryDTO.getProviderId(), queryDTO.getOrderStatus(), queryDTO.getPaymentStatus(), |
| | | queryDTO.getProductName(), queryDTO.getOrderId(), |
| | | queryDTO.getApplyTimeStart() != null ? queryDTO.getApplyTimeStart().toString() : null, |
| | | queryDTO.getApplyTimeEnd() != null ? queryDTO.getApplyTimeEnd().toString() : null, |
| | | queryDTO.getCreateTimeStart() != null ? queryDTO.getCreateTimeStart().toString() : null, |
| | | queryDTO.getCreateTimeEnd() != null ? queryDTO.getCreateTimeEnd().toString() : null, |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection(), productIds |
| | | ); |
| | | |
| | | // 将订单与详情联表封装到VO |
| | | List<OrderDetailVO> voList = result.getRecords().stream().map(order -> { |
| | | OrderDetailVO vo = new OrderDetailVO(); |
| | | BeanUtils.copyProperties(order, vo); |
| | | List<OrderDetail> details = orderDetailMapper.selectByOrderId(order.getOrderId()); |
| | | List<OrderDetailItemVO> items = details.stream().map(d -> { |
| | | OrderDetailItemVO item = new OrderDetailItemVO(); |
| | | BeanUtils.copyProperties(d, item); |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderDetailVO>( |
| | | voList, |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | |
| | | throw new BusinessException("取消订单失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateWorkflowId(String orderId, String workflowId) { |
| | | if (!StringUtils.hasText(orderId)) { |
| | | throw new BusinessException("订单ID不能为空"); |
| | | } |
| | | if (!StringUtils.hasText(workflowId)) { |
| | | throw new BusinessException("工作流ID不能为空"); |
| | | } |
| | | |
| | | OrderInfo orderInfo = this.getById(orderId); |
| | | if (orderInfo == null) { |
| | | throw new BusinessException("订单不存在"); |
| | | } |
| | | |
| | | orderInfo.setWorkflowId(workflowId); |
| | | orderInfo.setUpdatedAt(LocalDateTime.now()); |
| | | return this.updateById(orderInfo); |
| | | } |
| | | } |