无关风月
2024-08-30 d33c34c76e74dbacf1bf7a57d7d3109e2bc54e68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?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.ruoyi.order.mapper.TOrderEvaluateMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.order.api.model.TOrderEvaluate">
        <id column="id" property="id" />
        <result column="order_type" property="orderType" />
        <result column="order_id" property="orderId" />
        <result column="app_user_id" property="appUserId" />
        <result column="app_user_car_id" property="appUserCarId" />
        <result column="mark" property="mark" />
        <result column="content" property="content" />
        <result column="img_url" property="imgUrl" />
        <result column="evaluation_response" property="evaluationResponse" />
        <result column="create_time" property="createTime" />
        <result column="response_time" property="responseTime" />
        <result column="del_flag" property="delFlag" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response, create_time, response_time, del_flag
    </sql>
    <select id="pageList" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO">
        select id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response,
               create_time, response_time, del_flag
        from t_order_evaluate where id in
        (select toe.id
        from t_order_evaluate toe
        left join t_order_evaluate_tag toet on toe.id = toet.order_evaluate_id
        <where>
            <if test="query.orderIds != null and query.orderIds.size()>0">
                and toe.order_id in
                <foreach collection="query.orderIds" item="orderId" open="(" separator="," close=")">
                    #{orderId}
                </foreach>
            </if>
            <if test="query.tagType != null">
                <choose>
                    <when test="query.tagType == 2">
                        AND toe.img_url IS NOT NULL
                    </when>
                    <when test="query.tagType == 3">
                        AND toe.mark &gt;= 4
                    </when>
                    <when test="query.tagType == 4">
                        AND toe.mark &lt;= 3
                    </when>
                    <when test="query.tagType == 5">
                        AND toet.evaluation_tag_id = #{query.tagId}
                    </when>
                </choose>
            </if>
            AND toe.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        </where>
        GROUP BY toe.id)
        <if test="query.tagType != null">
            <choose>
                <when test="query.tagType == 1">
                    ORDER BY create_time DESC
                </when>
                <otherwise>
                    ORDER BY
                    CASE
                    WHEN img_url IS NOT NULL THEN 0
                    ELSE 1
                    END ASC,
                    create_time DESC;
                </otherwise>
            </choose>
        </if>
        <if test="query.tagType == null">
            ORDER BY
            CASE
            WHEN img_url IS NOT NULL THEN 0
            ELSE 1
            END ASC,
            create_time DESC;
        </if>
    </select>
    <select id="getOrderEvaluateBySiteId" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO">
        select id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response,
               create_time, response_time, del_flag
        from t_order_evaluate
        where order_id in
        (select order_id
        from t_charging_order
        where site_id = #{siteId}
        and del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()})
    </select>
 
    
    
    <select id="getPageList" resultType="com.ruoyi.order.dto.GetOrderEvaluatePageListDTO">
        select
        CAST(a.id AS CHAR) as id,
        b.`code`,
        a.mark,
        b.site_id as siteId,
        b.app_user_id as appUserId,
        a.content,
        a.img_url as imgUrl,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime,
        a.evaluation_response as `recover`
        from t_order_evaluate a
        left join t_charging_order b on (a.order_id = b.id)
        where a.order_type = 1 and a.del_flag = 0
        <if test="null != query.code and '' != query.code">
            and b.`code` like CONCAT('%', #{query.code}, '%')
        </if>
        <if test="null != query.content and '' != query.content">
            and a.content like CONCAT('%', #{query.content}, '%')
        </if>
        <if test="null != query.evaluateType">
            and a.id in (select order_evaluate_id from t_order_evaluate_tag where evaluation_tag_id in
            <foreach collection="evaluationTagIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="null != query.siteId">
            and b.site_id = #{query.siteId}
        </if>
        order by a.create_time desc
    </select>
</mapper>