sadjv3_java/src/main/resources/mapper/artificer/ArtificerDao.xml

179 lines
8.1 KiB
XML
Raw Normal View History

2024-06-05 19:12: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">
<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 as consortiaId,
(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 ),0.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
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
where u.is_authentication=2
<if test="status!=null and status!=0 and status!=-1">
and a.status=#{status}
</if>
<if test="classifyId!=null and classifyId!=0">
and classify_id=#{classifyId}
</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
<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.consortia_id as consortiaId,
(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 o.user_id = #{userId}
and classify = 1) as collectCount,
ifnull((select avg(c.score) from taking_commnt c where c.artificer_id = a.artificer_id),
0.00) as ordersScore,
(st_distance(point(a.longitude, a.latitude), point(#{longitude}, #{latitude})) *
111195) as distance
from artificer a
left join tb_user u on a.user_id = u.user_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),
0.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') &lt;= 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 ),0.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>
</mapper>