mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
update
This commit is contained in:
@@ -6302,10 +6302,32 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
|
||||
long orderCount = pageInfo.getTotal();
|
||||
|
||||
// 3. 统计总金额(使用聚合 SQL,避免查询所有数据到内存
|
||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
||||
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
|
||||
? statistics.getOrderAmount() : BigDecimal.ZERO;
|
||||
// 3. 统计总金额 (分批处理)
|
||||
BigDecimal totalOrderAmount = BigDecimal.ZERO;
|
||||
int batchSize = 500; // 每批最多 500 个站点ID
|
||||
if (stationIdList.size() > batchSize) {
|
||||
// 分批查询统计
|
||||
List<List<String>> batches = Lists.partition(stationIdList, batchSize);
|
||||
for (List<String> batch : batches) {
|
||||
QueryOrderDTO batchDTO = QueryOrderDTO.builder()
|
||||
.stationIdList(batch)
|
||||
.startTime(dto.getCreateTime())
|
||||
.endTime(dto.getEndTime())
|
||||
.orderStatus(dto.getOrderStatus())
|
||||
.startMode(dto.getStartMode())
|
||||
.stationName(dto.getStationName())
|
||||
.build();
|
||||
OrderStatisticsVO batchStatistics = orderBasicInfoMapper.countBusinessOrderStatistics(batchDTO);
|
||||
if (batchStatistics != null && batchStatistics.getOrderAmount() != null) {
|
||||
totalOrderAmount = totalOrderAmount.add(batchStatistics.getOrderAmount());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 直接查询
|
||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
||||
totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
|
||||
? statistics.getOrderAmount() : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
//4. 转换为 BusinessOrderListVO
|
||||
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()
|
||||
|
||||
@@ -1934,6 +1934,46 @@
|
||||
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="stationIdList != null and stationIdList.size() != 0">
|
||||
and t1.station_id in
|
||||
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
||||
and t1.station_id not in
|
||||
<foreach close=")" collection="excludeStationIdList" item="excludeStationId" open="(" separator=",">
|
||||
#{excludeStationId}
|
||||
</foreach>
|
||||
</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="orderStatus != null and orderStatus != ''">
|
||||
and t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="startMode != null and startMode != ''">
|
||||
and t1.start_mode = #{startMode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationName != null and stationName != ''">
|
||||
and t3.station_name like concat('%', #{stationName,jdbcType=VARCHAR}, '%')
|
||||
</if>
|
||||
<if test="stationDeptIds != null and stationDeptIds.size() != 0">
|
||||
and t3.dept_id in
|
||||
<foreach close=")" collection="stationDeptIds" item="stationDeptId" open="(" separator=",">
|
||||
#{stationDeptId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="orderCode != null and orderCode != ''">
|
||||
and t1.order_code = #{orderCode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="transactionCode != null and transactionCode != ''">
|
||||
and t1.transaction_code = #{transactionCode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="pileSn != null and pileSn != ''">
|
||||
and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||
</if>
|
||||
@@ -1943,15 +1983,6 @@
|
||||
<if test="memberId != null and memberId != ''">
|
||||
and t1.member_id = #{memberId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
and t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="orderCode != null and orderCode != ''">
|
||||
and t1.order_code = #{orderCode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="transactionCode != null and transactionCode != ''">
|
||||
and t1.transaction_code = #{transactionCode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="mobileNumber != null and mobileNumber != ''">
|
||||
and t2.mobile_number = #{mobileNumber,jdbcType=VARCHAR}
|
||||
</if>
|
||||
@@ -1961,12 +1992,6 @@
|
||||
<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="startSettleTime != null and startSettleTime != ''">
|
||||
and t1.settlement_time <![CDATA[ >= ]]> #{startSettleTime,jdbcType=VARCHAR}
|
||||
</if>
|
||||
@@ -1985,30 +2010,6 @@
|
||||
<if test="payMode != null and payMode != ''">
|
||||
and t1.pay_mode = #{payMode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationDeptIds != null and stationDeptIds.size() != 0">
|
||||
and t3.dept_id in
|
||||
<foreach close=")" collection="stationDeptIds" item="stationDeptId" open="(" separator=",">
|
||||
#{stationDeptId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
||||
and t1.station_id not in
|
||||
<foreach close=")" collection="excludeStationIdList" item="excludeStationId" open="(" separator=",">
|
||||
#{excludeStationId}
|
||||
</foreach>
|
||||
</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="startMode != null and startMode != ''">
|
||||
and t1.start_mode = #{startMode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationName != null and stationName != ''">
|
||||
and t3.station_name like concat('%', #{stationName,jdbcType=VARCHAR}, '%')
|
||||
</if>
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
@@ -2087,62 +2088,53 @@
|
||||
resultType="com.jsowell.pile.vo.web.OrderStatisticsVO">
|
||||
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'
|
||||
IFNULL(SUM(t1.order_amount), 0) AS orderAmount
|
||||
FROM order_basic_info t1
|
||||
<if test="(stationName != null and stationName != '') or (stationDeptIds != null and stationDeptIds.size() != 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="startMode != null and startMode != ''">
|
||||
AND t1.start_mode = #{startMode,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="stationName != null and stationName != ''">
|
||||
AND t3.station_name LIKE CONCAT('%', #{stationName,jdbcType=VARCHAR}, '%')
|
||||
</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
|
||||
</if>
|
||||
WHERE t1.del_flag = '0'
|
||||
<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="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
||||
AND t1.station_id NOT IN
|
||||
<foreach collection="excludeStationIdList" item="excludeStationId" open="(" separator="," close=")">
|
||||
#{excludeStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
AND t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="startMode != null and startMode != ''">
|
||||
AND t1.start_mode = #{startMode,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="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="stationName != null and stationName != ''">
|
||||
AND t3.station_name LIKE CONCAT('%', #{stationName,jdbcType=VARCHAR}, '%')
|
||||
</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>
|
||||
</select>
|
||||
|
||||
<select id="selectOrderBasicInfoById" parameterType="Long" resultMap="OrderBasicInfoOrderDetailResult">
|
||||
|
||||
Reference in New Issue
Block a user