IMProductCommentMapper.xml 6.0 KB
<?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.sibu.orderHelper.integral.web.dao.IMWebProductCommentDao">

	<sql id="IMProductComment_Column">
		pc.im_comment_id,pc.im_product_id,pc.comment_member_id,pc.comment_nickname,pc.comment_phone,
		pc.comment_head,pc.comment_level_name,pc.order_id,pc.order1_id,pc.content,pc.grade,pc.create_date,pc.buy_date,pc.status,pc.comment_img,pc.reply_remark,pc.reply_dt,pc.reply_username,
		pc.comment_img1,pc.comment_img2,p.name,p.erp_code,ims.name as store_name,p.total_comment_number as total_comment_number,p.total_comment_score as total_comment_score
	</sql>
    
   	<!-- 评论列表查询-->
   	<select id="listIMProductComment" parameterType="map" resultMap="listIMProductComment">
   	  select * from
	 <foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="tableName">
	 	select <include refid="IMProductComment_Column"></include>
	 	from ${tableName}  pc
	 	left join sibu_integralmall_base.im_product p on pc.im_product_id =p.im_product_id
		LEFT JOIN sibu_integralmall_base.im_product_supplier ps ON p.im_product_id =ps.product_id
		LEFT JOIN sibu_integralmall_base.im_supplier ims ON ims.id =ps.supplier_id
	 	where pc.delete_flag=1
	 	<if test="erpCode !=null and erpCode!=''">
	 		and p.erp_code=#{erpCode}
	 	</if>
	 	<if test="productName !=null and productName!=''">
	 		and p.name like concat('%',#{productName},'%')
	 	</if>
	 	<if test="commentNickname !=null and commentNickname!=''">
	 		and pc.comment_nickname=#{commentNickname}
	 	</if>
	 	<if test="grade !=null">
	 		and pc.grade=#{grade}
	 	</if>
	 	<if test="status!=null">
	 		and pc.status=#{status}
	 	</if>
	 	<if test="startCreateDt != null and startCreateDt !=''">
			<![CDATA[ and pc.create_date >= #{startCreateDt} ]]>
		</if>
		<if test="endCreateDt != null and endCreateDt !=''">
		 <![CDATA[  and pc.create_date <= #{endCreateDt}  ]]>
		</if>
		 <if test="storeName !=null and storeName!=''">
			 and ims.name=#{storeName}
		 </if>
		 <if test="contactPhone !=null and contactPhone!=''">
			 and pc.comment_phone=#{contactPhone}
		 </if>

	 </foreach>
	 as temp limit ${pageNow}, ${pageSize} 
   	</select>
   	
	<!-- 查询评论数量 -->
   	<select id="countIMProductComment" parameterType="map" resultType="int">
   		SELECT SUM(number) AS num  FROM 
   	 <foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="tableName">
	 	select count(1) as number
	 	from ${tableName}  pc 
	 	left join sibu_integralmall_base.im_product p on pc.im_product_id =p.im_product_id
		LEFT JOIN sibu_integralmall_base.im_product_supplier ps ON p.im_product_id =ps.product_id
		LEFT JOIN sibu_integralmall_base.im_supplier ims ON ims.id =ps.supplier_id
	 	where pc.delete_flag=1 
	 	<if test="erpCode !=null and erpCode!=''">
	 		and p.erp_code=#{erpCode}
	 	</if>
	 	<if test="productName !=null and productName!=''">
	 		and p.name like concat('%',#{productName},'%')
	 	</if>
	 	<if test="commentNickname !=null and commentNickname!=''">
	 		and pc.comment_nickname=#{commentNickname}
	 	</if>
	 	<if test="grade !=null">
	 		and pc.grade=#{grade}
	 	</if>
	 	<if test="status!=null">
	 		and pc.status=#{status}
	 	</if>
	 	<if test="startCreateDt != null and startCreateDt !=''">
			<![CDATA[ AND pc.create_date >= #{startCreateDt}  ]]>
		</if>
		<if test="endCreateDt != null and endCreateDt != ''">
		 <![CDATA[ and pc.create_date <= #{endCreateDt} ]]>
		</if>
		 <if test="storeName !=null and storeName!=''">
			 and ims.name=#{storeName}
		 </if>
		 <if test="contactPhone !=null and contactPhone!=''">
			 and pc.comment_phone=#{contactPhone}
		 </if>
	 </foreach>
	 	as temp
   	</select>
   	
   		<!-- 更新订单状态 -->
	<update id="updateVerifyStatus" parameterType="map">
		update ${commentProductTable} set status=#{status} where im_comment_id in
		 <foreach collection="ids" open="(" close=")" separator=" , " item="id">
		 	#{id}
		 </foreach>
	</update>
	
	<update id="addCommentReply" parameterType="map">
		update ${commentProductTable} set reply_remark = #{commentReply.replyRemark},reply_dt=NOW(),reply_username=#{commentReply.replyUsername} 
		where im_comment_id = #{commentReply.commentId} and im_product_id = #{commentReply.productId}
	</update>
   	<resultMap type="com.sibu.orderHelper.integral.model.ProductComment" id="listIMProductComment">
   		<id column="im_comment_id" property="imCommentId" />
        <result column="im_product_id" property="imProductId" />
        <result column="name" property="productName"></result>
        <result column="comment_member_id" property="commentMemberId" />
        <result column="comment_nickname" property="commentNickname" />
        <result column="comment_phone" property="commentPhone" />
        <result column="comment_head" property="commentHead" />
        <result column="comment_level_name" property="commentLevelName" />
        <result column="order1_id" property="order1Id" />
        <result column="order_id" property="orderId" />
        <result column="content" property="content" />
        <result column="grade" property="grade" />
        <result column="create_date" property="createDate" />
        <result column="buy_date" property="buyDate" />
        <result column="status" property="status" />
        <result column="comment_img" property="commentImg" />
        <result column="comment_img1" property="commentImg1" />
        <result column="comment_img2" property="commentImg2" />
        <result column="reply_remark" property="replyRemark" />
        <result column="reply_dt" property="replyDt" />
        <result column="reply_username" property="replyUsername" />
        <result column="erp_code" property="erpCode" />
		<result column="store_name" property="storeName" />
		<result column="total_comment_number" property="commentNumber" />
		<result column="total_comment_score" property="commentScore" />
		<result column="comment_phone" property="contactPhone" />
   	</resultMap>
</mapper>