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">
2021-08-27 16:01:16 +08:00
<mapper namespace= "com.xhpc.order.mapper.XhpcChargeOrderMapper" >
2021-08-04 11:22:15 +08:00
2021-08-27 16:01:16 +08:00
<resultMap type= "com.xhpc.order.domain.XhpcChargeOrder" id= "XhpcChargeOrderResult" >
2021-08-04 11:22:15 +08:00
<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-17 11:41:46 +08:00
<result column= "erro_remark" property= "erroRemark" />
<result column= "amount_charged" property= "amountCharged" />
2021-08-19 10:53:11 +08:00
<result column= "power" property= "power" />
2021-08-25 18:45:52 +08:00
<result column= "charging_time_number" property= "chargingTimeNumber" />
2022-01-04 18:48:54 +08:00
<result column= "tenant_id" property= "tenantId" />
2024-05-30 16:58:46 +08:00
<result column= "charging_capacity" property= "chargingCapacity" />
2024-07-01 09:31:42 +08:00
<result column= "suncha_status" property= "sunchaStatus" />
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-27 19:41:23 +08:00
<resultMap id= "XhpcRateMap" type= "com.xhpc.common.domain.XhpcRate" >
<result property= "rateId" column= "rate_id" />
<result property= "chargingStationId" column= "charging_station_id" />
<result property= "name" column= "name" />
<result property= "powerFee" column= "power_fee" />
<result property= "serviceFee" column= "service_fee" />
<result property= "status" column= "status" />
<result property= "delFlag" column= "del_flag" />
<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= "rateValue" column= "rate_value" />
</resultMap>
2024-05-30 16:58:46 +08:00
<select id= "getHistotyChargeOrderMessageMap" resultType= "map" >
2021-08-11 16:25:10 +08:00
select
2024-05-30 16:58:46 +08:00
charge_order_id as chargeOrderId,
status
2021-08-11 16:25:10 +08:00
from xhpc_charge_order
2022-01-04 18:48:54 +08:00
where user_id = #{userId}
and del_flag =0
2024-05-30 16:58:46 +08:00
and internet_serial_number=#{thirdCode}
2022-01-04 18:48:54 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
and source =#{userType}
2021-08-04 11:22:15 +08:00
</select>
2021-08-05 16:17:04 +08:00
2024-05-30 16:58:46 +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
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
2024-07-01 09:31:42 +08:00
<if test= "sunchaStatus ==1" >
and suncha_status !=0
</if>
2024-05-30 16:58:46 +08:00
and source =#{userType}
</select>
2024-07-01 09:31:42 +08:00
<select id= "getUserTypeSunchaSwitch" resultType= "int" >
<if test= "userType==0" >
select suncha_switch from xhpc_app_user where app_user_id=#{userId} and del_flag =0
</if>
<if test= "userType==2" >
select suncha_switch from xhpc_community_personnel where community_personnel_id=#{userId} and del_flag =0
</if>
<if test= "userType==3" >
select suncha_switch from xhpc_customers_personnel where customers_personnel_id=#{userId} and del_flag =0
</if>
</select>
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,
2021-09-09 11:02:28 +08:00
rto.charging_time_number as chargingTimeNumber,
2021-09-23 12:06:14 +08:00
concat(rto.pile_number,"",rto.gun_number)as serialNumber,
2021-08-12 15:54:28 +08:00
rto.electric_current as electricCurrent,
(select power from xhpc_charging_pile where charging_pile_id=
2021-09-02 20:08:21 +08:00
(select charging_pile_id from xhpc_charging_pile where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power,
2021-08-12 15:54:28 +08:00
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,
2021-09-18 10:47:28 +08:00
IFNULL(cp.type,'1') as type,
2021-08-12 15:54:28 +08:00
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
2021-09-18 10:47:28 +08:00
left join xhpc_charging_pile as cp on cp.serial_number = rto.pile_number and cp.status =0 and cp.del_flag=0
2021-09-02 20:08:21 +08:00
where rto.charging_order_id =(select charge_order_id from xhpc_charge_order where status =0 and source = 0 and user_id=#{userId} ORDER BY create_time desc LIMIT 1)
and rto.user_id=#{userId}
ORDER BY rto.create_time DESC limit 1
2021-08-12 15:54:28 +08:00
</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,
2023-08-11 10:28:54 +08:00
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
2021-08-05 16:17:04 +08:00
balance as balance,
2021-08-17 17:33:57 +08:00
phone as phone,
2021-08-26 19:35:19 +08:00
soc as soc,
2021-12-28 16:27:25 +08:00
is_refund as isRefund,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
2021-08-05 16:17:04 +08:00
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>
2021-08-25 15:27:57 +08:00
<update id= "updateUserBalance" >
update xhpc_app_user set balance=#{balance} where app_user_id=#{userId}
</update>
2024-07-01 09:31:42 +08:00
<update id= "updateUserSunchaBalance" >
update xhpc_app_user
<set >
<if test= "sunchaStatus==1" > a_balance = #{balance}</if>
<if test= "sunchaStatus==2" > b_balance = #{balance}</if>
</set>
where app_user_id=#{userId}
</update>
2022-01-27 17:20:30 +08:00
<update id= "updateCommunityBalance" >
update xhpc_community_personnel set surplus_money=#{balance} where community_personnel_id=#{userId}
</update>
2024-07-01 09:31:42 +08:00
<update id= "updateCommunitySunchaBalance" >
update xhpc_community_personnel
<set >
<if test= "sunchaStatus==1" > a_balance = #{balance}</if>
<if test= "sunchaStatus==2" > b_balance = #{balance}</if>
</set>
where community_personnel_id=#{userId}
</update>
2022-01-27 17:20:30 +08:00
<update id= "updateCustomersBalance" >
update xhpc_customers_personnel set surplus_money=#{balance} where customers_personnel_id=#{userId}
</update>
2024-03-27 09:18:09 +08:00
2024-07-01 09:31:42 +08:00
<update id= "updateCustomersSunchaBalance" >
update xhpc_customers_personnel
<set >
<if test= "sunchaStatus==1" > a_balance = #{balance}</if>
<if test= "sunchaStatus==2" > b_balance = #{balance}</if>
</set>
where customers_personnel_id=#{userId}
</update>
2024-03-27 09:18:09 +08:00
<update id= "updateAppInternetUserBalance" >
update xhpc_app_internet_user set balance=#{balance} where app_internet_user_id=#{userId}
</update>
2021-08-16 19:24:26 +08:00
<select id= "countXhpcRealTimeOrder" resultType= "String" >
2022-01-11 16:40:12 +08:00
select
charge_order_id as chargeOrderId
from xhpc_charge_order
where
user_id =#{userId} and status=0 and del_flag =0 and source =0
<if test= "source !=null and source !=''" >
and source=#{source}
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
limit 1
2021-08-05 16:17:04 +08:00
</select>
<select id= "countXhpcChargeOrder" resultType= "int" >
2022-01-11 16:40:12 +08:00
select count(charge_order_id)
from xhpc_charge_order
where user_id =#{userId}
and status =2 and source =0 and del_flag =0
<if test= "source !=null and source !=''" >
and source=#{source}
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
2021-08-05 16:17:04 +08:00
</select>
<select id= "getXhpcTerminalSerialNumber" resultMap= "BaseResultMap" >
2022-02-22 11:48:28 +08:00
select * from xhpc_terminal
where serial_number=#{serialNumber}
<if test= "tenantId !=null and ''!=tenantId" >
and tenant_id=#{tenantId}
</if>
2022-10-12 15:18:22 +08:00
and del_flag=0 limit 1
2021-08-05 16:17:04 +08:00
</select>
2021-08-27 16:01:16 +08:00
<insert id= "addXhpcChargeOrder" parameterType= "com.xhpc.order.domain.XhpcChargeOrder" 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>
2021-08-17 11:41:46 +08:00
<if test= "null != endSoc " >
end_soc,
</if>
2021-08-05 20:30:16 +08:00
<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 " >
2021-08-17 11:41:46 +08:00
charging_degree,
</if>
<if test= "null != type " >
type,
</if>
<if test= "null != erroRemark " >
erro_remark,
</if>
<if test= "null != amountCharged " >
2021-08-19 10:53:11 +08:00
amount_charged,
</if>
<if test= "null != power " >
2021-09-09 11:02:28 +08:00
power,
</if>
<if test= "null != createTime " >
2022-01-11 16:40:12 +08:00
create_time,
</if>
<if test= "null != tenantId and tenantId !=''" >
tenant_id,
2021-08-05 20:30:16 +08:00
</if>
2022-03-14 15:25:43 +08:00
<if test= "null != driverId and driverId !=''" >
driver_id,
</if>
<if test= "null != chargingAmt " >
charging_amt,
</if>
<if test= "null != PlateNum and PlateNum !=''" >
Plate_num,
</if>
<if test= "null != evcsOrderNo and evcsOrderNo !=''" >
evcs_order_no,
</if>
2022-09-19 12:06:54 +08:00
<if test= "null != vinNormal and vinNormal !=''" >
vin_normal,
</if>
2024-05-30 16:58:46 +08:00
<if test= "null != chargingCapacity" >
charging_capacity,
</if>
2024-07-01 09:31:42 +08:00
<if test= "null != sunchaStatus" >
suncha_status,
</if>
2021-08-05 20:30:16 +08:00
</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>
2021-08-17 11:41:46 +08:00
<if test= "null != endSoc " >
#{endSoc},
</if>
2021-08-05 20:30:16 +08:00
<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 " >
2021-08-17 11:41:46 +08:00
#{chargingDegree},
</if>
<if test= "null != type " >
#{type},
</if>
<if test= "null != erroRemark " >
#{erroRemark},
</if>
<if test= "null != amountCharged " >
2021-08-19 10:53:11 +08:00
#{amountCharged},
</if>
<if test= "null != power " >
2021-09-09 11:02:28 +08:00
#{power},
</if>
<if test= "null != createTime " >
2022-01-11 16:40:12 +08:00
#{createTime},
</if>
<if test= "null != tenantId and tenantId !=''" >
#{tenantId},
2021-08-05 20:30:16 +08:00
</if>
2022-03-14 15:25:43 +08:00
<if test= "null != driverId and driverId !=''" >
#{driverId},
</if>
<if test= "null != chargingAmt " >
#{chargingAmt},
</if>
<if test= "null != PlateNum and PlateNum !=''" >
#{PlateNum},
</if>
<if test= "null != evcsOrderNo and evcsOrderNo !=''" >
#{evcsOrderNo},
</if>
2022-09-19 12:06:54 +08:00
<if test= "null != vinNormal and vinNormal !=''" >
#{vinNormal},
</if>
2024-05-30 16:58:46 +08:00
<if test= "null != chargingCapacity" >
#{chargingCapacity},
</if>
2024-07-01 09:31:42 +08:00
<if test= "null != sunchaStatus" >
#{sunchaStatus},
</if>
2021-08-05 20:30:16 +08:00
</trim>
</insert>
2021-08-27 16:01:16 +08:00
<update id= "updateXhpcChargeOrder" parameterType= "com.xhpc.order.domain.XhpcChargeOrder" >
2021-08-09 12:15:00 +08:00
update xhpc_charge_order
2021-08-19 18:56:23 +08:00
<set >
2021-08-17 11:41:46 +08:00
<if test= "startSoc != null" > start_soc = #{startSoc},</if>
2021-08-12 15:54:28 +08:00
<if test= "endSoc != null" > end_soc = #{endSoc},</if>
2021-08-19 18:56:23 +08:00
<if test= "status != null" > status=#{status},</if>
2024-03-27 09:18:09 +08:00
<if test= "source != null" > source=#{source},</if>
2021-08-12 15:54:28 +08:00
<if test= "remark != null" > remark = #{remark},</if>
2021-08-23 19:59:57 +08:00
<if test= "startTime != null" > start_time = #{startTime},</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>
2021-08-19 10:53:11 +08:00
<if test= "power != null" > power = #{power},</if>
2021-08-17 11:41:46 +08:00
<if test= "erroRemark != null" > erro_remark = #{erroRemark},</if>
2021-08-25 18:45:52 +08:00
<if test= "amountCharged != null" > amount_charged = #{amountCharged},</if>
2022-03-14 15:25:43 +08:00
<if test= "rateModelId != null" > rate_model_id = #{rateModelId},</if>
<if test= "chargingTimeNumber != null" > charging_time_number = #{chargingTimeNumber},</if>
<if test= "null != driverId and driverId !=''" > driver_id =#{driverId},</if>
<if test= "null != chargingAmt " > charging_amt= #{chargingAmt},</if>
<if test= "null != PlateNum and PlateNum !=''" > Plate_num= #{PlateNum},</if>
<if test= "null != evcsOrderNo and evcsOrderNo !=''" > evcs_order_no= #{evcsOrderNo},</if>
2021-08-19 18:56:23 +08:00
</set>
where charge_order_id = #{chargeOrderId}
2021-08-09 12:15:00 +08:00
</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,
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
2022-01-04 18:48:54 +08:00
where cor.status =2
and cor.del_flag =0
and cor.user_id=#{userId}
<if test= "tenantId !=null and tenantId !=''" >
and cor.tenant_id =#{tenantId}
</if>
<if test= "userType !=null" >
and cor.source =#{userType}
</if>
2021-08-09 21:18:02 +08:00
order by cor.update_time desc
2021-08-05 16:17:04 +08:00
</select>
2021-08-27 16:01:16 +08:00
<select id= "getSerialNumberMessage" resultMap= "XhpcChargeOrderResult" >
2024-01-04 09:37:06 +08:00
select *,Plate_num as PlateNum
2021-08-27 16:01:16 +08:00
from xhpc_charge_order
where serial_number = #{serialNumber}
limit 1
2021-08-12 15:54:28 +08:00
</select>
<select id= "getCount" resultType= "int" >
2021-08-30 15:49:42 +08:00
select count(charge_order_id) from xhpc_charge_order where user_id=#{userId} and del_flag =0 and (status !=1 or status !=3)
<if test= "chargeOrderId !=null" >
and charge_order_id=#{chargeOrderId}
</if>
2022-01-04 18:48:54 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
<if test= "source !=null" >
and source=#{source}
</if>
2021-08-12 15:54:28 +08:00
</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-16 19:24:26 +08:00
2021-08-27 16:01:16 +08:00
<select id= "getChargingOrderId" resultMap= "XhpcChargeOrderResult" >
select *
from xhpc_charge_order
where charge_order_id = #{chargingOrderId}
2021-08-16 19:24:26 +08:00
</select>
2021-08-17 20:33:10 +08:00
<select id= "getOperatorMessage" resultType= "map" >
select
operator_id as operatorId,
commission_type as commissionType,
2021-09-23 12:06:14 +08:00
operator_id_evcs as operatorIdEvcs,
2023-10-16 16:47:42 +08:00
duty_paragraph as dutyParagraph,
2021-08-26 19:35:19 +08:00
soc as soc,
2021-08-17 20:33:10 +08:00
platform_commission_rate as platformCommissionRate,
2023-08-11 10:28:54 +08:00
(select name from xhpc_charging_station where charging_station_id=#{chargingStationId}) chargingStationName,
2021-08-17 20:33:10 +08:00
maintenance_commission_rate as maintenanceCommissionRate
2023-08-11 10:28:54 +08:00
from xhpc_operator
where operator_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
2021-08-17 20:33:10 +08:00
</select>
2021-08-18 14:01:42 +08:00
2023-10-23 17:52:41 +08:00
<select id= "getXhpcUserVehicleMessage" resultType= "map" >
select
vehicle_id as vehicleId,
app_user_id as appUserId,
vehicle_name as vehicleName
from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=0
2024-03-27 09:18:09 +08:00
and vin_blacklist !=1 order by type,create_time desc LIMIT 1
2023-10-23 17:52:41 +08:00
</select>
2021-08-19 15:40:17 +08:00
<select id= "getXhpcChargingPileById" resultType= "map" >
select
2022-01-25 14:28:38 +08:00
cp.charging_pile_id as chargingPileId,
cs.operator_id as operatorId,
2022-02-23 10:01:28 +08:00
opn.corp_no as corpNo,
2022-01-25 14:28:38 +08:00
cp.communication_protocol_version as communicationProtocolVersion,
cp.power as power
from xhpc_charging_pile as cp
left join xhpc_charging_station as cs on cs.charging_station_id = cp.charging_station_id
2022-02-23 10:01:28 +08:00
left join xhpc_operator as opn on opn.operator_id = cs.operator_id
2022-01-25 14:28:38 +08:00
where cp.charging_pile_id=#{chargingPileid}
2022-01-04 18:48:54 +08:00
<if test= "tenantId !=null and tenantId !=''" >
2022-01-25 14:28:38 +08:00
and cp.tenant_id=#{tenantId}
2022-01-04 18:48:54 +08:00
</if>
2021-08-19 10:53:11 +08:00
</select>
2021-08-24 13:59:16 +08:00
<insert id= "addXhpcOrderRedisRecord" parameterType= "com.xhpc.order.domain.XhpcOrderRedisRecord" useGeneratedKeys= "true"
keyProperty="orderRedisRecordId">
insert into xhpc_order_redis_record
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != chargeOrderId " >
charge_order_id,
</if>
<if test= "null != historyOrderOd " >
history_order_id,
</if>
<if test= "null != endSoc " >
end_soc,
</if>
<if test= "null != status " >
status,
</if>
<if test= "null != balance " >
balance,
</if>
<if test= "null != tel " >
tel,
</if>
<if test= "null != startSoc " >
start_soc,
</if>
<if test= "null != startResult " >
start_result,
</if>
<if test= "null != realtimeDataList " >
realtime_data_list,
</if>
<if test= "null != remainingTime " >
remaining_time,
</if>
<if test= "null != rateModelId " >
rate_model_id,
</if>
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != createBy " >
create_by,
</if>
<if test= "null != updateTime " >
update_time,
</if>
<if test= "null != updateBy " >
update_by,
</if>
<if test= "null != remark " >
2021-09-14 11:53:51 +08:00
remark,
</if>
<if test= "null != orderData " >
2021-10-08 15:41:14 +08:00
order_data
2021-08-24 13:59:16 +08:00
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != chargeOrderId " >
#{chargeOrderId},
</if>
<if test= "null != historyOrderOd " >
#{historyOrderOd},
</if>
<if test= "null != endSoc " >
#{endSoc},
</if>
<if test= "null != status " >
#{status},
</if>
<if test= "null != balance " >
#{balance},
</if>
<if test= "null != tel " >
#{tel},
</if>
<if test= "null != startSoc " >
#{startSoc},
</if>
<if test= "null != startResult " >
#{startResult},
</if>
<if test= "null != realtimeDataList " >
#{realtimeDataList},
</if>
<if test= "null != remainingTime " >
#{remainingTime},
</if>
<if test= "null != rateModelId " >
#{rateModelId},
</if>
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != createBy " >
#{createBy},
</if>
<if test= "null != updateTime " >
#{updateTime},
</if>
<if test= "null != updateBy " >
#{updateBy},
</if>
<if test= "null != remark " >
2021-09-14 11:53:51 +08:00
#{remark},
</if>
<if test= "null != orderData " >
2021-10-08 15:41:14 +08:00
#{orderData}
2021-08-24 13:59:16 +08:00
</if>
</trim>
</insert>
2021-08-25 15:27:57 +08:00
2022-01-04 18:48:54 +08:00
<insert id= "insertUserAccountStatement" >
2022-01-27 17:20:30 +08:00
INSERT INTO xhpc_user_account_statement(user_id, amount, remaining_sum, charge_order_id, type, create_time,source)
values (#{userId}, #{amount}, #{remainingSum}, #{chargeOrderId}, #{type}, #{date},#{source})
2021-08-25 15:27:57 +08:00
</insert>
2021-08-27 19:41:23 +08:00
<select id= "getRateModelId" resultMap= "XhpcRateMap" >
2021-11-29 11:22:50 +08:00
select *
from xhpc_rate
where rate_model_id = #{rateModelId}
2021-08-27 19:41:23 +08:00
</select>
2021-09-18 10:47:28 +08:00
<select id= "getXhpcChargingPile" resultType= "map" >
2021-10-22 18:09:11 +08:00
select charging_pile_id as chargingPileId,
IFNULL(type, '1') as type
from xhpc_charging_pile
2022-02-10 10:33:55 +08:00
where charging_pile_id = (select charging_pile_id from xhpc_terminal where terminal_id = #{terminalId} and del_flag =0) and del_flag =0
2021-09-18 10:47:28 +08:00
</select>
2021-10-22 14:37:29 +08:00
2022-04-25 13:30:45 +08:00
<select id= "getXhpcChargeOrderStatus" resultType= "map" >
select
xco.charge_order_id as chargeOrderId,
2024-05-30 16:58:46 +08:00
(select max(real_time_order_id) from xhpc_real_time_order where charging_order_id = xco.charge_order_id LIMIT 1) realTimeOrderId
2022-04-25 13:30:45 +08:00
from xhpc_charge_order as xco
where xco.del_flag = 0
and xco.status = #{status}
2024-05-30 16:58:46 +08:00
and NOW() > DATE_ADD(xco.create_time, INTERVAL #{number} HOUR)
2021-10-22 14:37:29 +08:00
</select>
2021-10-22 18:09:11 +08:00
2022-03-14 15:25:43 +08:00
<insert id= "addBy3rd" parameterType= "com.xhpc.order.domain.XhpcChargeOrder" useGeneratedKeys= "true"
keyProperty="chargeOrderId">
2021-10-22 18:09:11 +08:00
insert into xhpc_charge_order
2021-11-12 15:13:28 +08:00
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != internetSerialNumber " >
internet_serial_number,
</if>
<if test= "null != serialNum " >
serial_number,
</if>
<if test= "null != driverId " >
driver_id,
</if>
<if test= "null != chargingAmt " >
charging_amt,
</if>
<if test= "null != plateNum " >
plate_num,
</if>
<if test= "null != status " >
status,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != rateModelId " >
rate_model_id,
</if>
<if test= "null != terminalId " >
terminal_id,
</if>
<if test= "null != power " >
power,
</if>
<if test= "null != chargingStationId " >
charging_station_id,
</if>
<if test= "null != chargingMode " >
charging_mode,
</if>
<if test= "null != source " >
source,
</if>
<if test= "null != userId " >
user_id
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != internetSerialNumber " >
#{internetSerialNumber},
</if>
<if test= "null != serialNum " >
#{serialNum},
</if>
<if test= "null != driverId " >
#{driverId},
</if>
<if test= "null != chargingAmt " >
#{chargingAmt},
</if>
<if test= "null != plateNum " >
#{plateNum},
</if>
<if test= "null != status " >
#{status},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != rateModelId " >
#{rateModelId},
</if>
<if test= "null != terminalId " >
#{terminalId},
</if>
<if test= "null != power " >
#{power},
</if>
<if test= "null != chargingStationId " >
#{chargingStationId},
</if>
<if test= "null != chargingMode " >
#{chargingMode},
</if>
<if test= "null != source " >
#{source},
</if>
<if test= "null != userId " >
#{userId}
</if>
</trim>
2021-10-22 18:09:11 +08:00
</insert>
2021-11-12 10:52:46 +08:00
<select id= "selectDate3rdNeedBy" resultType= "map" >
select xt.charging_station_id as chargingStationId,
xt.terminal_id as terminalId,
2021-11-18 11:21:04 +08:00
cs.rate_model_id as rateModelId,
2022-03-14 15:25:43 +08:00
xcp.power as power
2021-11-12 10:52:46 +08:00
from xhpc_terminal as xt
2021-11-18 11:21:04 +08:00
left join xhpc_charging_pile as xcp on xcp.serial_number = substring(#{serialNumber}, 1, 14)
left join xhpc_charging_station as cs on xt.charging_station_id = cs.charging_station_id
2022-03-14 15:25:43 +08:00
where xt.serial_number = #{serialNumber} and xt.del_flag = 0
2021-11-12 10:52:46 +08:00
</select>
2021-11-12 15:13:28 +08:00
<select id= "select3rdNameBy" resultType= "map" >
2021-11-12 10:52:46 +08:00
2021-11-12 15:13:28 +08:00
select name, internet_user_id as userId
2021-11-12 10:52:46 +08:00
from xhpc_internet_user
where operator_id_evcs = #{operatorIdEvcs}
</select>
2021-12-01 16:27:30 +08:00
<update id= "updateStatus" >
2022-08-11 09:23:54 +08:00
update xhpc_charge_order set status=#{status}
<if test= "erroRemark !=null and erroRemark !=''" >
and erro_remark=#{erroRemark}
</if>
where status=0 and charge_order_id = #{chargeOrderId}
2021-12-01 16:27:30 +08:00
</update>
<select id= "getFourTimsStatus" resultMap= "XhpcChargeOrderResult" >
select * from xhpc_charge_order where now() >DATE_ADD(create_time,interval 4 hour) and status=0
</select>
2022-10-28 17:07:14 +08:00
<select id= "getChargeOrderStatus" resultType= "map" >
select charging_station_id chargingStationId,serial_number serialNumber from xhpc_charge_order where status =2
2022-06-06 17:48:41 +08:00
</select>
2021-12-01 16:31:41 +08:00
<select id= "getSerialNumberLike" resultType= "int" >
2021-12-08 18:00:54 +08:00
select count(charge_order_id) from xhpc_charge_order where serial_number like concat('%', #{serialNumber}, '%') and charge_order_id > #{chargeOrderId} and status=1
2021-11-18 14:30:02 +08:00
</select>
2022-09-26 16:10:38 +08:00
2024-05-30 16:58:46 +08:00
<update id= "updateStatusNull" >
update xhpc_charge_order set status=2 where status is null and create_time < NOW() - INTERVAL 30 MINUTE
</update>
<update id= "updateStatusNegativeOne" >
update xhpc_charge_order set status=2 where status=-1 and source=1 and create_time < NOW() - INTERVAL 30 MINUTE
</update>
2022-09-26 16:10:38 +08:00
<select id= "getSerialNumberOrder" resultType= "map" >
2022-09-28 13:50:25 +08:00
SELECT
serial_number serialNumber
FROM
xhpc_charge_order
WHERE
charge_order_id = (
SELECT MAX(charge_order_id) FROM xhpc_charge_order WHERE terminal_id = (
SELECT terminal_id FROM xhpc_terminal WHERE serial_number =#{serialNumber} AND del_flag = 0 )
)
2022-09-26 16:10:38 +08:00
</select>
2024-01-04 09:37:06 +08:00
<select id= "getXhpcBarrierGate" resultType= "map" >
select
xcs.charging_station_id as id,
xcs.name as name,
xcs.address as address,
xcs.longitude as longitude,
xcs.latitude as latitude,
xbg.barrier_gate_id as barrierGateId,
xbg.url as url,
xbg.charging_station_number as chargingStationNumber
from xhpc_charging_station xcs
left join xhpc_barrier_gate xbg on xcs.barrier_gate_id = xbg.barrier_gate_id and xbg.del_flag =0 and xbg.status =0
where charging_station_id =#{chargingStationId}
</select>
2024-03-08 15:21:59 +08:00
<select id= "getvVinNumber" resultType= "map" >
select
app_user_id as appUerId,
source as source
2024-05-30 16:58:46 +08:00
from xhpc_user_vehicle where (vin_spec_code =#{vinNumber} or vin_spec_code =#{reverseVinNumber}) and del_flag =0 and source !=1 and status =1 and vin_blacklist =0 order by create_time desc limit 1
2024-03-08 15:21:59 +08:00
</select>
2024-03-27 09:18:09 +08:00
<select id= "getChargingStationById" resultType= "map" >
select
xcs.charging_station_id as id,
xcs.name as name,
xcs.address as address,
xcs.longitude as longitude,
xcs.latitude as latitude,
xcs.area_code as areaCode
from xhpc_charging_station xcs
where xcs.charging_station_id =#{chargingStationId}
</select>
2024-07-01 09:31:42 +08:00
<update id= "updateXhpcAppUser" >
update xhpc_app_user set a_balance=#{aBalance}, b_balance =#{bBalance} where app_user_id=#{userId}
</update>
<update id= "updateXhpcCommunityPersonnel" >
update xhpc_community_personnel set a_balance=#{aBalance}, b_balance =#{bBalance} where community_personnel_id=#{userId}
</update>
<update id= "updateXhpcCustomersPersonnel" >
update xhpc_customers_personnel set a_balance=#{aBalance}, b_balance =#{bBalance} where customers_personnel_id=#{userId}
</update>
<select id= "getBlacklistUser" resultType= "int" >
select count(blacklist_id)
from xhpc_blacklist
where distinguish =1
and (
<choose >
<when test= "phone !=null and phone !='' and vin !=null and vin !='' and plateNnum !=null and plateNnum !=''" >
phone=#{phone} or vin =#{vin} or plate_num=#{plateNnum}
</when>
<when test= "phone !=null and phone !='' and vin !=null and vin !=''" >
phone=#{phone} or vin =#{vin}
</when>
<when test= "vin !=null and vin !='' and plateNnum !=null and plateNnum !=''" >
vin =#{vin} or plate_num=#{plateNnum}
</when>
<when test= "phone !=null and phone !='' and plateNnum !=null and plateNnum !=''" >
phone=#{phone} or plate_num=#{plateNnum}
</when>
<when test= "phone !=null and phone !=''" >
phone=#{phone}
</when>
<when test= "vin !=null and vin !=''" >
vin =#{vin}
</when>
<otherwise >
plate_num=#{plateNnum}
</otherwise>
</choose>
)
and blacklist_id in (select mechanism_id from xhpc_mechanism where source =2 and del_flag =0 and charging_station_id =#{chargingStationId} )
and start_time < = #{time} and end_time > = #{time}
</select>
2021-08-27 16:01:16 +08:00
</mapper>