| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <?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="shop.alien.mapper.OrderReviewMapper">
- <!-- 评价列表查询结果映射 -->
- <resultMap id="OrderReviewVoResultMap" type="shop.alien.entity.store.vo.OrderReviewVo">
- <id column="id" property="id" />
- <result column="order_id" property="orderId" />
- <result column="order_number" property="orderNumber" />
- <result column="user_id" property="userId" />
- <result column="user_name" property="userName" />
- <result column="user_avatar" property="userAvatar" />
- <result column="lawyer_user_id" property="lawyerUserId" />
- <result column="lawyer_name" property="lawyerName" />
- <result column="lawyer_avatar" property="lawyerAvatar" />
- <result column="law_firm_name" property="lawFirmName" />
- <result column="overall_rating" property="overallRating" />
- <result column="service_attitude_rating" property="serviceAttitudeRating" />
- <result column="response_time_rating" property="responseTimeRating" />
- <result column="professional_ability_rating" property="professionalAbilityRating" />
- <result column="review_content" property="reviewContent" />
- <result column="review_images" property="reviewImagesJson" />
- <result column="is_anonymous" property="isAnonymous" />
- <result column="like_count" property="likeCount" />
- <result column="comment_count" property="commentCount" />
- <result column="is_liked" property="isLiked" />
- <result column="created_time" property="createdTime" />
- </resultMap>
- <!-- 分页查询评价列表(包含用户和律师信息) -->
- <select id="getReviewListWithUser" resultMap="OrderReviewVoResultMap">
- SELECT
- orv.id,
- orv.order_id,
- orv.order_number,
- orv.user_id,
- CASE
- WHEN orv.is_anonymous = 1 THEN '匿名用户'
- ELSE lu.user_name
- END AS user_name,
- CASE
- WHEN orv.is_anonymous = 1 THEN NULL
- ELSE lu.user_image
- END AS user_avatar,
- orv.lawyer_user_id,
- lu2.name AS lawyer_name,
- lu2.head_img AS lawyer_avatar,
- lf.firm_name AS law_firm_name,
- orv.overall_rating,
- orv.service_attitude_rating,
- orv.response_time_rating,
- orv.professional_ability_rating,
- orv.review_content,
- orv.is_anonymous,
- orv.like_count,
- orv.comment_count,
- orv.review_images,
- CASE
- WHEN #{currentUserId} IS NOT NULL AND llr.id IS NOT NULL THEN 1
- ELSE 0
- END AS is_liked,
- orv.created_time
- FROM lawyer_order_review orv
- LEFT JOIN life_user lu ON lu.id = orv.user_id AND lu.delete_flag = 0
- LEFT JOIN lawyer_user lu2 ON lu2.id = orv.lawyer_user_id AND lu2.delete_flag = 0
- LEFT JOIN law_firm lf ON lf.id = lu2.firm_id AND lf.delete_flag = 0
- LEFT JOIN life_like_record llr ON CONVERT(llr.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr.type = '7'
- AND CONVERT(llr.dianzan_id, CHAR) = CONVERT(#{currentUserId}, CHAR)
- AND llr.delete_flag = 0
- WHERE orv.delete_flag = 0
- <if test="orderId != null">
- AND orv.order_id = #{orderId}
- </if>
- <if test="lawyerUserId != null">
- AND orv.lawyer_user_id = #{lawyerUserId}
- </if>
- <if test="userId != null">
- AND orv.user_id = #{userId}
- </if>
- ORDER BY orv.created_time DESC
- </select>
- <!-- 根据订单ID查询评价 -->
- <select id="getReviewByOrderId" resultMap="OrderReviewVoResultMap">
- SELECT
- orv.id,
- orv.order_id,
- orv.order_number,
- orv.user_id,
- CASE
- WHEN orv.is_anonymous = 1 THEN '匿名用户'
- ELSE lu.user_name
- END AS user_name,
- CASE
- WHEN orv.is_anonymous = 1 THEN NULL
- ELSE lu.user_image
- END AS user_avatar,
- orv.lawyer_user_id,
- lu2.name AS lawyer_name,
- lu2.head_img AS lawyer_avatar,
- lf.firm_name AS law_firm_name,
- orv.overall_rating,
- orv.service_attitude_rating,
- orv.response_time_rating,
- orv.professional_ability_rating,
- orv.review_content,
- orv.is_anonymous,
- orv.like_count,
- orv.comment_count,
- CASE
- WHEN #{currentUserId} IS NOT NULL AND llr.id IS NOT NULL THEN 1
- ELSE 0
- END AS is_liked,
- orv.created_time
- FROM lawyer_order_review orv
- LEFT JOIN life_user lu ON lu.id = orv.user_id AND lu.delete_flag = 0
- LEFT JOIN lawyer_user lu2 ON lu2.id = orv.lawyer_user_id AND lu2.delete_flag = 0
- LEFT JOIN law_firm lf ON lf.id = lu2.firm_id AND lf.delete_flag = 0
- LEFT JOIN life_like_record llr ON CONVERT(llr.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr.type = '7'
- AND CONVERT(llr.dianzan_id, CHAR) = CONVERT(#{currentUserId}, CHAR)
- AND llr.delete_flag = 0
- WHERE orv.delete_flag = 0
- AND orv.order_id = #{orderId}
- LIMIT 1
- </select>
- <!-- 根据评价ID查询评价详情(包含用户和律师信息) -->
- <select id="getReviewDetailById" resultMap="OrderReviewVoResultMap">
- SELECT
- orv.id,
- orv.order_id,
- orv.order_number,
- orv.user_id,
- CASE
- WHEN orv.is_anonymous = 1 THEN '匿名用户'
- ELSE lu.user_name
- END AS user_name,
- CASE
- WHEN orv.is_anonymous = 1 THEN NULL
- ELSE lu.user_image
- END AS user_avatar,
- orv.lawyer_user_id,
- lu2.name AS lawyer_name,
- lu2.head_img AS lawyer_avatar,
- lf.firm_name AS law_firm_name,
- orv.overall_rating,
- orv.service_attitude_rating,
- orv.response_time_rating,
- orv.professional_ability_rating,
- orv.review_content,
- orv.review_images,
- orv.is_anonymous,
- COALESCE((
- SELECT COUNT(1)
- FROM life_like_record llr_count
- WHERE CONVERT(llr_count.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr_count.type = '7'
- AND llr_count.delete_flag = 0
- ), 0) AS like_count,
- orv.comment_count,
- CASE
- WHEN #{currentUserId} IS NOT NULL AND llr.id IS NOT NULL THEN 1
- ELSE 0
- END AS is_liked,
- orv.created_time
- FROM lawyer_order_review orv
- LEFT JOIN life_user lu ON lu.id = orv.user_id AND lu.delete_flag = 0
- LEFT JOIN lawyer_user lu2 ON lu2.id = orv.lawyer_user_id AND lu2.delete_flag = 0
- LEFT JOIN law_firm lf ON lf.id = lu2.firm_id AND lf.delete_flag = 0
- LEFT JOIN life_like_record llr ON CONVERT(llr.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr.type = '7'
- AND CONVERT(llr.dianzan_id, CHAR) = CONVERT(#{currentUserId}, CHAR)
- AND llr.delete_flag = 0
- WHERE orv.delete_flag = 0
- AND orv.id = #{reviewId}
- </select>
- <!-- 评价列表结果映射 -->
- <resultMap id="PendingReviewVoResultMap" type="shop.alien.entity.store.vo.PendingReviewVo">
- <result column="order_id" property="orderId" />
- <result column="order_number" property="orderNumber" />
- <result column="lawyer_user_id" property="lawyerUserId" />
- <result column="lawyer_name" property="lawyerName" />
- <result column="lawyer_avatar" property="lawyerAvatar" />
- <result column="law_firm_name" property="lawFirmName" />
- <result column="overall_rating" property="overallRating" />
- <result column="review_content" property="reviewContent" />
- <result column="created_time" property="createdTime" />
- <result column="completed_time" property="completedTime" />
- </resultMap>
- <!-- 分页查询待评价列表(查询用户已完成但未评价的订单对应的律师信息) -->
- <select id="getPendingReviewList" resultMap="PendingReviewVoResultMap">
- SELECT
- lco.id AS order_id,
- lco.order_number,
- lco.lawyer_user_id,
- lu.name AS lawyer_name,
- lu.head_img AS lawyer_avatar,
- lf.firm_name AS law_firm_name,
- NULL AS overall_rating,
- NULL AS review_content,
- lco.end_time AS created_time,
- lco.end_time AS completed_time
- FROM lawyer_consultation_order lco
- LEFT JOIN lawyer_user lu ON lu.id = lco.lawyer_user_id AND lu.delete_flag = 0
- LEFT JOIN law_firm lf ON lf.id = lu.firm_id AND lf.delete_flag = 0
- LEFT JOIN lawyer_order_review orv ON orv.order_id = lco.id AND orv.delete_flag = 0
- WHERE lco.delete_flag = 0
- AND lco.order_status = 3
- AND lco.client_user_id = #{userId}
- AND orv.id IS NULL
- ORDER BY lco.end_time DESC
- </select>
- <!-- 统计律师的好评数(4.5-5分) -->
- <select id="getGoodReviewCountByLawyerUserId" resultType="java.lang.Integer">
- <![CDATA[
- SELECT COUNT(*)
- FROM lawyer_order_review
- WHERE lawyer_user_id = #{lawyerUserId}
- AND delete_flag = 0
- AND overall_rating IS NOT NULL
- AND overall_rating >= 4.5
- AND overall_rating <= 5
- ]]>
- </select>
- <!-- 统计律师的中评数(3-4分) -->
- <select id="getMediumReviewCountByLawyerUserId" resultType="java.lang.Integer">
- <![CDATA[
- SELECT COUNT(*)
- FROM lawyer_order_review
- WHERE lawyer_user_id = #{lawyerUserId}
- AND delete_flag = 0
- AND overall_rating IS NOT NULL
- AND overall_rating >= 3
- AND overall_rating < 4.5
- ]]>
- </select>
- <!-- 统计律师的差评数(0-2.5分,包含2.5) -->
- <select id="getBadReviewCountByLawyerUserId" resultType="java.lang.Integer">
- <![CDATA[
- SELECT COUNT(*)
- FROM lawyer_order_review
- WHERE lawyer_user_id = #{lawyerUserId}
- AND delete_flag = 0
- AND overall_rating IS NOT NULL
- AND overall_rating >= 0
- AND overall_rating < 3
- ]]>
- </select>
- <!-- 根据律师ID和类型分页查询评价列表(包含用户和律师信息) -->
- <select id="getReviewListByLawyerAndType" resultMap="OrderReviewVoResultMap">
- SELECT
- orv.id,
- orv.order_id,
- orv.order_number,
- orv.user_id,
- CASE
- WHEN orv.is_anonymous = 1 THEN '匿名用户'
- ELSE lu.user_name
- END AS user_name,
- CASE
- WHEN orv.is_anonymous = 1 THEN NULL
- ELSE lu.user_image
- END AS user_avatar,
- orv.lawyer_user_id,
- lu2.name AS lawyer_name,
- lu2.head_img AS lawyer_avatar,
- lf.firm_name AS law_firm_name,
- orv.overall_rating,
- orv.service_attitude_rating,
- orv.response_time_rating,
- orv.professional_ability_rating,
- orv.review_content,
- orv.is_anonymous,
- COALESCE((
- SELECT COUNT(1)
- FROM life_like_record llr_count
- WHERE CONVERT(llr_count.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr_count.type = '7'
- AND llr_count.delete_flag = 0
- ), 0) AS like_count,
- orv.comment_count,
- orv.review_images,
- CASE
- WHEN #{currentUserId} IS NOT NULL AND llr.id IS NOT NULL THEN 1
- ELSE 0
- END AS is_liked,
- orv.created_time
- FROM lawyer_order_review orv
- LEFT JOIN life_user lu ON lu.id = orv.user_id AND lu.delete_flag = 0
- LEFT JOIN lawyer_user lu2 ON lu2.id = orv.lawyer_user_id AND lu2.delete_flag = 0
- LEFT JOIN law_firm lf ON lf.id = lu2.firm_id AND lf.delete_flag = 0
- LEFT JOIN life_like_record llr ON CONVERT(llr.huifu_id, CHAR) = CONVERT(orv.id, CHAR)
- AND llr.type = '7'
- AND CONVERT(llr.dianzan_id, CHAR) = CONVERT(#{currentUserId}, CHAR)
- AND llr.delete_flag = 0
- WHERE orv.delete_flag = 0
- AND orv.lawyer_user_id = #{lawyerUserId}
- <if test="type != null">
- <choose>
- <when test="type == 1">
- <![CDATA[
- AND orv.overall_rating >= 4.5
- AND orv.overall_rating <= 5
- ]]>
- </when>
- <when test="type == 2">
- <![CDATA[
- AND orv.overall_rating >= 3
- AND orv.overall_rating < 4.5
- ]]>
- </when>
- <when test="type == 3">
- <![CDATA[
- AND orv.overall_rating >= 0
- AND orv.overall_rating < 3
- ]]>
- </when>
- <when test="type == 4">
- AND orv.review_images IS NOT NULL
- AND orv.review_images != ''
- AND TRIM(orv.review_images) != ''
- </when>
- </choose>
- </if>
- ORDER BY orv.created_time DESC
- </select>
- </mapper>
|