mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 06:20:07 +08:00
update
This commit is contained in:
@@ -6302,10 +6302,32 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
|
|
||||||
long orderCount = pageInfo.getTotal();
|
long orderCount = pageInfo.getTotal();
|
||||||
|
|
||||||
// 3. 统计总金额(使用聚合 SQL,避免查询所有数据到内存
|
// 3. 统计总金额 (分批处理)
|
||||||
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
|
BigDecimal totalOrderAmount = BigDecimal.ZERO;
|
||||||
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
|
int batchSize = 500; // 每批最多 500 个站点ID
|
||||||
? statistics.getOrderAmount() : BigDecimal.ZERO;
|
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
|
//4. 转换为 BusinessOrderListVO
|
||||||
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()
|
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 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'
|
join order_detail t4 on t4.order_code = t1.order_code and t4.del_flag = '0'
|
||||||
where t1.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 != ''">
|
<if test="pileSn != null and pileSn != ''">
|
||||||
and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
|
and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
@@ -1943,15 +1983,6 @@
|
|||||||
<if test="memberId != null and memberId != ''">
|
<if test="memberId != null and memberId != ''">
|
||||||
and t1.member_id = #{memberId,jdbcType=VARCHAR}
|
and t1.member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
</if>
|
</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 != ''">
|
<if test="mobileNumber != null and mobileNumber != ''">
|
||||||
and t2.mobile_number = #{mobileNumber,jdbcType=VARCHAR}
|
and t2.mobile_number = #{mobileNumber,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
@@ -1961,12 +1992,6 @@
|
|||||||
<if test="stationId != null and stationId != ''">
|
<if test="stationId != null and stationId != ''">
|
||||||
and t1.station_id = #{stationId,jdbcType=VARCHAR}
|
and t1.station_id = #{stationId,jdbcType=VARCHAR}
|
||||||
</if>
|
</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 != ''">
|
<if test="startSettleTime != null and startSettleTime != ''">
|
||||||
and t1.settlement_time <![CDATA[ >= ]]> #{startSettleTime,jdbcType=VARCHAR}
|
and t1.settlement_time <![CDATA[ >= ]]> #{startSettleTime,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
@@ -1985,30 +2010,6 @@
|
|||||||
<if test="payMode != null and payMode != ''">
|
<if test="payMode != null and payMode != ''">
|
||||||
and t1.pay_mode = #{payMode,jdbcType=VARCHAR}
|
and t1.pay_mode = #{payMode,jdbcType=VARCHAR}
|
||||||
</if>
|
</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
|
order by t1.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -2087,62 +2088,53 @@
|
|||||||
resultType="com.jsowell.pile.vo.web.OrderStatisticsVO">
|
resultType="com.jsowell.pile.vo.web.OrderStatisticsVO">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*) AS orderCount,
|
COUNT(*) AS orderCount,
|
||||||
IFNULL(SUM(order_amount), 0) AS orderAmount
|
IFNULL(SUM(t1.order_amount), 0) AS orderAmount
|
||||||
FROM (
|
FROM order_basic_info t1
|
||||||
SELECT DISTINCT
|
<if test="(stationName != null and stationName != '') or (stationDeptIds != null and stationDeptIds.size() != 0)">
|
||||||
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
|
JOIN pile_station_info t3
|
||||||
ON t1.station_id = t3.id
|
ON t1.station_id = t3.id
|
||||||
AND t3.del_flag = '0'
|
AND t3.del_flag = '0'
|
||||||
JOIN order_detail t4
|
</if>
|
||||||
ON t4.order_code = t1.order_code
|
WHERE t1.del_flag = '0'
|
||||||
AND t4.del_flag = '0'
|
<if test="stationIdList != null and stationIdList.size() != 0">
|
||||||
WHERE t1.del_flag = '0'
|
AND t1.station_id IN
|
||||||
<if test="orderStatus != null and orderStatus != ''">
|
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
||||||
AND t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
#{stationId}
|
||||||
</if>
|
</foreach>
|
||||||
<if test="merchantId != null and merchantId != ''">
|
</if>
|
||||||
AND t1.merchant_id = #{merchantId,jdbcType=VARCHAR}
|
<if test="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
||||||
</if>
|
AND t1.station_id NOT IN
|
||||||
<if test="stationId != null and stationId != ''">
|
<foreach collection="excludeStationIdList" item="excludeStationId" open="(" separator="," close=")">
|
||||||
AND t1.station_id = #{stationId,jdbcType=VARCHAR}
|
#{excludeStationId}
|
||||||
</if>
|
</foreach>
|
||||||
<if test="startTime != null and startTime != ''">
|
</if>
|
||||||
AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
|
<if test="orderStatus != null and orderStatus != ''">
|
||||||
</if>
|
AND t1.order_status = #{orderStatus,jdbcType=VARCHAR}
|
||||||
<if test="endTime != null and endTime != ''">
|
</if>
|
||||||
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
<if test="startMode != null and startMode != ''">
|
||||||
</if>
|
AND t1.start_mode = #{startMode,jdbcType=VARCHAR}
|
||||||
<if test="stationIdList != null and stationIdList.size() != 0">
|
</if>
|
||||||
AND t1.station_id IN
|
<if test="startTime != null and startTime != ''">
|
||||||
<foreach collection="stationIdList" item="stationId" open="(" separator="," close=")">
|
AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
|
||||||
#{stationId}
|
</if>
|
||||||
</foreach>
|
<if test="endTime != null and endTime != ''">
|
||||||
</if>
|
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
||||||
<if test="startMode != null and startMode != ''">
|
</if>
|
||||||
AND t1.start_mode = #{startMode,jdbcType=VARCHAR}
|
<if test="merchantId != null and merchantId != ''">
|
||||||
</if>
|
AND t1.merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||||
<if test="stationName != null and stationName != ''">
|
</if>
|
||||||
AND t3.station_name LIKE CONCAT('%', #{stationName,jdbcType=VARCHAR}, '%')
|
<if test="stationId != null and stationId != ''">
|
||||||
</if>
|
AND t1.station_id = #{stationId,jdbcType=VARCHAR}
|
||||||
<if test="stationDeptIds != null and stationDeptIds.size() != 0">
|
</if>
|
||||||
AND t3.dept_id IN
|
<if test="stationName != null and stationName != ''">
|
||||||
<foreach collection="stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
|
AND t3.station_name LIKE CONCAT('%', #{stationName,jdbcType=VARCHAR}, '%')
|
||||||
#{stationDeptId}
|
</if>
|
||||||
</foreach>
|
<if test="stationDeptIds != null and stationDeptIds.size() != 0">
|
||||||
</if>
|
AND t3.dept_id IN
|
||||||
<if test="excludeStationIdList != null and excludeStationIdList.size() != 0">
|
<foreach collection="stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
|
||||||
AND t1.station_id NOT IN
|
#{stationDeptId}
|
||||||
<foreach collection="excludeStationIdList" item="excludeStationId" open="(" separator="," close=")">
|
</foreach>
|
||||||
#{excludeStationId}
|
</if>
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
) AS temp
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectOrderBasicInfoById" parameterType="Long" resultMap="OrderBasicInfoOrderDetailResult">
|
<select id="selectOrderBasicInfoById" parameterType="Long" resultMap="OrderBasicInfoOrderDetailResult">
|
||||||
|
|||||||
Reference in New Issue
Block a user