XH-Power-Cloud/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml

136 lines
6.6 KiB
XML
Raw Normal View History

<?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="XhpcHistoryOrderReconciliationStatusId">
INSERT INTO xhpc_recharge_order
<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>
<update id="update" parameterType="com.xhpc.order.domain.XhpcHistoryOrderReconciliationStatus">
UPDATE xhpc_history_order_reconciliation_status
<set>
<if test="null != historyOrderId and '' != historyOrderId">history_order_id = #{historyOrderId},</if>
<if test="null != status and '' != status">status = #{status},</if>
<if test="null != delFlag and '' != delFlag">del_flag = #{delFlag},</if>
<if test="null != createTime and '' != createTime">create_time = #{createTime},</if>
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
<if test="null != updateTime and '' != updateTime">update_time = #{updateTime},</if>
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
<if test="null != remark and '' != remark">remark = #{remark}</if>
</set>
WHERE history_order_reconciliation_status_id = #{historyOrderReconciliationStatusId}
</update>
<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
(select sum(xho.total_price-xho.promotion_discount-xho.internet_commission-xho.internet_svc_commission) waitConfirmed,xho.user_id
from xhpc_history_order xho
where xho.del_flag = 0 and xho.reconciliation_status = 0 GROUP BY user_id) a
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
where xho.del_flag = 0 and xho.reconciliation_status = 1 GROUP BY user_id) b on a.user_id = b.user_id
LEFT JOIN xhpc_internet_user xiu on xiu.internet_user_id = b.user_id
where a.user_id = #{internetUserId}
</select>
<select id="page" parameterType="java.lang.Long" resultType="java.util.Map">
select sum(xho.total_price-xho.promotion_discount-xho.internet_commission-xho.internet_svc_commission)
realIncome,
xho.user_id userId,xho.serial_number serialNumber,xco.create_time createTime,
xo.`name` operatorName,xcs.`name` chargingStationName,xho.`status`,xdb.dict_value reconciliationStatusName
from xhpc_history_order xho
LEFT JOIN xhpc_charge_order xco on xco.charge_order_id = xho.charging_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 xhpc_dict_biz xdb on xdb.`code` = 'reconciliation_status' and xdb.dict_key = xho.`status`
where xho.del_flag = 0
<if test="internetUserId != null and internetUserId != ''">
and xho.user_id = #{internetUserId}
</if>
<if test="serialNumber != null and serialNumber != ''">
and xho.serial_number like concat(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(concat('%', #{chargingStationName}), '%')
</if>
<if test="status != null and status != ''">
and xho.status = #{status}
</if>
</select>
</mapper>