<?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.fzm.mall.server.admin.goods_center.mapper.GoodsCommentMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.goods_center.model.GoodsComment">
        <id column="id" property="id"/>
        <result column="sku_id" property="skuId"/>
        <result column="comment_id" property="commentId"/>
        <result column="goods_id" property="goodsId"/>
        <result column="oid" property="oid"/>
        <result column="uid" property="uid"/>
        <result column="evaluate" property="evaluate"/>
        <result column="content" property="content"/>
        <result column="images_json" property="imagesJson"/>
        <result column="video" property="video"/>
        <result column="express_evaluate" property="expressEvaluate"/>
        <result column="anonymous" property="anonymous"/>
        <result column="business_evaluate" property="businessEvaluate"/>
        <result column="like_num" property="likeNum"/>
        <result column="tip_off_num" property="tipOffNum"/>
        <result column="views" property="views"/>
        <result column="reply_content" property="replyContent"/>
        <result column="is_append" property="isAppend"/>
        <result column="is_valid" property="isValid"/>
        <result column="is_reply" property="isReply"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.goods_center.entity.vo.GoodsCommentVO">
        SELECT
        A.comment_id,A.goods_id,B.name AS goodsName,B.thumb,A.evaluate,A.reply_content,
        D.nick_name AS userName,A.anonymous,E.buyer_state,E.seller_state,A.create_time
        FROM
        goods_comment A
        LEFT JOIN
        goods_spu B
        ON
        A.goods_id = B.goods_id
        LEFT JOIN
        merchant C
        ON
        B.merchant_id = C.merchant_id
        LEFT JOIN
        user D
        ON
        A.uid = D.uid
        LEFT JOIN
        order_detail E
        ON
        A.oid = E.oid AND A.sku_id = E.sku_id
        <where>
            A.is_valid != 0
            AND
            C.merchant_id = #{merchantId}
            <if test="goodsId!=null and goodsId!=''">
                AND
                B.goods_id = #{goodsId}
            </if>
            <if test="goodsName!=null and goodsName!=''">
                AND
                B.name = #{goodsName}
            </if>
            <if test="evaluateType!=null">
                AND
                A.evaluate = #{evaluateType}
            </if>
            <if test="replyStatus!=null">
                AND
                E.seller_state = #{replyStatus}
            </if>
        </where>
        ORDER BY
        A.create_time
        DESC
    </select>

</mapper>
