cloud-battery-manage/cloud-manage-server/src/main/resources/mapper/OrderMapper.xml
2026-02-14 11:19:21 +08:00

221 lines
9.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.evotech.hd.common.core.dao.cloud.OrderDao">
<!-- 通用查询映射结果 -->
<resultMap id="homeProportionResultMap" type="com.evotech.hd.common.core.Dto.home.HomeOrderSwapBatteryProportionDto">
<result column="name" property="stationName" />
<result column="code" property="stationCode" />
<result column="quantity" property="quantity" />
<result column="totalAmount" property="totalAmount" />
</resultMap>
<resultMap id="homeAmountResultMap" type="com.evotech.hd.common.core.Dto.home.HomeOrderSwapBatteryAmountDto">
<result column="amount" property="amount" />
<result column="dataCount" property="dataCount" />
<result column="status" property="status" />
</resultMap>
<resultMap id="homeHalfYearResultMap" type="com.evotech.hd.common.core.Dto.home.HomeOrderSwapBatteryHalfYearDto">
<result column="y_m" property="month" />
<result column="quantity" property="quantity" />
<result column="totalMoney" property="totalMoney" />
</resultMap>
<resultMap id="homeHalfYearAmountResultMap" type="com.evotech.hd.common.core.Dto.home.HomeOrderSwapBatteryHalfYearAmountDto">
<result column="y_m" property="month" />
<result column="quantity" property="quantity" />
<result column="totalMoney" property="totalMoney" />
<result column="status" property="status" />
<result column="payType" property="payType" />
</resultMap>
<resultMap id="findOrderListByStatusMap" type="com.evotech.hd.common.core.Dto.home.HomeOrderInfo">
<result column="order_time" property="swapTime" />
<result column="plate_num" property="swapCar" />
<result column="order_pre_uname" property="swapUserName" />
<result column="order_amount" property="swapAmount" />
</resultMap>
<select id="findOrderListByStatus" resultMap="findOrderListByStatusMap">
select order_time,
plate_num,
order_pre_uname,
order_amount
from hd_cloud_manage.yt_t_order osb
where del_Flag = 0
<if test="status!= null">
and status =#{status}
</if>
order by order_time desc
</select>
<select id="homeFindProportionData" resultMap="homeProportionResultMap">
select ifnull(count(osb.pk_id),0) as quantity,
bs.code,
bs.name
from hd_cloud_manage.yt_t_battery_station bs
left join hd_cloud_manage.yt_t_order osb on bs.code = osb.station_code
where DATE_FORMAT(osb.order_time,"%Y-%m-%d") >= DATE_FORMAT(#{params.begin},"%Y-%m-%d")
and DATE_FORMAT(#{params.end},"%Y-%m-%d") >= DATE_FORMAT(osb.order_time,"%Y-%m-%d")
GROUP by bs.code,bs.name
</select>
<select id="homeFindAmountData" resultMap="homeAmountResultMap">
-- select osb.amount,
-- osb.status
select ifnull(sum(osb.order_amount),0) amount,ifnull(count(osb.pk_id),0) as dataCount,
osb.status
from hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m-%d") >= DATE_FORMAT(#{params.begin},"%Y-%m-%d")
and DATE_FORMAT(#{params.end},"%Y-%m-%d") >= DATE_FORMAT(osb.order_time,"%Y-%m-%d")
and osb.order_amount is not null
GROUP by osb.status
</select>
<select id="homeFindHalfYearOrderData" resultMap="homeHalfYearResultMap">
select
DATE_FORMAT(osb.order_time,"%Y-%m") as y_m,
count(osb.pk_id) as quantity,
sum(osb.order_amount) as totalMoney
from hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m-%d") >= DATE_FORMAT(#{params.begin},"%Y-%m-%d")
and DATE_FORMAT(#{params.end},"%Y-%m-%d") >= DATE_FORMAT(osb.order_time,"%Y-%m-%d")
and osb.order_amount is not null
and osb.status=7
GROUP by y_m
</select>
<select id="homeFindHalfYearAmountData" resultMap="homeHalfYearAmountResultMap">
select
DATE_FORMAT(osb.order_time,"%Y-%m") as y_m,
ifnull(count(osb.pk_id), 0) as quantity,
sum(ifnull(osb.order_amount,0)) as totalMoney
from
hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m") >= DATE_FORMAT(#{params.begin},"%Y-%m")
and DATE_FORMAT(#{params.end},"%Y-%m") >= DATE_FORMAT(osb.order_time,"%Y-%m")
and osb.order_amount is not null
and osb.status = 7
GROUP by y_m
</select>
<select id="homeFindHalfYearStationAmountData" resultMap="homeHalfYearAmountResultMap">
select
DATE_FORMAT(osb.order_time,"%Y-%m") as y_m,
ifnull(count(osb.pk_id), 0) as quantity
from
hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m") >= DATE_FORMAT(#{params.begin},"%Y-%m")
and DATE_FORMAT(#{params.end},"%Y-%m") >= DATE_FORMAT(osb.order_time,"%Y-%m")
and osb.order_amount is not null
and osb.status = 7
GROUP by y_m
</select>
<!--<select id="homeFindHalfYearAmountData" resultMap="homeHalfYearAmountResultMap">
select
DATE_FORMAT(osb.order_time,"%Y-%m") as y_m,
ifnull(count(osb.pk_id), 0) as quantity,
sum(ifnull(osb.amount,0)) as totalMoney,
osb.status as status,
td.pay_type as payType
from
hd_cloud_manage.yt_t_order_swap_battery osb
left join
hd_cloud_manage.yt_t_trade_detail td on td.order_no=osb.order_no
where DATE_FORMAT(osb.order_time,"%Y-%m-%d") >= DATE_FORMAT(#{params.begin},"%Y-%m-%d")
and DATE_FORMAT(#{params.end},"%Y-%m-%d") >= DATE_FORMAT(osb.order_time,"%Y-%m-%d")
and osb.amount is not null
and td.pay_type IS not null
and osb.status in (-1,7)
GROUP by y_m,osb.status,td.pay_type
</select>-->
<select id="homeFindOrderCountData" resultType="java.lang.Long" >
select count(osb.pk_id)
from hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m") = DATE_FORMAT(#{date},"%Y-%m")
and osb.order_amount is not null
and osb.status=7
</select>
<select id="homeFindOrderAmountData" resultType="java.lang.Double" >
select sum(osb.order_amount)
from hd_cloud_manage.yt_t_order osb
where DATE_FORMAT(osb.order_time,"%Y-%m") = DATE_FORMAT(#{date},"%Y-%m")
and osb.order_amount is not null
and osb.status=7
</select>
<select id="findBillList">
select osb.pk_id, osb.order_amount, osb.plate_num, osb.order_time, osb.station_name, osb.order_pre_uname, osb.status
from hd_cloud_manage.yt_t_order osb
<if test="companyCode!= null and companyCode!= ''">
left join hd_cloud_manage.yt_t_vehicle_info wi on wi.plate_num = osb.plate_num
</if>
where osb.del_flag = 0 and osb.order_amount is not null and osb.order_amount > 0 and osb.status=6
<if test="companyCode!= null and companyCode!= ''">
and wi.owner_id=#{companyCode}
</if>
<if test="orderTimeEnd!= null and orderTimeEnd!= '' ">
and DATE_FORMAT(#{orderTimeEnd},"%Y-%m-%d") >= DATE_FORMAT(osb.order_time,"%Y-%m-%d")
</if>
</select>
<select id="findExportList" parameterType="com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest" resultType="com.evotech.hd.common.core.Dto.order.OrderExportVo">
select osbp.source as orderSource, o.order_no, o.station_name, o.status as orderType, o.plate_num,
od.return_bat_code,
od.return_bat_soc,
od.rent_bat_code,
od.rent_bat_soc,
od.service_time_begin,
od.service_time_end
from hd_cloud_manage.yt_t_order o
left join hd_cloud_manage.yt_t_order_detail od on od.order_id = o.pk_id
left join hd_cloud_manage.yt_t_order_swap_battery_pre osbp on osbp.pk_id = o.order_pre_id
<if test="proCode!= null and proCode!= ''">
left join hd_cloud_manage.yt_t_battery_station bs on bs.code = o.station_code
</if>
where o.del_flag != 1
<if test="orderNo!= null and orderNo!= ''">
and o.order_no=#{orderNo}
</if>
<if test="plateNum!= null and plateNum!= ''">
and o.plate_num=#{plateNum}
</if>
<if test="orderTimeBegin!= null ">
and o.order_time <![CDATA[ >= ]]> #{orderTimeBegin}
</if>
<if test="orderTimeEnd!= null">
and o.order_time <![CDATA[ <= ]]> #{orderTimeEnd}
</if>
<if test="stationCode!= null and stationCode!= ''">
and o.station_code = #{stationCode}
</if>
<if test="tradeNo!= null and tradeNo!= ''">
and o.trade_no=#{tradeNo}
</if>
<if test="status!= null and status!= ''">
and o.status=#{status}
</if>
<if test="userId!= null and userId!= ''">
and o.user_id=#{userId}
</if>
<if test="proCode!= null and proCode!= ''">
and bs.proxy_id = #{proCode}
</if>
order by order_time desc
</select>
</mapper>