陶杰
2024-10-22 c144a01a7fff4e9bd169eb9d03b6ea58bc8bafb6
src/main/resources/mapper/comment/FlowerCommentMapperCustom.xml
@@ -2,29 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mzl.flower.mapper.comment.FlowerCommentMapperCustom">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mzl.flower.entity.FlowerCommentDO">
        <id column="id" property="id" />
        <result column="deleted" property="deleted" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="order_id" property="orderId" />
        <result column="order_item_id" property="orderItemId" />
        <result column="customer_id" property="customerId" />
        <result column="customer_user_id" property="customerUserId" />
        <result column="supplier_id" property="supplierId" />
        <result column="supplier_user_id" property="supplierUserId" />
        <result column="flower_id" property="flowerId" />
        <result column="flower_cover" property="flowerCover" />
        <result column="comment_grade" property="commentGrade" />
        <result column="comment" property="comment" />
        <result column="comment_images" property="commentImages" />
        <result column="anonymity_falg" property="anonymityFalg" />
    </resultMap>
    <select id="getPage" resultType="com.mzl.flower.dto.response.comment.FlowerCommentVO">
        <include refid="baseSql" />
    </select>
@@ -35,7 +12,7 @@
        SELECT
            COALESCE(ROUND(SUM(c.comment_grade) / NULLIF(COUNT(1), 0), 1), 0) AS average_grade
        FROM t_flower_comment c
        WHERE c.deleted = false
        WHERE c.deleted = false and c.show_flag=0
          AND c.supplier_id = #{supplierId}
    </select>
@@ -47,12 +24,20 @@
            oi.flower_level,
            oi.flower_category,
            ci.name as customer_name,
            ci.cover as customer_cover
            ci.cover as customer_cover,
            o.order_no,
            sui.name as supplier_name,
            sui.contact_name as supplier_contact_name,
            sui.contact_tel as supplier_contact_tel
        from t_flower_comment c
        left join t_order_item oi
        on c.order_item_id=oi.id
        left join t_order o
        on c.order_id=o.id
        left join t_customer_info ci
        on c.customer_id=ci.id
        left join t_supplier_info sui
        on c.supplier_id =sui.id
        where c.deleted=false
        <if test="param.id != null and param.id != ''">
            and c.id = #{param.id}
@@ -72,6 +57,25 @@
        <if test="param.flowerId != null">
            and c.flower_id = #{param.flowerId}
        </if>
        <if test="param.showFlag != null">
            and c.show_flag = #{param.showFlag}
        </if>
        <if test="param.orderNo != null and param.orderNo != ''">
            and o.order_no like concat('%', #{param.orderNo}, '%')
        </if>
        <if test="param.flowerName != null and param.flowerName != ''">
            and oi.flower_name like concat('%', #{param.flowerName}, '%')
        </if>
        <if test="param.commentGrade != null">
            and c.comment_grade = #{param.commentGrade}
        </if>
        <if test="param.commentStartDate != null">
            and DATE_FORMAT(c.create_time, '%Y-%m-%d') &gt;= #{param.commentStartDate}
        </if>
        <if test="param.commentEndDate != null">
            and DATE_FORMAT(c.create_time, '%Y-%m-%d') &lt;= #{param.commentEndDate}
        </if>
        order by c.create_time desc