1
0

ApiCommentMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.api.dao.ApiCommentMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.CommentVo" id="commentMap">
  6. <result property="id" column="id"/>
  7. <result property="typeId" column="type_id"/>
  8. <result property="valueId" column="value_id"/>
  9. <result property="valueName" column="value_name"/>
  10. <result property="userId" column="user_id"/>
  11. <result property="orderId" column="order_id"/>
  12. <result property="productId" column="product_id"/>
  13. <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  14. <result property="status" column="status"/>
  15. <result property="content" column="content"/>
  16. <result property="addTime" column="add_time"/>
  17. <result property="evalLevel" column="eval_level"/>
  18. <result property="deliveryLevel" column="delivery_level"/>
  19. <result property="goodsLevel" column="goods_level"/>
  20. <result property="goodsLevel" column="goods_level"/>
  21. </resultMap>
  22. <select id="queryObject" resultMap="commentMap">
  23. select * from mall_comment where id = #{value}
  24. </select>
  25. <select id="queryList" resultMap="commentMap">
  26. select distinct c.* from mall_comment c
  27. LEFT JOIN mall_order o ON c.order_id = o.id
  28. <if test="hasPic != null and hasPic == 1">
  29. left join mall_comment_picture cp on cp.comment_id = c.id
  30. </if>
  31. where 1 = 1 and c.status = 1
  32. <if test="store_id != null and store_id != ''">
  33. AND o.store_id = #{store_id}
  34. </if>
  35. <if test="type_id != null and type_id != ''">
  36. and c.type_id = #{type_id}
  37. </if>
  38. <if test="value_id != null and value_id != ''">
  39. and c.value_id = #{value_id}
  40. </if>
  41. <if test="goods_id != null and goods_id != ''">
  42. and c.value_id = #{goods_id}
  43. </if>
  44. <if test="user_id != null and user_id != ''">
  45. and c.user_id = #{user_id}
  46. </if>
  47. <if test="hasPic != null and hasPic == 1">
  48. and cp.id is not null
  49. </if>
  50. <if test="orderId != null and orderId!= 0">
  51. and c.order_id = #{orderId}
  52. </if>
  53. <choose>
  54. <when test="sidx != null and sidx.trim() != ''">
  55. order by ${sidx} ${order}
  56. </when>
  57. <otherwise>
  58. order by id desc
  59. </otherwise>
  60. </choose>
  61. <if test="offset != null and limit != null">
  62. limit #{offset}, #{limit}
  63. </if>
  64. </select>
  65. <select id="queryTotal" resultType="int">
  66. select count(c.id)
  67. from mall_comment c
  68. LEFT JOIN mall_order o ON c.order_id = o.id
  69. <if test="hasPic != null and hasPic == 1">
  70. left join mall_comment_picture cp on cp.comment_id = c.id
  71. </if>
  72. where 1= 1 and c.status = 1
  73. <if test="store_id != null and store_id != ''">
  74. AND o.store_id = #{store_id}
  75. </if>
  76. <if test="type_id != null and type_id != ''">
  77. and c.type_id = #{type_id}
  78. </if>
  79. <if test="value_id != null and value_id != ''">
  80. and c.value_id = #{value_id}
  81. </if>
  82. <if test="goods_id != null and goods_id != ''">
  83. and c.value_id = #{goods_id}
  84. </if>
  85. <if test="user_id != null and user_id != ''">
  86. and c.user_id = #{user_id}
  87. </if>
  88. <if test="hasPic != null and hasPic == 1">
  89. and cp.id is not null
  90. </if>
  91. <if test="orderId != null and orderId!= 0">
  92. and c.order_id = #{orderId}
  93. </if>
  94. </select>
  95. <select id="queryhasPicTotal" resultType="int">
  96. select count(distinct c.id) from mall_comment c
  97. LEFT JOIN mall_order o ON c.order_id = o.id
  98. left join mall_comment_picture cp on cp.comment_id = c.id
  99. where 1= 1 and cp.id > 0 and c.status = 1
  100. <if test="store_id != null and store_id != ''">
  101. AND o.store_id = #{store_id}
  102. </if>
  103. <if test="type_id != null and type_id != ''">
  104. and c.type_id = #{type_id}
  105. </if>
  106. <if test="value_id != null and value_id != ''">
  107. and c.value_id = #{value_id}
  108. </if>
  109. <if test="orderId != null and orderId!= 0">
  110. and c.order_id = #{orderId}
  111. </if>
  112. </select>
  113. <insert id="save" parameterType="com.kmall.api.entity.CommentVo" useGeneratedKeys="true" keyProperty="id">
  114. insert into mall_comment(
  115. `type_id`,
  116. `value_id`,
  117. `value_name`,
  118. `user_id`,
  119. `order_id`,
  120. `product_id`,
  121. `goods_specification_name_value`,
  122. `status`,
  123. `content`,
  124. `add_time`,
  125. `eval_level`,
  126. `delivery_level`,
  127. `goods_level`)
  128. values(
  129. #{typeId},
  130. #{valueId},
  131. #{valueName},
  132. #{userId},
  133. #{orderId},
  134. #{productId},
  135. #{goodsSpecificationNameValue},
  136. #{status},
  137. #{content},
  138. #{addTime},
  139. #{evalLevel},
  140. #{deliveryLevel},
  141. #{goodsLevel})
  142. </insert>
  143. <update id="update" parameterType="com.kmall.api.entity.CommentVo">
  144. update mall_comment
  145. <set>
  146. <if test="typeId != null">`type_id` = #{typeId}, </if>
  147. <if test="valueId != null">`value_id` = #{valueId}, </if>
  148. <if test="valueName != null">`value_name` = #{valueName}, </if>
  149. <if test="userId != null">`user_id` = #{userId}, </if>
  150. <if test="orderId != null">`order_id` = #{orderId}, </if>
  151. <if test="productId != null">`product_id` = #{productId}, </if>
  152. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` = #{goodsSpecificationNameValue}, </if>
  153. <if test="status != null">`status` = #{status}, </if>
  154. <if test="content != null">`content` = #{content}, </if>
  155. <if test="evalLevel != null">`eval_level` = #{evalLevel}, </if>
  156. <if test="deliveryLevel != null">`delivery_level` = #{deliveryLevel}, </if>
  157. <if test="goodsLevel != null">`goods_level` = #{goodsLevel}</if>
  158. </set>
  159. where id = #{id}
  160. </update>
  161. <delete id="delete">
  162. delete from mall_comment where id = #{value}
  163. </delete>
  164. <delete id="deleteBatch">
  165. delete from mall_comment where id in
  166. <foreach item="id" collection="array" open="(" separator="," close=")">
  167. #{id}
  168. </foreach>
  169. </delete>
  170. <select id="queryOrderTotal" resultType="map">
  171. SELECT
  172. b.eval_level as evalLevel,
  173. sum(a.actual_price) as actualPrice,
  174. count(a.id) as orderNums
  175. FROM mall_order a
  176. LEFT JOIN mall_comment b ON a.id = b.order_id
  177. WHERE
  178. a.order_status = 301
  179. <if test="user_id != null">
  180. and a.user_id = #{user_id}
  181. </if>
  182. <if test="startDate!=null">
  183. AND a.add_time >= #{startDate}
  184. </if>
  185. <if test="endDate!=null">
  186. AND a.add_time <![CDATA[ < ]]> #{endDate}
  187. </if>
  188. GROUP BY b.eval_level
  189. </select>
  190. </mapper>