IMProductCommentStatMapper.xml
6.1 KB
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
128
129
130
131
132
133
134
135
136
<?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.IMWebProductCommentStatDao">
<sql id="IMProductComment_Column">
pc.im_comment_id,pc.im_product_id as 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 store_nam
</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>,
round(p.total_comment_score/p.total_comment_number,2) as total_comment_score
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="supplierId !=null and supplierId!=''">
and ims.supplier_id=#{supplierId}
</if>
<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>
AND p.total_comment_number != 0
</foreach>
as temp group by im_product_id ORDER BY total_comment_score DESC limit ${pageNow}, ${pageSize}
</select>
<!-- 查询评论数量 -->
<select id="countIMProductComment" parameterType="map" resultType="int">
SELECT IFNULL(SUM(number),0) AS num FROM
<foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="tableName">
select IFNULL(count(DISTINCT(pc.im_product_id)),0) 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>
AND p.total_comment_number != 0
group by pc.im_product_id
</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" />
</resultMap>
</mapper>