This commit is contained in:
YAS\29473
2026-01-04 08:40:56 +08:00
parent 2347445e74
commit ccd2f96466
3 changed files with 76 additions and 46 deletions

View File

@@ -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">