add 新增运营端小程序查询订单列表接口

This commit is contained in:
YAS\29473
2025-12-31 15:43:48 +08:00
parent 7e2f9a4c61
commit a5fac3091f
9 changed files with 358 additions and 5 deletions

View File

@@ -19,8 +19,10 @@ import com.jsowell.pile.vo.base.OrderAmountDetailVO;
import com.jsowell.pile.vo.base.OrderPeriodAmountVO;
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
import com.jsowell.pile.vo.nanrui.JiangSuOrderInfoVO;
import com.jsowell.pile.dto.business.QueryBusinessOrderDTO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderBillingInfoVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderQueryResultVO;
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
import com.jsowell.pile.vo.uniapp.customer.PersonPileConnectorSumInfoVO;
import com.jsowell.pile.vo.uniapp.customer.SendMessageVO;
@@ -544,6 +546,13 @@ public interface OrderBasicInfoService{
BusinessOrderDetailInfoVO getBusinessOrderDetail(String orderCode);
/**
* 运营端小程序查询订单
* @param dto 查询条件
* @return 订单查询结果
*/
BusinessOrderQueryResultVO queryBusinessOrder(QueryBusinessOrderDTO dto);
/**
* 根据枪口编号和状态查询订单
* @param pileConnectorCode

View File

@@ -2,6 +2,8 @@ package com.jsowell.pile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -22,6 +24,7 @@ import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.AcquirerEnum;
import com.jsowell.common.enums.DelFlagEnum;
@@ -40,6 +43,7 @@ import com.jsowell.common.util.id.SnowflakeIdWorker;
import com.jsowell.common.util.spring.SpringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.dto.business.QueryBusinessOrderDTO;
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
@@ -59,8 +63,11 @@ import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
import com.jsowell.pile.vo.nanrui.JiangSuOrderInfoVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderBillingInfoVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderListVO;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderQueryResultVO;
import com.jsowell.pile.vo.uniapp.customer.*;
import com.jsowell.pile.vo.web.*;
import com.jsowell.pile.vo.web.OrderStatisticsVO;
import com.jsowell.wxpay.common.WeChatPayParameter;
import com.jsowell.wxpay.response.WechatPayRefundRequest;
import com.jsowell.wxpay.response.WechatPayRefundResponse;
@@ -6165,6 +6172,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
return orderBasicInfoMapper.getPlatformProfit(dto);
}
@Override
public OrderCountByTimeVO queryOrderInsuranceAmountByTime(QueryOrderDTO dto) {
if (dto == null) {
dto = new QueryOrderDTO();
@@ -6245,5 +6253,104 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public List<IndexPlatformProfitVO> getInsuranceAmount(IndexQueryDTO dto) {
return orderBasicInfoMapper.getInsuranceAmount(dto);
}
/**
* 运营端小程序查询订单
* @param dto 查询条件
* @return 订单查询结果
*/
@Override
public BusinessOrderQueryResultVO queryBusinessOrder(QueryBusinessOrderDTO dto) {
// 获取当前登录账号的运营商权限
List<MerchantInfoVO> merchantInfoVOList = UserUtils.getMerchantInfoVOList();
if (CollectionUtils.isEmpty(merchantInfoVOList)) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
List<String> merchantIds = merchantInfoVOList.stream()
.map(MerchantInfoVO::getMerchantId)
.collect(Collectors.toList());
// 根据权限查询站点列表
List<PileStationInfo> allStations = pileStationInfoService.getStationInfosByMerchantIds(merchantIds);
if (CollectionUtils.isEmpty(allStations)) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
// 根据站点名称过滤
List<String> stationIdList = new ArrayList<>();
if (StringUtils.isNotBlank(dto.getStationName())) {
List<PileStationInfo> filteredStations = allStations.stream()
.filter(s -> s.getStationName() != null && s.getStationName().contains(dto.getStationName()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(filteredStations)) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
stationIdList = filteredStations.stream()
.map(s -> String.valueOf(s.getId()))
.collect(Collectors.toList());
} else {
stationIdList = allStations.stream()
.map(s -> String.valueOf(s.getId()))
.collect(Collectors.toList());
}
// 构建QueryOrderDTO
QueryOrderDTO queryOrderDTO = QueryOrderDTO.builder()
.stationIdList(stationIdList)
.startTime(dto.getCreateTime())
.endTime(dto.getEndTime())
.orderStatus(dto.getOrderStatus())
.build();
// 分页参数处理
int pageNum = dto.getPageNum() == null || dto.getPageNum() <= 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == null || dto.getPageSize() <= 0 ? 10 : dto.getPageSize();
// 使用聚合 SQL 统计订单数量和总金额
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
// 订单数量和总金额的为空判断
long orderCount = statistics != null && statistics.getOrderCount() != null
? statistics.getOrderCount() : 0L;
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
? statistics.getOrderAmount() : BigDecimal.ZERO;
// 分页查询订单列表
PageHelper.startPage(pageNum, pageSize);
List<OrderListVO> orderListVOS = selectOrderBasicInfoList(queryOrderDTO);
PageInfo<OrderListVO> pageInfo = new PageInfo<>(orderListVOS);
// 转换为BusinessOrderListVO
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()
.map(order -> BusinessOrderListVO.builder()
.createTime(order.getCreateTime())
.startMode(order.getStartMode())
.orderAmount(StringUtils.isNotBlank(order.getOrderAmount())
? new BigDecimal(order.getOrderAmount()) : BigDecimal.ZERO)
.chargingDegree(StringUtils.isNotBlank(order.getChargingDegree())
? new BigDecimal(order.getChargingDegree()) : BigDecimal.ZERO)
.orderStatus(order.getOrderStatus())
.build())
.collect(Collectors.toList());
// 构建分页响应
com.jsowell.common.core.page.PageResponse pageResponse = com.jsowell.common.core.page.PageResponse.builder()
.pageNum(pageNum)
.pageSize(pageSize)
.total(pageInfo.getTotal())
.pages(pageInfo.getPages())
.list(businessOrderList)
.build();
// 构建返回结果
return BusinessOrderQueryResultVO.builder()
.orderCount(orderCount)
.orderAmount(totalOrderAmount)
.pageResponse(pageResponse)
.orderList(businessOrderList)
.build();
}
}