2021-07-24 18:07:51 +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.XhpcHistoryOrderMapper" >
<resultMap type= "com.xhpc.order.domain.XhpcHistoryOrder" id= "XhpcHistoryOrderResult" >
<result column= "history_order_id" property= "historyOrderId" />
<result column= "charging_station_id" property= "chargingStationId" />
<result column= "charging_order_id" property= "chargingOrderId" />
<result column= "user_id" property= "userId" />
<result column= "terminal_id" property= "terminalId" />
<result column= "serial_number" property= "serialNumber" />
<result column= "internet_serial_number" property= "internetSerialNumber" />
<result column= "total_price" property= "totalPrice" />
<result column= "promotion_discount" property= "promotionDiscount" />
<result column= "act_price" property= "actPrice" />
<result column= "act_power_price" property= "actPowerPrice" />
<result column= "act_service_price" property= "actServicePrice" />
<result column= "internet_commission" property= "internetCommission" />
<result column= "internet_svc_commission" property= "internetSvcCommission" />
<result column= "platform_commission" property= "platformCommission" />
<result column= "platform_svc_commisssion" property= "platformSvcCommisssion" />
<result column= "operation_commission" property= "operationCommission" />
<result column= "start_soc" property= "startSoc" />
<result column= "end_soc" property= "endSoc" />
<result column= "reconciliation_status" property= "reconciliationStatus" />
<result column= "sorting_status" property= "sortingStatus" />
<result column= "type" property= "type" />
<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.XhpcHistoryOrder" useGeneratedKeys= "true"
2021-07-27 18:38:32 +08:00
keyProperty="historyOrderId">
2021-07-24 18:07:51 +08:00
INSERT INTO xhpc_history_order
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingStationId and '' != chargingStationId" >
charging_station_id,
</if>
<if test= "null != chargingOrderId and '' != chargingOrderId" >
charging_order_id,
</if>
<if test= "null != userId and '' != userId" >
user_id,
</if>
<if test= "null != terminalId and '' != terminalId" >
terminal_id,
</if>
<if test= "null != serialNumber and '' != serialNumber" >
serial_number,
</if>
<if test= "null != internetSerialNumber and '' != internetSerialNumber" >
internet_serial_number,
</if>
<if test= "null != totalPrice and '' != totalPrice" >
total_price,
</if>
<if test= "null != promotionDiscount and '' != promotionDiscount" >
promotion_discount,
</if>
<if test= "null != actPrice and '' != actPrice" >
act_price,
</if>
<if test= "null != actPowerPrice and '' != actPowerPrice" >
act_power_price,
</if>
<if test= "null != actServicePrice and '' != actServicePrice" >
act_service_price,
</if>
<if test= "null != internetCommission and '' != internetCommission" >
internet_commission,
</if>
<if test= "null != internetSvcCommission and '' != internetSvcCommission" >
internet_svc_commission,
</if>
<if test= "null != platformCommission and '' != platformCommission" >
platform_commission,
</if>
<if test= "null != platformSvcCommisssion and '' != platformSvcCommisssion" >
platform_svc_commisssion,
</if>
<if test= "null != operationCommission and '' != operationCommission" >
operation_commission,
</if>
<if test= "null != operationSvcCommission and '' != operationSvcCommission" >
operation_svc_commission,
</if>
<if test= "null != startSoc and '' != startSoc" >
start_soc,
</if>
<if test= "null != endSoc and '' != endSoc" >
end_soc,
</if>
<if test= "null != reconciliationStatus and '' != reconciliationStatus" >
reconciliation_status,
</if>
<if test= "null != sortingStatus and '' != sortingStatus" >
sorting_status,
</if>
<if test= "null != type and '' != type" >
type,
</if>
<if test= "null != status and '' != status" >
status,
</if>
<if test= "null != delFlag and '' != delFlag" >
del_flag,
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime " >
2021-07-24 18:07:51 +08:00
create_time,
</if>
<if test= "null != createBy and '' != createBy" >
create_by,
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" >
2021-07-24 18:07:51 +08:00
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 != chargingStationId and '' != chargingStationId" >
#{chargingStationId},
</if>
<if test= "null != chargingOrderId and '' != chargingOrderId" >
#{chargingOrderId},
</if>
<if test= "null != userId and '' != userId" >
#{userId},
</if>
<if test= "null != terminalId and '' != terminalId" >
#{terminalId},
</if>
<if test= "null != serialNumber and '' != serialNumber" >
#{serialNumber},
</if>
<if test= "null != internetSerialNumber and '' != internetSerialNumber" >
#{internetSerialNumber},
</if>
<if test= "null != totalPrice and '' != totalPrice" >
#{totalPrice},
</if>
<if test= "null != promotionDiscount and '' != promotionDiscount" >
#{promotionDiscount},
</if>
<if test= "null != actPrice and '' != actPrice" >
#{actPrice},
</if>
<if test= "null != actPowerPrice and '' != actPowerPrice" >
#{actPowerPrice},
</if>
<if test= "null != actServicePrice and '' != actServicePrice" >
#{actServicePrice},
</if>
<if test= "null != internetCommission and '' != internetCommission" >
#{internetCommission},
</if>
<if test= "null != internetSvcCommission and '' != internetSvcCommission" >
#{internetSvcCommission},
</if>
<if test= "null != platformCommission and '' != platformCommission" >
#{platformCommission},
</if>
<if test= "null != platformSvcCommisssion and '' != platformSvcCommisssion" >
#{platformSvcCommisssion},
</if>
<if test= "null != operationCommission and '' != operationCommission" >
#{operationCommission},
</if>
<if test= "null != operationSvcCommission and '' != operationSvcCommission" >
#{operationSvcCommission},
</if>
<if test= "null != startSoc and '' != startSoc" >
#{startSoc},
</if>
<if test= "null != endSoc and '' != endSoc" >
#{endSoc},
</if>
<if test= "null != reconciliationStatus and '' != reconciliationStatus" >
#{reconciliationStatus},
</if>
<if test= "null != sortingStatus and '' != sortingStatus" >
#{sortingStatus},
</if>
<if test= "null != type and '' != type" >
#{type},
</if>
<if test= "null != status and '' != status" >
#{status},
</if>
<if test= "null != delFlag and '' != delFlag" >
#{delFlag},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime " >
2021-07-24 18:07:51 +08:00
#{createTime},
</if>
<if test= "null != createBy and '' != createBy" >
#{createBy},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" >
2021-07-24 18:07:51 +08:00
#{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.XhpcHistoryOrder" >
UPDATE xhpc_history_order
<set >
<if test= "null != chargingStationId and '' != chargingStationId" > charging_station_id =
#{chargingStationId},
</if>
<if test= "null != chargingOrderId and '' != chargingOrderId" > charging_order_id = #{chargingOrderId},</if>
<if test= "null != userId and '' != userId" > user_id = #{userId},</if>
<if test= "null != terminalId and '' != terminalId" > terminal_id = #{terminalId},</if>
<if test= "null != serialNumber and '' != serialNumber" > serial_number = #{serialNumber},</if>
<if test= "null != internetSerialNumber and '' != internetSerialNumber" > internet_serial_number =
#{internetSerialNumber},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != totalPrice" > total_price = #{totalPrice},</if>
<if test= "null != promotionDiscount" > promotion_discount =
2021-07-24 18:07:51 +08:00
#{promotionDiscount},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != actPrice" > act_price = #{actPrice},</if>
<if test= "null != actPowerPrice" > act_power_price = #{actPowerPrice},</if>
<if test= "null != actServicePrice" > act_service_price = #{actServicePrice},</if>
<if test= "null != internetCommission " > internet_commission =
2021-07-24 18:07:51 +08:00
#{internetCommission},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != internetSvcCommission" > internet_svc_commission =
2021-07-24 18:07:51 +08:00
#{internetSvcCommission},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != platformCommission" > platform_commission =
2021-07-24 18:07:51 +08:00
#{platformCommission},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != platformSvcCommisssion" > platform_svc_commisssion =
2021-07-24 18:07:51 +08:00
#{platformSvcCommisssion},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != operationCommission " > operation_commission =
2021-07-24 18:07:51 +08:00
#{operationCommission},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != operationSvcCommission" > operation_svc_commission =
2021-07-24 18:07:51 +08:00
#{operationSvcCommission},
</if>
<if test= "null != startSoc and '' != startSoc" > start_soc = #{startSoc},</if>
<if test= "null != endSoc and '' != endSoc" > end_soc = #{endSoc},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != reconciliationStatus " > reconciliation_status =
2021-07-24 18:07:51 +08:00
#{reconciliationStatus},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != sortingStatus " > sorting_status = #{sortingStatus},</if>
<if test= "null != type" > type = #{type},</if>
<if test= "null != status" > status = #{status},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != delFlag and '' != delFlag" > del_flag = #{delFlag},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime " > create_time = #{createTime},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != createBy and '' != createBy" > create_by = #{createBy},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" > update_time = #{updateTime},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != updateBy and '' != updateBy" > update_by = #{updateBy},</if>
<if test= "null != remark and '' != remark" > remark = #{remark}</if>
</set>
WHERE history_order_id = #{historyOrderId}
</update>
<select id= "info" parameterType= "java.lang.Long" resultMap= "XhpcHistoryOrderResult" >
select *
from xhpc_history_order xho
where xho.del_flag = 0 and xho.history_order_id = #{historyOrderId}
</select>
2021-07-26 18:02:59 +08:00
2021-08-06 18:46:55 +08:00
<update id= "updateReconciliation" parameterType= "java.lang.String" >
2021-07-26 18:02:59 +08:00
update xhpc_history_order set reconciliation_status = #{status} where history_order_id in
2021-08-06 18:46:55 +08:00
<foreach collection= "xhpcHistoryOrderIds" item= "item" open= "(" separator= "," close= ")" >
#{item}
2021-07-26 18:02:59 +08:00
</foreach>
</update>
2021-08-06 18:46:55 +08:00
<update id= "updateSorting" parameterType= "java.lang.String" >
2021-07-26 18:02:59 +08:00
update xhpc_history_order set sorting_status = #{status} where history_order_id in
2021-08-06 18:46:55 +08:00
<foreach collection= "xhpcHistoryOrderIds" item= "item" open= "(" separator= "," close= ")" >
#{item}
2021-07-26 18:02:59 +08:00
</foreach>
</update>
2021-08-03 22:41:53 +08:00
<select id= "list" resultType= "map" >
SELECT
ho.history_order_id as historyOrderId,
ho.serial_number as serialNumber,
ho.create_time as createTime,
ho.type as type,
cs.name as chargingStationName,
te.name as terminalName,
ho.act_price as actPrice,
(select charging_degree from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as chargingDegree,
(select charging_time from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as chargingTime
FROM xhpc_history_order as ho
LEFT JOIN xhpc_charging_station as cs on cs.charging_station_id = ho.charging_station_id
LEFT JOIN xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.status=0 and ho.del_flag=0 and ho.user_id =#{userId}
</select>
<select id= "gethistotyOrderMessage" resultType= "map" >
SELECT
ho.history_order_id as historyOrderId,
ho.serial_number as serialNumber,
ho.type as type,
cs.name as chargingStationName,
te.name as terminalName,
ho.act_price as actPrice,
ho.act_power_price as actPowerPrice,
2021-08-05 11:18:32 +08:00
(select charging_time from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY
create_time desc LIMIT 1) as chargingTime,
2021-08-03 22:41:53 +08:00
(select charging_degree from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as chargingDegree,
(select DATE_FORMAT(create_time,'%m月%d日') from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time asc LIMIT 1) as daysOne,
(select DATE_FORMAT(create_time,'%H:%m') from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time asc LIMIT 1) as timeOne,
(select DATE_FORMAT(create_time,'%m月%d日') from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as daysTwo,
(select DATE_FORMAT(create_time,'%H:%m') from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as timeTwo,
(select type from xhpc_real_time_order where charging_order_id=ho.charging_order_id ORDER BY create_time desc LIMIT 1) as type
FROM xhpc_history_order as ho
LEFT JOIN xhpc_charging_station as cs on cs.charging_station_id = ho.charging_station_id
LEFT JOIN xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.status=0 and ho.del_flag=0 and ho.history_order_id =#{historyOrderId}
<if test= "userId !=null" >
and ho.user_id =#{userId}
</if>
</select>
2021-07-24 18:07:51 +08:00
</mapper>