334 lines
14 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">
2021-12-31 09:23:41 +08:00
<!--suppress ALL -->
<mapper namespace="com.xhpc.user.mapper.XhpcCommonMapper">
<select id="getAppUser" resultType="map">
select
2022-02-11 19:04:18 +08:00
xau.app_user_id as appUserId,
xau.phone as phone,
xau.is_refund_application as isRefundApplication,
xau.is_refund as isRefund,
xau.soc as socUser,
xau.balance as balance,
xau.avatar as avatar,
xau.status,
xau.weixin_open_id as weixinOpenId,
xau.alipay_open_id as alipayOpenId,
xau.weixin_login as weixinLogin,
xau.alipay_login as alipayLogin,
xau.del_flag delFlag,
concat(0) as userType,
concat("C") as userTypeName,
xau.tenant_id tenantId,
xau.soc_protect socProtect,
ten.status tenantStatus,
xau.create_time as createTime
from xhpc_app_user xau
left join xhpc_tenant ten on ten.tenant_id = xau.tenant_id and ten.is_deleted =0
where xau.del_flag=0
<if test="phone !=null and phone !=''">
2022-02-11 19:04:18 +08:00
and xau.phone =#{phone}
</if>
<if test="userId !=null">
2022-02-11 19:04:18 +08:00
and xau.app_user_id =#{userId}
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
2022-02-11 19:04:18 +08:00
and xau.tenant_id =#{tenantId}
2022-01-04 10:19:03 +08:00
</if>
</select>
<select id="getCommunityUser" resultType="map">
select
2022-02-11 19:04:18 +08:00
xcp.community_personnel_id as appUserId,
xcp.account as account,
xcp.phone as phone,
xcp.is_refund_application as isRefundApplication,
xcp.is_refund as isRefund,
xcp.soc as socUser,
xcp.surplus_money as balance,
xcp.avatar as avatar,
xcp.status,
xcp.weixin_open_id as weixinOpenId,
xcp.alipay_open_id as alipayOpenId,
xcp.weixin_login as weixinLogin,
xcp.alipay_login as alipayLogin,
xcp.tenant_id tenantId,
xcp.del_flag delFlag,
concat(2) as userType,
2022-02-11 19:04:18 +08:00
xcp.soc_protect socProtect,
ten.status tenantStatus,
2022-01-10 13:52:59 +08:00
concat("ST") as userTypeName,
2021-12-31 09:23:41 +08:00
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
2022-02-11 19:04:18 +08:00
xcp.create_time as createTime
from xhpc_community_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
2022-02-11 19:04:18 +08:00
and xcp.account =#{phone}
</if>
<if test="userId !=null">
2022-02-11 19:04:18 +08:00
and xcp.community_personnel_id =#{userId}
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
2022-02-11 19:04:18 +08:00
and xcp.tenant_id =#{tenantId}
2022-01-04 10:19:03 +08:00
</if>
</select>
<select id="getCustomersUser" resultType="map">
select
2022-02-11 19:04:18 +08:00
xcp.customers_personnel_id as appUserId,
xcp.account as account,
xcp.phone as phone,
xcp.is_refund_application as isRefundApplication,
xcp.is_refund as isRefund,
xcp.soc as socUser,
xcp.surplus_money as balance,
xcp.avatar as avatar,
xcp.status,
xcp.weixin_open_id as weixinOpenId,
xcp.alipay_open_id as alipayOpenId,
xcp.weixin_login as weixinLogin,
xcp.alipay_login as alipayLogin,
xcp.del_flag delFlag,
xcp.tenant_id tenantId,
concat(3) as userType,
2022-02-11 19:04:18 +08:00
xcp.soc_protect socProtect,
ten.status tenantStatus,
2022-01-10 13:52:59 +08:00
concat("BE") as userTypeName,
2021-12-31 09:23:41 +08:00
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
2022-02-11 19:04:18 +08:00
xcp.create_time as createTime
from xhpc_customers_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
2022-02-11 19:04:18 +08:00
and xcp.account =#{phone}
</if>
<if test="userId !=null">
2022-02-11 19:04:18 +08:00
and xcp.customers_personnel_id =#{userId}
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
2022-02-11 19:04:18 +08:00
and xcp.tenant_id =#{tenantId}
2022-01-04 10:19:03 +08:00
</if>
</select>
2022-04-24 14:28:39 +08:00
<select id="getPersonnelStatistics" resultType="map">
select
concat("社区用户") as mechanismName,
xcp.account as account,
xcp.name as name,
xcp.phone as phone,
count(xho.history_order_id) number,
IFNULL(sum(xho.total_power),0) totalPower,
IFNULL(sum(xho.total_price),0) totalPrice,
IFNULL(sum(xho.promotion_discount),0) promotionDiscount
from xhpc_community_personnel as xcp
2022-05-24 17:32:01 +08:00
left join xhpc_community xc on xc.community_id = xcp.community_id and xc.del_flag =0
2022-04-24 14:28:39 +08:00
left join xhpc_history_order xho on xho.source =2 and xho.user_id =xcp.community_personnel_id
2022-05-24 17:32:01 +08:00
where xcp.del_flag=0
<if test="tenantId !=null and tenantId!=''">
and xcp.tenant_id=#{tenantId}
</if>
2022-04-24 14:28:39 +08:00
<if test="number==1 or number==2">
and xcp.create_type=2 and xcp.create_id=#{userId}
</if>
<if test="type==1">
and xcp.create_type=2 and xcp.create_id=#{userId}
</if>
2022-05-24 17:32:01 +08:00
<if test="terminalId !=null">
and xho.terminal_id=#{terminalId}
</if>
2022-04-24 14:28:39 +08:00
<if test="chargingStationId !=null">
and xcp.create_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
</if>
<if test="operatorId !=null">
and xcp.create_id=#{operatorId}
</if>
<if test="chargingPileId !=null">
and xcp.create_id=(select operator_id from xhpc_charging_station where charging_station_id=(select terminal_id from xhpc_charging_pile where charging_pile_id=#{chargingPileId}))
</if>
<if test="name !=null and name !=''">
and xcp.name like concat('%',#{name},'%')
</if>
<if test="account !=null and account !=''">
and xcp.account like concat('%',#{account},'%')
</if>
<if test="phone !=null and phone !=''">
and xcp.phone like concat('%',#{phone},'%')
</if>
<if test="startTime !=null and '' !=startTime">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and '' !=endTime">
and xho.end_time &lt;=#{endTime}
</if>
2022-04-24 14:28:39 +08:00
GROUP BY xcp.account
2022-05-24 17:32:01 +08:00
union
2022-04-24 14:28:39 +08:00
select
concat("B端用户") as mechanismName,
xcup.account as account,
xcup.name as name,
xcup.phone as phone,
count(xho.history_order_id) number,
IFNULL(sum(xho.total_power),0) totalPower,
IFNULL(sum(xho.total_price),0) totalPrice,
IFNULL(sum(xho.promotion_discount),0) promotionDiscount
from xhpc_customers_personnel as xcup
2022-05-24 17:32:01 +08:00
left join xhpc_customers xuc on xuc.customers_id = xcup.customers_personnel_id and xuc.del_flag =0
2022-04-24 14:28:39 +08:00
left join xhpc_history_order xho on xho.source =3 and xho.user_id =xcup.customers_personnel_id
2022-05-24 17:32:01 +08:00
where xcup.del_flag=0
<if test="tenantId !=null and tenantId!=''">
and xcup.tenant_id=#{tenantId}
</if>
2022-04-24 14:28:39 +08:00
<if test="number==1 or number==2">
and xcup.create_type=2 and xcup.create_id=#{userId}
</if>
<if test="type==1">
and xcup.create_type=2 and xcup.create_id=#{userId}
</if>
2022-05-24 17:32:01 +08:00
<if test="terminalId !=null">
and xho.terminal_id=#{terminalId}
</if>
2022-04-24 14:28:39 +08:00
<if test="chargingStationId !=null">
and xcup.create_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
</if>
<if test="operatorId !=null">
and xcup.create_id=#{operatorId}
</if>
<if test="chargingPileId !=null">
and xcup.create_id=(select operator_id from xhpc_charging_station where charging_station_id=(select terminal_id from xhpc_charging_pile where charging_pile_id=#{chargingPileId}))
</if>
<if test="name !=null and name !=''">
and xcup.name like concat('%',#{name},'%')
</if>
<if test="account !=null and account !=''">
and xcup.account like concat('%',#{account},'%')
</if>
<if test="phone !=null and phone !=''">
and xcup.phone like concat('%',#{phone},'%')
</if>
<if test="startTime !=null and '' !=startTime">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and '' !=endTime">
and xho.end_time &lt;=#{endTime}
</if>
2022-04-24 14:28:39 +08:00
GROUP BY xcup.account
2022-05-24 17:32:01 +08:00
</select>
<select id="getCommunityPersonnel" resultType="map">
2022-04-24 14:28:39 +08:00
select
concat("社区用户") as mechanismName,
xcp.account as account,
xcp.name as name,
xcp.phone as phone,
count(xho.history_order_id) number,
IFNULL(sum(xho.total_power),0) totalPower,
IFNULL(sum(xho.total_price),0) totalPrice,
IFNULL(sum(xho.promotion_discount),0) promotionDiscount
from xhpc_community_personnel as xcp
2022-05-24 17:32:01 +08:00
left join xhpc_community xc on xc.community_id = xcp.community_id and xc.del_flag =0
2022-04-24 14:28:39 +08:00
left join xhpc_history_order xho on xho.source =2 and xho.user_id =xcp.community_personnel_id
2022-05-24 17:32:01 +08:00
where xcp.del_flag=0
<if test="tenantId !=null and tenantId!=''">
and xcp.tenant_id=#{tenantId}
</if>
<if test="number==1 or number==2">
2022-04-24 14:28:39 +08:00
and xcp.create_type=2 and xcp.create_id=#{userId}
</if>
<if test="type==1">
and xcp.create_type=2 and xcp.create_id=#{userId}
</if>
<if test="chargingStationId !=null">
and xcp.create_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
</if>
<if test="operatorId !=null">
and xcp.create_id=#{operatorId}
</if>
2022-05-24 17:32:01 +08:00
<if test="terminalId !=null">
and xho.terminal_id=#{terminalId}
</if>
2022-04-24 14:28:39 +08:00
<if test="chargingPileId !=null">
and xcp.create_id=(select operator_id from xhpc_charging_station where charging_station_id=(select terminal_id from xhpc_charging_pile where charging_pile_id=#{chargingPileId}))
</if>
<if test="name !=null and name !=''">
and xcp.name like concat('%',#{name},'%')
</if>
<if test="account !=null and account !=''">
and xcp.account like concat('%',#{account},'%')
</if>
<if test="phone !=null and phone !=''">
and xcp.phone like concat('%',#{phone},'%')
</if>
<if test="startTime !=null and '' !=startTime">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and '' !=endTime">
and xho.end_time &lt;=#{endTime}
</if>
2022-04-24 14:28:39 +08:00
GROUP BY xcp.account
2022-05-24 17:32:01 +08:00
</select>
<select id="getCustomersPersonnel" resultType="map">
2022-04-24 14:28:39 +08:00
select
concat("B端用户") as mechanismName,
xcup.account as account,
xcup.name as name,
xcup.phone as phone,
count(xho.history_order_id) number,
IFNULL(sum(xho.total_power),0) totalPower,
IFNULL(sum(xho.total_price),0) totalPrice,
IFNULL(sum(xho.promotion_discount),0) promotionDiscount
from xhpc_customers_personnel as xcup
2022-05-24 17:32:01 +08:00
left join xhpc_customers xuc on xuc.customers_id = xcup.customers_personnel_id and xuc.del_flag =0
2022-04-24 14:28:39 +08:00
left join xhpc_history_order xho on xho.source =3 and xho.user_id =xcup.customers_personnel_id
2022-05-24 17:32:01 +08:00
where xcup.del_flag=0
<if test="tenantId !=null and tenantId!=''">
and xcup.tenant_id=#{tenantId}
</if>
<if test="number==1 or number==2">
2022-04-24 14:28:39 +08:00
and xcup.create_type=2 and xcup.create_id=#{userId}
</if>
<if test="type==1">
and xcup.create_type=2 and xcup.create_id=#{userId}
</if>
<if test="chargingStationId !=null">
and xcup.create_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
</if>
<if test="operatorId !=null">
and xcup.create_id=#{operatorId}
</if>
2022-05-24 17:32:01 +08:00
<if test="terminalId !=null">
and xho.terminal_id=#{terminalId}
</if>
2022-04-24 14:28:39 +08:00
<if test="chargingPileId !=null">
and xcup.create_id=(select operator_id from xhpc_charging_station where charging_station_id=(select terminal_id from xhpc_charging_pile where charging_pile_id=#{chargingPileId}))
</if>
<if test="name !=null and name !=''">
and xcup.name like concat('%',#{name},'%')
</if>
<if test="account !=null and account !=''">
and xcup.account like concat('%',#{account},'%')
</if>
<if test="phone !=null and phone !=''">
and xcup.phone like concat('%',#{phone},'%')
</if>
<if test="startTime !=null and '' !=startTime">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and '' !=endTime">
and xho.end_time &lt;=#{endTime}
</if>
2022-04-24 14:28:39 +08:00
GROUP BY xcup.account
2022-05-24 17:32:01 +08:00
</select>
</mapper>