410 lines
18 KiB
XML
410 lines
18 KiB
XML
<?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.sqx.modules.artificer.dao.ArtificerDao">
|
|
|
|
<select id="selectArtificerList" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select * from (select a.*,u.phone,s.code as classifyName,u.status as artificerStatus,u.consortia_id,c.consortia_name,
|
|
(select count(*) from collect_artificer o where o.artificer_id=a.artificer_id and classify=1) as collectCount,
|
|
(select count(*) from orders o where o.artificer_id=a.artificer_id and o.status in (3,5)) as ordersCount,
|
|
ifnull((select avg(c.score) from taking_commnt c where c.artificer_id=a.artificer_id ),5.00) as ordersScore,
|
|
(select count(*) from taking_commnt c where c.artificer_id=a.artificer_id ) as commentCount,
|
|
(st_distance (point (a.longitude, a.latitude),point(#{longitude},#{latitude}) ) *111195) as distance,
|
|
v.vip_name as technicianTypeName,v.rate as technicianTypeRate ,(CASE WHEN DATEDIFF(CURDATE(), a.create_time) <=7 THEN 1 ELSE 2 END) AS isNewer
|
|
from artificer a
|
|
left join tb_user u on a.user_id=u.user_id
|
|
left join sys_dict s on s.id=a.classify_id
|
|
left join vip_details v on a.technician_type = v.vip_name_type and v.vip_type = 1
|
|
left join consortia c on u.consortia_id = c.consortia_id
|
|
where u.is_authentication=2
|
|
<if test="status!=null and status!=0 and status!=-1">
|
|
and a.status=#{status}
|
|
</if>
|
|
<if test="isStart!=null and isStart!=0">
|
|
and a.is_start=#{isStart}
|
|
</if>
|
|
<if test="classifyId!=null and classifyId!=0">
|
|
and classify_id=#{classifyId}
|
|
</if>
|
|
<if test="technicianType!=null and technicianType!=0">
|
|
and a.technician_type=#{technicianType}
|
|
</if>
|
|
<if test="massageTypeId!=null">
|
|
and a.artificer_id in (select artificer_id from artificer_massage where massage_type_id =#{massageTypeId})
|
|
</if>
|
|
<if test="artificerName!=null and artificerName!=''">
|
|
and artificer_name like concat('%',#{artificerName},'%')
|
|
</if>
|
|
<if test="city!=null and city!=''">
|
|
and a.city=#{city}
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone=#{phone}
|
|
</if>
|
|
<if test="authentication!=null">
|
|
and u.is_authentication=2
|
|
</if>
|
|
<if test="user!=null">
|
|
and a.longitude is not null and a.latitude is not null
|
|
</if>
|
|
) b
|
|
where distance <= 50000
|
|
<if test="by!=null and by==1">
|
|
order by
|
|
<if test="status!=null and status==-1">
|
|
status asc,
|
|
</if>
|
|
distance asc
|
|
</if>
|
|
<if test="by!=null and by==2">
|
|
order by
|
|
<if test="status!=null and status==-1">
|
|
status asc,
|
|
</if>
|
|
distance asc
|
|
</if>
|
|
<if test="by!=null and by==3">
|
|
order by
|
|
<if test="status!=null and status==-1">
|
|
status asc,
|
|
</if>
|
|
artificer_sales desc
|
|
</if>
|
|
<if test="by!=null and by==4">
|
|
order by
|
|
<if test="status!=null and status==-1">
|
|
status asc,
|
|
</if>
|
|
credit_score desc
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectArtificerById" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.*,u.phone,u.status as artificerStatus,u.consortia_id as consortiaId,c.consortia_name,u.invitation_code,
|
|
(select count(*) from orders o where o.artificer_id = a.artificer_id and o.status in (3,5)) as ordersCount,
|
|
(select code from sys_dict o where o.id = a.classify_id) as classifyName,
|
|
(select count(*) from collect_artificer o where o.artificer_id = a.artificer_id and classify = 1) as collectCount,
|
|
(select count(*) from collect_artificer o where o.artificer_id = a.artificer_id and o.user_id = #{userId} and classify = 1) as myCollectCount,
|
|
ifnull((select avg(c.score) from taking_commnt c where c.artificer_id = a.artificer_id), 5.00) as ordersScore,
|
|
(st_distance(point(a.longitude, a.latitude), point(#{longitude}, #{latitude})) * 111195) as distance,
|
|
v.vip_name as technicianTypeName,v.rate as technicianTypeRate ,(CASE WHEN DATEDIFF(CURDATE(), a.create_time) <=7 THEN 1 ELSE 2 END) AS isNewer
|
|
from artificer a
|
|
left join tb_user u on a.user_id = u.user_id
|
|
left join sys_dict s on s.id=a.classify_id
|
|
left join vip_details v on a.technician_type = v.vip_name_type and v.vip_type = 1
|
|
left join consortia c on u.consortia_id = c.consortia_id
|
|
where a.artificer_id = #{artificerId}
|
|
</select>
|
|
|
|
<select id="selectArtificerByUserId" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.*,
|
|
(select count(*) from orders o where o.artificer_id = a.artificer_id and o.status in (3,5)) as ordersCount,
|
|
ifnull((select avg(c.score) from taking_commnt c where c.artificer_id = a.artificer_id),
|
|
5.00) as ordersScore
|
|
from artificer a
|
|
left join tb_user u on a.user_id = u.user_id
|
|
where a.user_id = #{artificerId}
|
|
</select>
|
|
|
|
<select id="selectArtificerByStatus" resultType="int">
|
|
select count(*)
|
|
from artificer_massage
|
|
where artificer_id = #{userId}
|
|
and status = #{status}
|
|
</select>
|
|
|
|
<select id="selectArtificerMoneyList" resultType="Map">
|
|
select * from (
|
|
select ifnull(sum(o.artificer_money),0.00) as money,count(*) as counts,o.artificer_id as artificerId,a.artificer_name as
|
|
artificerName,a.user_id as userId
|
|
from artificer a
|
|
left join orders o on a.artificer_id=o.artificer_id
|
|
where o.`status` in (3,5)
|
|
<if test="title!=null and title!=''">
|
|
and massage_type_id in (select massage_type_id from massage_type where title like concat('%',#{title},'%'))
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="endTime!=null and endTime!=''">
|
|
and date_format(end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
|
|
</if>
|
|
<if test="classifyId !=null and classifyId!=''">
|
|
and massage_type_id in (select massage_type_id from massage_type where classify_id =#{classifyId})
|
|
</if>
|
|
group by o.artificer_id
|
|
) a order by money desc
|
|
</select>
|
|
|
|
<select id="selectUserListByConsortiaId" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.*,u.phone,
|
|
u.status as artificerStatus,
|
|
(select count(*) from collect_artificer o where o.artificer_id=a.artificer_id and classify=1) as collectCount,
|
|
(select count(*) from orders o where o.artificer_id=a.artificer_id and o.status in (3,5)) as ordersCount,
|
|
ifnull((select avg(c.score) from taking_commnt c where c.artificer_id=a.artificer_id ),5.00) as ordersScore,
|
|
(select count(*) from taking_commnt c where c.artificer_id=a.artificer_id ) as commentCount,
|
|
(select ifnull(sum(o.shop_money),0.00) as money from orders o
|
|
where o.shop_user_id=#{shopId}
|
|
and o.artificer_id=(select artificer_id from artificer a where a.user_id=u.user_id)
|
|
and status in (3,5)
|
|
<if test="flag!=null and flag==1">
|
|
and date_format(o.end_times,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
</if>
|
|
<if test="flag!=null and flag==2">
|
|
and date_format(o.end_times,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
</if>
|
|
<if test="flag!=null and flag==3">
|
|
and date_format(o.end_times,'%Y')=date_format(#{time},'%Y')
|
|
</if>
|
|
) as money
|
|
from tb_user u
|
|
left join artificer a on a.user_id=u.user_id
|
|
where u.consortia_id=#{consortiaId} and u.is_shop is null and a.artificer_id is not null
|
|
<if test="userName!=null and userName!=''">
|
|
and u.user_name like concat('%',#{userName},'%')
|
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
|
and u.phone like concat('%',#{phone},'%')
|
|
</if>
|
|
order by u.create_time desc
|
|
</select>
|
|
|
|
<select id="selectArtificerMassageDuration" resultType="java.lang.Integer">
|
|
SELECT
|
|
t.duration
|
|
FROM
|
|
artificer_massage m
|
|
LEFT JOIN massage_type t ON t.massage_type_id = m.massage_type_id
|
|
WHERE
|
|
m.artificer_id = #{artificerId}
|
|
AND t.STATUS = 1
|
|
AND t.parent_id = "0"
|
|
ORDER BY
|
|
t.duration DESC
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="getHomeStartArtificerList" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.artificer_id,artificer_name,artificer_img,s.code as classifyName,a.content,v.vip_name as technicianTypeName,a.city,a.bdxsl
|
|
from artificer a
|
|
inner join tb_user u on a.user_id=u.user_id
|
|
inner join sys_dict s on s.id=a.classify_id
|
|
left join vip_details v on a.technician_type = v.vip_name_type and v.vip_type = 1
|
|
where u.is_authentication=2
|
|
<if test="status!=null and status!=0 and status!=-1">
|
|
and u.status=#{status}
|
|
</if>
|
|
<if test="isStart!=null and isStart!=0">
|
|
and a.is_start=#{isStart}
|
|
</if>
|
|
<if test="city!=null and city!=''">
|
|
and a.city=#{city}
|
|
</if>
|
|
order by artificer_sales desc
|
|
</select>
|
|
|
|
|
|
<select id="getYxjsList" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.* from artificer a
|
|
inner join tb_user u on a.user_id=u.user_id
|
|
where u.status = 1
|
|
and yn_jfgz = 1
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectInlineList" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.* from artificer a
|
|
inner join tb_user u on a.user_id=u.user_id
|
|
where u.status = 1
|
|
<if test="status">
|
|
and a.status = ${status}
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="selectByPhone" resultType="com.sqx.modules.artificer.entity.Artificer">
|
|
select a.* from artificer a
|
|
inner join tb_user u on a.user_id=u.user_id
|
|
where u.phone = #{phone}
|
|
</select>
|
|
|
|
|
|
<!--按照业绩倒叙-->
|
|
<select id="getYejiList" resultType="Map">
|
|
select t.*,sum(price_total) AS typeval,a.artificer_name as artificerName
|
|
from (
|
|
select o.artificer_id,
|
|
(
|
|
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
|
|
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
|
|
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
|
|
) as price_total
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
left join massage_type m on m.massage_type_id=om.massage_id
|
|
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
|
|
where o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_id,
|
|
o.price + ifnull(o.add_price,0) as price_total
|
|
from orders o
|
|
left join orders_massage om on om.orders_id=o.orders_id
|
|
where o.parent_id = 0
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
left join artificer a on t.artificer_id = a.artificer_id
|
|
where a.artificer_name is not null
|
|
GROUP BY t.artificer_id
|
|
order by sum(price_total) desc
|
|
</select>
|
|
<!-- 在线时长-->
|
|
<select id="getZxscList" resultType="Map">
|
|
select t.artificer_id,IFNULL( SUM(t.user_recharge),0) AS typeval,a.artificer_name as artificerName
|
|
from bl_user_zxsc t
|
|
left join artificer a on t.artificer_id = a.artificer_id
|
|
<where>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and t.create_time >= #{startTime}
|
|
</if>
|
|
<if test="startTime!=null and startTime!=''">
|
|
and t.create_time <= #{endTime}
|
|
</if>
|
|
</where>
|
|
group BY t.artificer_id
|
|
order by IFNULL( SUM(user_recharge),0) desc
|
|
</select>
|
|
|
|
<!-- 加钟率-->
|
|
<select id="getJzlList" resultType="Map">
|
|
|
|
select t.artificer_id,IFNULL( count(*),'0') AS a,sum(add_num) as b, round(sum(add_num)/IFNULL( count(*),'0'),2) * 100 as typeval,a.artificer_name as artificerName
|
|
from (
|
|
select o.artificer_id,(case when o.status = 4
|
|
then o.artificer_money + ifnull(o.add_artificer_money,0)
|
|
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
|
|
end) as artificer_money_total,if(o.add_num is null ,0,1) as add_num
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
union all
|
|
select o.artificer_id,o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total,if(add_num is null ,0,1) add_num
|
|
from orders o
|
|
where o.parent_id = 0
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
left join artificer a on t.artificer_id = a.artificer_id
|
|
|
|
GROUP BY artificer_id
|
|
order by round(sum(add_num)/IFNULL( count(*),'0'),2) * 100 desc
|
|
</select>
|
|
|
|
<!-- 充值率-->
|
|
<select id="getCzlList" resultType="Map">
|
|
select t.artificer_id,
|
|
IFNULL(count(*),0) AS tt,
|
|
IFNULL(ur.num,0) as num,
|
|
IFNULL(ur.num,0) / IFNULL(count(*),0) as typeval,a.artificer_name as artificerName
|
|
from (
|
|
select o.artificer_id
|
|
from orders o
|
|
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
|
|
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
|
|
where o.old_orders_id is not null
|
|
and o.status not in (4,11,15)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
GROUP BY o.artificer_id
|
|
union all
|
|
select o.artificer_id
|
|
from orders o
|
|
where o.parent_id = 0
|
|
and o.orders_id not in (
|
|
select orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
)
|
|
and o.orders_id not in (
|
|
select old_orders_id from orders
|
|
where old_orders_id is not null
|
|
and status != 4
|
|
GROUP BY o.artificer_id
|
|
)
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
and o.status in (3,5)
|
|
) t
|
|
LEFT JOIN (select artificer_id,count(*) as num from user_recharge
|
|
where orders_id is not null
|
|
<if test="startTime!=null and startTime !=''">
|
|
and date_format(create_time,'%Y-%m-%d %H:%i:%s') >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null and endTime !=''">
|
|
and date_format(create_time,'%Y-%m-%d %H:%i:%s') <= #{endTime}
|
|
</if>
|
|
GROUP BY artificer_id) ur on t.artificer_id = ur.artificer_id
|
|
left join artificer a on t.artificer_id = a.artificer_id
|
|
GROUP BY t.artificer_id
|
|
order by IFNULL(ur.num,0) / IFNULL(count(*),0) desc
|
|
</select>
|
|
</mapper> |