497 lines
18 KiB
XML
Raw Normal View History

2026-01-17 15:26:41 +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.user.mapper.XhpcMotorcadeMapper">
<resultMap type="com.xhpc.user.domain.XhpcMotorcade" id="XhpcMotorcadeResult">
<result column="motorcade_id" property="motorcadeId"/>
<result column="name" property="name"/>
<result column="service_preferential" property="servicePreferential"/>
<result column="min_people" property="minPeople"/>
<result column="contact_name" property="contactName"/>
<result column="contact_phone" property="contactPhone"/>
<result column="address" property="address"/>
<result column="parent_id" property="parentId"/>
<result column="type" property="type"/>
<result column="dimension" property="dimension"/>
<result column="status" property="status"/>
<result column="del_flag" property="delFlag"/>
<result column="create_by" property="createBy"/>
<result column="create_time" property="createTime"/>
<result column="update_by" property="updateBy"/>
<result column="update_time" property="updateTime"/>
<result column="remark" property="remark"/>
<result column="motorcade_type" property="motorcadeType"/>
<result column="ilk" property="ilk"/>
<result column="total_amount" property="totalAmount"/>
</resultMap>
<select id="getLandUser" resultType="map">
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<select id="tree" resultType="map">
select
concat('CD_', motorcade_id) as id,
name as name
from xhpc_motorcade
where del_flag =0
<if test="name !=null and name !=''">
and name like CONCAT('%',#{name},'%')
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
</if>
order by create_time desc
</select>
<select id="list" resultType="map">
select
motorcade_id as motorcadeId,
name as name
from xhpc_motorcade
where del_flag =0
<if test="name !=null and name !=''">
and name like CONCAT('%',#{name},'%')
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
</if>
order by create_time desc
</select>
<insert id="addMotorcade" parameterType="com.xhpc.user.domain.XhpcMotorcade" useGeneratedKeys="true" keyProperty="motorcadeId">
insert into xhpc_motorcade
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != motorcadeId">
motorcade_id,
</if>
<if test="null != name and '' != name">
name,
</if>
<if test="null != servicePreferential">
service_preferential,
</if>
<if test="null != minPeople">
min_people,
</if>
<if test="null != contactName and '' != contactName">
contact_name,
</if>
<if test="null != contactPhone and '' != contactPhone">
contact_phone,
</if>
<if test="null != address and '' != address">
address,
</if>
<if test="null != dimension">
dimension,
</if>
<if test="null != status ">
status,
</if>
<if test="null != 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>
<if test="null != type">
type,
</if>
<if test="null != operatorId">
operatorId,
</if>
<if test="null != motorcadeType">
motorcade_type,
</if>
<if test="null != ilk">
ilk,
</if>
<if test="null != totalAmount">
total_amount,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != motorcadeId">
#{motorcadeId},
</if>
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != servicePreferential">
#{servicePreferential},
</if>
<if test="null != minPeople">
#{minPeople},
</if>
<if test="null != contactName and '' != contactName">
#{contactName},
</if>
<if test="null != contactPhone and '' != contactPhone">
#{contactPhone},
</if>
<if test="null != address and '' != address">
#{address},
</if>
<if test="null != dimension">
#{dimension},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != 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>
<if test="null != type">
#{type},
</if>
<if test="null != operatorId">
#{operatorId},
</if>
<if test="null != motorcadeType">
#{motorcadeType},
</if>
<if test="null != ilk">
#{ilk},
</if>
<if test="null != totalAmount">
#{totalAmount},
</if>
</trim>
</insert>
<update id="updateMotorcade" parameterType="com.xhpc.user.domain.XhpcMotorcade" useGeneratedKeys="true" keyProperty="motorcadeId">
update xhpc_motorcade
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="servicePreferential != null">service_preferential = #{servicePreferential},</if>
<if test="minPeople != null">min_people = #{minPeople},</if>
<if test="contactName != null">contact_name = #{contactName},</if>
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
<if test="address != null">address = #{address},</if>
<if test="dimension != null">dimension = #{dimension},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="motorcadeType != null">motorcade_type = #{motorcadeType},</if>
<if test="ilk != null">ilk = #{ilk},</if>
<if test="totalAmount != null">total_amount = #{totalAmount},</if>
</trim>
where motorcade_id=#{motorcadeId}
</update>
<update id="deleteMotorcade">
update xhpc_motorcade set del_flag =1 where motorcade_id=#{motorcadeId}
</update>
<select id="countMotorcadePersonnel" resultType="java.lang.Integer">
select count(motorcade_personnel_id) from xhpc_motorcade_personnel where motorcade_id=#{motorcadeId} and del_flag=0
</select>
<select id="getMotorcadeById" resultType="map">
select
co.motorcade_id as motorcadeId,
co.name as name,
co.service_preferential as servicePreferential,
co.motorcade_type as motorcadeType,
co.min_people as minPeople,
co.contact_name as contactName,
co.contact_phone as contactPhone,
co.address as address,
co.dimension as dimension,
co.status as status,
group_concat(me.charging_station_id) chargingStationIds
from xhpc_motorcade co
left join xhpc_mechanism me on me.mechanism_id = co.motorcade_id and me.source = 3 and me.del_flag =0
where 1=1
<if test="motorcadeId !=null and type !=null and type==1">
and co.motorcade_id=#{motorcadeId}
</if>
<if test="motorcadeId !=null and type !=null and type==2">
and co.motorcade_id !=#{motorcadeId}
</if>
<if test="name !=null">
and co.name =#{name}
</if>
limit 1
</select>
<select id="motorcadePersonnelTree" resultType="map">
SELECT
motorcade_personnel_id AS id,
name AS name
FROM
xhpc_motorcade_personnel
where motorcade_id=#{motorcadeId} and del_flag=0 and status=0
order by create_time desc
</select>
<select id="motorcadePersonnelList" resultType="map">
SELECT
motorcade_personnel_id AS motorcadePersonnelId,
name AS name,
motorcade_id AS motorcadeId,
weixin_open_id as weixinOpenId,
alipay_open_id AS alipayOpenId,
account AS account,
tenant_id as tenantId,
phone AS phone,
recharge_money AS rechargeMoney,
consume_money AS consumeMoney,
red_packet AS redPacket,
surplus_money AS surplusMoney,
type,
vin_number as vinNumber,
status
FROM
xhpc_motorcade_personnel
where motorcade_id=#{motorcadeId} and del_flag=0
<if test="account !=null and account !=''">
and account like concat('%', #{account}, '%')
</if>
<if test="phone !=null and phone !=''">
and phone like concat('%', #{phone}, '%')
</if>
<if test="status !=null">
and status=#{status}
</if>
order by create_time desc
</select>
<insert id="addMotorcadePersonnel" parameterType="com.xhpc.user.domain.XhpcMotorcadePersonnel" useGeneratedKeys="true" keyProperty="communityPersonnelId">
insert into xhpc_motorcade_personnel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != motorcadePersonnelId">
motorcade_personnel_id,
</if>
<if test="null != motorcadeId">
motorcade_id,
</if>
<if test="null != name and '' != name">
name,
</if>
<if test="null != account">
account,
</if>
<if test="null != rechargeMoney">
recharge_money,
</if>
<if test="null != consumeMoney">
consume_money,
</if>
<if test="null != redPacket">
red_packet,
</if>
<if test="null != surplusMoney">
surplus_money,
</if>
<if test="null != phone">
phone,
</if>
<if test="null != type">
type,
</if>
<if test="null != status ">
status,
</if>
<if test="null != 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>
<if test="null != createId">
create_id,
</if>
<if test="null != createType">
create_type,
</if>
<if test="null != vinNumber">
vin_number,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != motorcadePersonnelId">
#{motorcadePersonnelId},
</if>
<if test="null != motorcadeId">
#{motorcadeId},
</if>
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != account">
#{account},
</if>
<if test="null != rechargeMoney">
#{rechargeMoney},
</if>
<if test="null != consumeMoney">
#{consumeMoney},
</if>
<if test="null != redPacket">
#{redPacket},
</if>
<if test="null != surplusMoney">
#{surplusMoney},
</if>
<if test="null != phone">
#{phone},
</if>
<if test="null != type">
#{type},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != 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>
<if test="null != createId">
#{createId},
</if>
<if test="null != createType">
#{createType},
</if>
<if test="null != vinNumber">
#{vinNumber},
</if>
</trim>
</insert>
<select id="getMotorcadePersonnelById" resultType="map">
select
motorcade_personnel_id AS motorcadePersonnelId,
name AS name,
motorcade_id AS motorcadeId,
account AS account,
phone AS phone,
recharge_money AS rechargeMoney,
surplus_money AS surplusMoney,
type,
vin_number AS vinNumber,
status
from xhpc_motorcade_personnel
where del_flag =0
<if test="motorcadePersonnelId !=null and type !=null and type==1">
and motorcade_personnel_id=#{motorcadePersonnelId}
</if>
<if test="type !=null and type==3">
and phone =#{phone} or account =#{account}
</if>
<if test="motorcadePersonnelId !=null and type !=null and type==2">
and motorcade_personnel_id !=#{motorcadePersonnelId}
and motorcade_personnel_id in ( select motorcade_personnel_id from xhpc_motorcade_personnel where phone =#{phone} or account =#{account} and del_flag =0)
</if>
limit 1
</select>
<update id="updateMotorcadePersonnel">
update xhpc_motorcade_personnel
<trim prefix="SET" suffixOverrides=",">
<if test="motorcadeId != null">motorcade_id = #{motorcadeId},</if>
<if test="name != null">name = #{name},</if>
<if test="account != null">account = #{account},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="rechargeMoney != null">recharge_money = #{rechargeMoney},</if>
<if test="surplusMoney != null">surplus_money = #{surplusMoney},</if>
<if test="type != null">type = #{type},</if>
<if test="status != null">address = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="vinNumber != null">vin_number = #{vinNumber},</if>
<if test="isRefundApplication != null">is_refund_application = #{isRefundApplication},</if>
</trim>
where motorcade_personnel_id=#{motorcadePersonnelId}
</update>
<update id="deleteMotorcadePersonnel">
update xhpc_motorcade_personnel set del_flag=1 where motorcade_personnel_id=#{motorcadePersonnelId}
</update>
<update id="updateMotorcadePersonnelStatus">
update xhpc_motorcade_personnel set status=#{status} where motorcade_personnel_id=#{motorcadePersonnelId}
</update>
<select id="getMotorcadePersonnelUserId" resultType="map">
select
co.motorcade_type motorcadeType,
co.service_preferential servicePreferential
from xhpc_motorcade co
join xhpc_mechanism me on me.mechanism_id = co.motorcade_id and me.source = 3 and me.del_flag =0
where co.motorcade_id = (select motorcade_id from xhpc_motorcade_personnel where motorcade_personnel_id=#{userId} and tenant_id=#{tenantId} and del_flag =0)
<if test="chargingStationId !=null">
and me.charging_station_id=#{chargingStationId}
</if>
</select>
</mapper>