无关风月
2025-01-01 ca070436770f715572405880cfe548c02f639c73
ruoyi-system/src/main/resources/mapper/system/TOrderMapper.xml
@@ -149,5 +149,56 @@
    </select>
    <select id="listExport" resultType="com.ruoyi.system.domain.TOrder">
        SELECT
        t1.*,
        t2.NAME AS name,
        t2.phone AS phone,
        t2.avatar AS avatar,
        CONCAT( t2.NAME, ' ', t2.phone ) AS user_search,
        COALESCE ( t_course.course_name, t_information.information_name,'工作总结生成' ) AS good_name,
        COALESCE ( t_course.course_cover, t_information.information_cover ) AS cover,
        CONCAT(COALESCE ( t_course.course_name, t_information.information_name ),' ',t1.code) as orderSearch
        FROM
        t_order t1
        LEFT JOIN t_app_user t2 ON t1.user_id = t2.id
        LEFT JOIN ( SELECT id, course_name AS course_name,course_cover FROM t_course ) t_course ON t1.good_id = t_course.id
        AND t1.good_type = 1
        LEFT JOIN ( SELECT id, information_name AS information_name,information_cover FROM t_information ) t_information ON t1.good_id = t_information.id
        AND t1.good_type = 2
        LEFT JOIN ( SELECT id,'工作总结生成' AS recordsName,user_id FROM t_generated_records order by create_time DESC limit 1) t_generated_records ON t1.user_id = t_generated_records.user_id
        AND t1.good_type = 3
        <where>
            t1.is_delete = 0
            <if test="orderQuery.orderSearch != null and orderQuery.orderSearch != ''">
                AND ( t1.code LIKE concat('%',#{orderQuery.orderSearch},'%')
                or t_course.course_name LIKE concat('%',#{orderQuery.orderSearch},'%')
                or t_information.information_name LIKE concat('%',#{orderQuery.orderSearch},'%')
                or COALESCE ( t_course.course_name, t_information.information_name,'工作总结生成' ) LIKE concat('%',#{orderQuery.orderSearch},'%'))
            </if>
            <if test="orderQuery.userSearch != null and orderQuery.userSearch != ''">
                AND (t2.name LIKE concat('%',#{orderQuery.userSearch},'%') OR t2.phone LIKE concat('%',#{orderQuery.userSearch},'%'))
            </if>
            <if test="orderQuery.goodType != null ">
                AND t1.good_type = #{orderQuery.goodType}
            </if>
            <if test="orderQuery.paymentStatus != null">
                AND t1.payment_status = #{orderQuery.paymentStatus}
            </if>
            <if test="orderQuery.paymentType != null">
                AND t1.payment_type = #{orderQuery.paymentType}
            </if>
            <if test="orderQuery.createTime1 != null">
                AND DATE(t1.create_time) >= #{orderQuery.createTime1}
            </if>
            <if test="orderQuery.createTime2 != null">
                AND DATE(t1.create_time) &lt;= #{orderQuery.createTime2}
            </if>
            <if test="orderQuery.userId != null ">
                AND t1.user_id = #{orderQuery.userId}
            </if>
        </where>
        order by t1.create_time desc
    </select>
</mapper>