2021-08-04 11:22:15 +08:00
<?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.HxpcChargeOrderMapper" >
<resultMap type= "com.xhpc.order.domain.HxpcChargeOrder" id= "HxpcChargeOrderResult" >
<result column= "charge_order_id" property= "chargeOrderId" />
<result column= "charging_station_id" property= "chargingStationId" />
<result column= "user_id" property= "userId" />
<result column= "terminal_id" property= "terminalId" />
<result column= "internet_serial_number" property= "internetSerialNumber" />
<result column= "serial_number" property= "serialNumber" />
<result column= "start_soc" property= "startSoc" />
2021-08-09 12:15:00 +08:00
<result column= "end_soc" property= "endSoc" />
2021-08-04 11:22:15 +08:00
<result column= "source" property= "source" />
<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" />
<result column= "rate_model_id" property= "rateModelId" />
2021-08-09 12:15:00 +08:00
<result column= "charging_mode" property= "chargingMode" />
<result column= "start_time" property= "startTime" />
<result column= "end_time" property= "endTime" />
<result column= "charging_time" property= "chargingTime" />
<result column= "charging_degree" property= "chargingDegree" />
<result column= "type" property= "type" />
2021-08-04 11:22:15 +08:00
</resultMap>
2021-08-05 16:17:04 +08:00
<resultMap id= "BaseResultMap" type= "com.xhpc.common.domain.XhpcTerminal" >
<result property= "terminalId" column= "terminal_id" />
<result property= "chargingPileId" column= "charging_pile_id" />
<result property= "chargingStationId" column= "charging_station_id" />
<result property= "name" column= "name" />
<result property= "serialNumber" column= "serial_number" />
<result property= "pileSerialNumber" column= "pile_serial_number" />
<result property= "gunStatus" column= "gun_status" />
<result property= "workStatus" column= "work_status" />
<result property= "status" column= "status" />
<result property= "delFlag" column= "del_flag" />
2021-08-05 20:30:16 +08:00
<result property= "createTime" column= "create_time" />
<result property= "createBy" column= "create_by" />
<result property= "updateTime" column= "update_time" />
<result property= "updateBy" column= "update_by" />
<result property= "remark" column= "remark" />
<result property= "rateModelId" column= "rate_model_id" />
2021-08-05 16:17:04 +08:00
</resultMap>
2021-08-05 20:30:16 +08:00
2021-08-11 16:25:10 +08:00
<select id= "getHistotyChargeOrderMessage" resultType= "int" >
select
count(charge_order_id)
from xhpc_charge_order
where user_id = #{userId} and status=0 and del_flag =0
2021-08-04 11:22:15 +08:00
</select>
2021-08-05 16:17:04 +08:00
2021-08-12 15:54:28 +08:00
<select id= "getMessage" resultType= "map" >
select
rto.real_time_order_id as realTimeOrderId,
rto.charging_order_id as chargingOrderId,
rto.voltage as voltage,
rto.gun_number as seriaNumber,
rto.electric_current as electricCurrent,
(select power from xhpc_charging_pile where charging_pile_id=
(select charging_pile_id from xhpc_terminal where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power,
rto.soc as soc,
rto.gun_number as gunNumber,
rto.charging_degree as chargingDegree,
rto.charging_time as chargingTime,
rto.remaining_time as remainingTime,
rto.amount_charged as amountCharged,
au.balance as balance
from xhpc_real_time_order as rto
LEFT JOIN xhpc_app_user as au on au.app_user_id = rto.user_id
where rto.charging_order_id =(select charge_order_id from xhpc_charge_order where status =0 and source = 0 ORDER BY create_time desc LIMIT 1)
and rto.user_id=#{userId}
</select>
2021-08-11 16:25:10 +08:00
2021-08-05 16:17:04 +08:00
<select id= "getUserMessage" resultType= "map" >
select
app_user_id as appUserId,
balance as balance,
is_refund_application as isRefundApplication
from xhpc_app_user
2021-08-13 19:12:07 +08:00
where del_flag=0 and app_user_id=#{userId}
2021-08-05 16:17:04 +08:00
</select>
<select id= "countXhpcRealTimeOrder" resultType= "int" >
2021-08-12 15:54:28 +08:00
select count(charge_order_id) from xhpc_charge_order where user_id =#{userId} and status=0 and del_flag =0
2021-08-05 16:17:04 +08:00
</select>
<select id= "countXhpcChargeOrder" resultType= "int" >
select count(charge_order_id) from xhpc_charge_order where user_id =#{userId} and status =2 and del_flag =0
</select>
<select id= "getXhpcTerminalSerialNumber" resultMap= "BaseResultMap" >
2021-08-12 15:54:28 +08:00
select * from xhpc_terminal where serial_number=#{serialNumber} and del_flag=0 limit 1
2021-08-05 16:17:04 +08:00
</select>
2021-08-12 15:54:28 +08:00
<insert id= "addXhpcChargeOrder" parameterType= "com.xhpc.order.domain.HxpcChargeOrder" useGeneratedKeys= "true"
2021-08-05 20:30:16 +08:00
keyProperty="chargeOrderId">
insert into xhpc_charge_order
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingStationId " >
charging_station_id,
</if>
<if test= "null != userId " >
user_id,
</if>
<if test= "null != terminalId " >
terminal_id,
</if>
<if test= "null != internetSerialNumber " >
internet_serial_number,
</if>
<if test= "null != serialNumber " >
serial_number,
</if>
<if test= "null != startSoc " >
start_soc,
</if>
<if test= "null != source " >
source,
</if>
<if test= "null != status " >
status,
</if>
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != rateModelId " >
2021-08-09 12:15:00 +08:00
rate_model_id,
</if>
<if test= "null != chargingMode " >
charging_mode,
</if>
<if test= "null != startTime " >
start_time,
</if>
<if test= "null != endTime " >
end_time,
</if>
<if test= "null != chargingTime " >
charging_time,
</if>
<if test= "null != chargingDegree " >
charging_degree
2021-08-05 20:30:16 +08:00
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingStationId " >
#{chargingStationId},
</if>
<if test= "null != userId " >
#{userId},
</if>
<if test= "null != terminalId " >
#{terminalId},
</if>
<if test= "null != internetSerialNumber " >
#{internetSerialNumber},
</if>
<if test= "null != serialNumber " >
#{serialNumber},
</if>
<if test= "null != startSoc " >
#{startSoc},
</if>
<if test= "null != source " >
#{source},
</if>
<if test= "null != status " >
#{status},
</if>
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != rateModelId " >
2021-08-09 12:15:00 +08:00
#{rateModelId},
</if>
<if test= "null != chargingMode " >
#{chargingMode},
</if>
<if test= "null != startTime " >
#{startTime},
</if>
<if test= "null != endTime " >
#{endTime},
</if>
<if test= "null != chargingTime " >
#{chargingTime},
</if>
<if test= "null != chargingDegree " >
#{chargingDegree}
2021-08-05 20:30:16 +08:00
</if>
</trim>
</insert>
2021-08-12 15:54:28 +08:00
<update id= "updateXhpcChargeOrder" parameterType= "com.xhpc.order.domain.HxpcChargeOrder" >
2021-08-09 12:15:00 +08:00
update xhpc_charge_order
<trim prefix= "SET" suffixOverrides= "," >
2021-08-12 15:54:28 +08:00
<if test= "endSoc != null" > end_soc = #{endSoc},</if>
2021-08-09 12:15:00 +08:00
<if test= "status != null" > status = #{status},</if>
2021-08-12 15:54:28 +08:00
<if test= "remark != null" > remark = #{remark},</if>
2021-08-09 12:15:00 +08:00
<if test= "endTime != null" > end_time = #{endTime},</if>
<if test= "chargingTime != null" > charging_time = #{chargingTime},</if>
<if test= "chargingDegree != null" > charging_degree = #{chargingDegree},</if>
<if test= "type != null" > type = #{type},</if>
</trim>
where charge_order_id = #{chargingStationId}
</update>
2021-08-05 16:17:04 +08:00
<select id= "getHistotyChargeOrderStatusList" resultType= "map" >
2021-08-09 21:18:02 +08:00
select
cor.charge_order_id as chargeOrderId,
cor.create_time as createTime,
cor.serial_number as serialNumber,
cs.name as chargingStationName,
ter.name as terminalName,
ho.history_order_id as historyOrderId,
ho.act_price as actPrice,
cor.charging_time as chargingTime,
cor.charging_degree as chargingDegree,
cor.status as status
from xhpc_charge_order as cor
left join xhpc_charging_station as cs on cs.charging_station_id = cor.charging_station_id
left join xhpc_terminal as ter on ter.terminal_id=cor.terminal_id
left join xhpc_history_order as ho on ho.charge_order_id = cor.charge_order_id
where cor.status =2 and cor.del_flag =0 and cor.user_id=#{userId}
order by cor.update_time desc
2021-08-05 16:17:04 +08:00
</select>
2021-08-12 15:54:28 +08:00
<select id= "getSerialNumberMessage" resultMap= "HxpcChargeOrderResult" >
select * from xhpc_charge_order where serial_number=#{serialNumber} limit 1
</select>
<select id= "getCount" resultType= "int" >
select count(charge_order_id) from xhpc_charge_order where user_id=#{userId} and del_flag =1
</select>
<select id= "getPromotion" resultType= "map" >
select discount,state from xhpc_promotion where del_flag=0 and status=0 and type=0 and start_time < = now() and end_time > =now() order by update_time desc
</select>
2021-08-04 11:22:15 +08:00
</mapper>