XH-Power-Cloud/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml
2021-12-27 15:45:06 +08:00

178 lines
8.5 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.xhpc.order.mapper.XhpcHistoryOrderReconciliationStatusMapper">
<resultMap type="com.xhpc.order.domain.XhpcHistoryOrderReconciliationStatus"
id="XhpcHistoryOrderReconciliationStatusResult">
<result column="history_order_reconciliation_status_id" property="historyOrderReconciliationStatusId"/>
<result column="history_order_id" property="historyOrderId"/>
<result column="status" property="status"/>
<result column="del_flag" property="delFlag"/>
<result column="create_time" property="createTime"/>
<result column="create_by" property="createBy"/>
<result column="update_time" property="updateTime"/>
<result column="update_by" property="updateBy"/>
<result column="remark" property="remark"/>
</resultMap>
<insert id="insert" parameterType="com.xhpc.order.domain.XhpcHistoryOrderReconciliationStatus"
useGeneratedKeys="true" keyProperty="historyOrderReconciliationStatusId">
INSERT INTO xhpc_history_order_reconciliation_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != historyOrderId and '' != historyOrderId">
history_order_id,
</if>
<if test="null != status and '' != status">
status,
</if>
<if test="null != delFlag and '' != delFlag">
del_flag,
</if>
<if test="null != createTime">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != historyOrderId and '' != historyOrderId">
#{historyOrderId},
</if>
<if test="null != status and '' != status">
#{status},
</if>
<if test="null != delFlag and '' != delFlag">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark}
</if>
</trim>
</insert>
<select id="internetUser" parameterType="java.lang.Long" resultType="java.util.Map">
select xiu.internet_user_id internetUserId,xiu.`name`,xiu.open_bank openbank,xiu.card_number
cardNumber,a.waitConfirmed,b.confirmed
from
sys_user su
LEFT JOIN (select sum(xho.act_price-xho.internet_commission-xho.internet_svc_commission)
waitConfirmed,xho.user_id
from xhpc_history_order xho
LEFT JOIN xhpc_charge_order xco on xco.charge_order_id = xho.charge_order_id
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id = xho.charging_station_id
LEFT JOIN xhpc_operator xo on xo.operator_id = xcs.operator_id
<if test="chargingStation != null and chargingStation != ''">
LEFT JOIN xhpc_user_privilege xup on xup.charging_station_id = xcs.charging_station_id
</if>
where xho.del_flag = 0 and xho.reconciliation_status = 0
<if test="operatorId != null and operatorId != ''">
and xo.operator_id = #{operatorId }
</if>
<if test="chargingStation != null and chargingStation != ''">
and xho.user_id = #{userId}
</if>
GROUP BY xho.user_id) a on su.user_id = a.user_id
LEFT JOIN
(select sum(xho.total_price-xho.promotion_discount-xho.internet_commission-xho.internet_svc_commission) confirmed ,xho.user_id
from xhpc_history_order xho
LEFT JOIN xhpc_charge_order xco on xco.charge_order_id = xho.charge_order_id
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id = xho.charging_station_id
LEFT JOIN xhpc_operator xo on xo.operator_id = xcs.operator_id
<if test="chargingStation != null and chargingStation !=''">
LEFT JOIN xhpc_user_privilege xup on xup.charging_station_id = xcs.charging_station_id
</if>
where xho.del_flag = 0 and xho.reconciliation_status = 1
<if test="operatorId != null and operatorId !=''">
and xo.operator_id = #{operatorId}
</if>
<if test="chargingStation != null and chargingStation !=''">
and xcs.user_id = #{userId}
</if>
GROUP BY xho.user_id) b on a.user_id = su.user_id
LEFT JOIN xhpc_internet_user xiu on xiu.internet_user_id = su.internet_user_id
where su.user_id = #{userId} limit 1
</select>
<select id="page" parameterType="java.lang.Long" resultType="java.util.Map">
select xho.act_price-xho.internet_commission-xho.internet_svc_commission
realIncome,xho.history_order_id historyOrderId,
xho.user_id userId,xho.serial_number serialNumber,xho.create_time createTime,
xo.`name` operatorName,xcs.`name` chargingStationName,xho.`reconciliation_status`
reconciliationStatus,sdd.dict_label reconciliationStatusName
from xhpc_history_order xho
LEFT JOIN xhpc_charge_order xco on xco.charge_order_id = xho.charge_order_id
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id = xho.charging_station_id
LEFT JOIN xhpc_operator xo on xo.operator_id = xcs.operator_id
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'reconciliation_status' and sdd.dict_value =
xho.`reconciliation_status`
<if test="chargingStation != null and chargingStation !=''">
LEFT JOIN xhpc_user_privilege xup on xup.charging_station_id = xcs.charging_station_id
</if>
where xho.del_flag = 0
<if test="userId != null and userId != ''">
and xho.user_id = #{userId}
</if>
<if test="serialNumber != null and serialNumber != ''">
and xho.serial_number like concat('%', #{serialNumber}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''"><!-- 开始时间检索 -->
AND xco.create_time &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''"><!-- 结束时间检索 -->
AND xco.create_time &lt;= #{createTimeEnd}
</if>
<if test="chargingStationName != null and chargingStationName != ''">
and xcs.`name`like concat('%', #{chargingStationName}, '%')
</if>
<if test="status != null and status != ''">
and xho.reconciliation_status = #{status}
</if>
<if test="operatorId != null and operatorId !=''">
and xo.operator_id = #{operatorId }
</if>
<if test="chargingStation != null and chargingStation !=''">
and xup.user_id = #{userId}
</if>
ORDER BY xho.create_time DESC
</select>
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select sum(xho.act_price-xho.internet_commission-xho.internet_svc_commission)
realIncome,xho.history_order_id historyOrderId,
xho.user_id userId,xho.serial_number serialNumber,xho.create_time createTime,
xo.`name` operatorName,xcs.`name` chargingStationName,xho.`reconciliation_status`
reconciliationStatus,sdd.dict_label reconciliationStatusName,
xho.end_soc endSoc
from xhpc_history_order xho
LEFT JOIN xhpc_charge_order xco on xco.charge_order_id = xho.charge_order_id
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id = xho.charging_station_id
LEFT JOIN xhpc_operator xo on xo.operator_id = xcs.operator_id
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'reconciliation_status' and sdd.dict_value =
xho.`reconciliation_status`
where xho.del_flag = 0 and xho.history_order_id = #{historyOrderId}
</select>
</mapper>