mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update
This commit is contained in:
@@ -6302,25 +6302,23 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
.orderStatus(dto.getOrderStatus())
|
||||
.build();
|
||||
|
||||
// 分页参数处理
|
||||
// 1. 分页参数处理
|
||||
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;
|
||||
|
||||
// 分页查询订单列表
|
||||
// 2. 分页查询订单列表
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<OrderListVO> orderListVOS = selectOrderBasicInfoList(queryOrderDTO);
|
||||
PageInfo<OrderListVO> pageInfo = new PageInfo<>(orderListVOS);
|
||||
|
||||
// 转换为BusinessOrderListVO(
|
||||
long orderCount = pageInfo.getTotal();
|
||||
|
||||
// 3. 统计总金额(使用聚合 SQL,避免查询所有数据到内存
|
||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
||||
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
|
||||
? statistics.getOrderAmount() : BigDecimal.ZERO;
|
||||
|
||||
//4. 转换为 BusinessOrderListVO
|
||||
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()
|
||||
.map(order -> BusinessOrderListVO.builder()
|
||||
.createTime(order.getCreateTime())
|
||||
@@ -6334,8 +6332,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页响应
|
||||
com.jsowell.common.core.page.PageResponse pageResponse = com.jsowell.common.core.page.PageResponse.builder()
|
||||
// 5. 构建分页响应
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageNum(pageNum)
|
||||
.pageSize(pageSize)
|
||||
.total(pageInfo.getTotal())
|
||||
@@ -6343,12 +6341,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
.list(businessOrderList)
|
||||
.build();
|
||||
|
||||
// 构建返回结果
|
||||
// 6. 构建返回结果
|
||||
return BusinessOrderQueryResultVO.builder()
|
||||
.orderCount(orderCount)
|
||||
.orderAmount(totalOrderAmount)
|
||||
.pageResponse(pageResponse)
|
||||
.orderList(businessOrderList)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,5 @@ public class BusinessOrderQueryResultVO {
|
||||
*/
|
||||
private PageResponse pageResponse;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
private List<BusinessOrderListVO> orderList;
|
||||
}
|
||||
|
||||
|
||||
@@ -1997,6 +1997,12 @@
|
||||
#{excludeStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="stationIdList != null and stationIdList.size() != 0">
|
||||
and station_id in
|
||||
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId}
|
||||
</foreach>
|
||||
</if>
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
@@ -2066,34 +2072,65 @@
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
<!--
|
||||
统计订单数量和总金额(用于运营端小程序)
|
||||
使用子查询去重,确保与分页查询 selectOrderBasicInfoList 的条件一致
|
||||
包含相同的 JOIN 条件(order_detail、pile_station_info)和过滤条件
|
||||
-->
|
||||
<select id="countBusinessOrderStatistics" parameterType="com.jsowell.pile.dto.QueryOrderDTO"
|
||||
resultType="com.jsowell.pile.vo.web.OrderStatisticsVO">
|
||||
select
|
||||
COUNT(*) as orderCount,
|
||||
IFNULL(SUM(order_amount), 0) as orderAmount
|
||||
from order_basic_info
|
||||
where del_flag = '0'
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
and order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
and merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationId != null and stationId != ''">
|
||||
and station_id = #{stationId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationIdList != null and stationIdList.size() != 0">
|
||||
and station_id in
|
||||
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId}
|
||||
</foreach>
|
||||
</if>
|
||||
SELECT
|
||||
COUNT(*) AS orderCount,
|
||||
IFNULL(SUM(order_amount), 0) AS orderAmount
|
||||
FROM (
|
||||
SELECT DISTINCT
|
||||
t1.order_code,
|
||||
t1.order_amount
|
||||
FROM order_basic_info t1
|
||||
LEFT JOIN member_basic_info t2
|
||||
ON t1.member_id = t2.member_id
|
||||
AND t2.del_flag = '0'
|
||||
JOIN pile_station_info t3
|
||||
ON t1.station_id = t3.id
|
||||
AND t3.del_flag = '0'
|
||||
JOIN order_detail t4
|
||||
ON t4.order_code = t1.order_code
|
||||
AND t4.del_flag = '0'
|
||||
WHERE t1.del_flag = '0'
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
AND t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
AND t1.merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationId != null and stationId != ''">
|
||||
AND t1.station_id = #{stationId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationIdList != null and stationIdList.size() != 0">
|
||||
AND t1.station_id IN
|
||||
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="stationDeptIds != null and stationDeptIds.size() != 0">
|
||||
AND t3.dept_id IN
|
||||
<foreach collection="stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
|
||||
#{stationDeptId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
||||
AND t1.station_id NOT IN
|
||||
<foreach collection="excludeStationIdList" item="excludeStationId" open="(" separator="," close=")">
|
||||
#{excludeStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
) AS temp
|
||||
</select>
|
||||
|
||||
<select id="selectOrderBasicInfoById" parameterType="Long" resultMap="OrderBasicInfoOrderDetailResult">
|
||||
|
||||
Reference in New Issue
Block a user