ApiFootprintMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.ApiFootprintMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.FootprintVo" id="footprintMap">
  6. <result property="id" column="id"/>
  7. <result property="user_id" column="user_id"/>
  8. <result property="goods_id" column="goods_id"/>
  9. <result property="add_time" column="add_time"/>
  10. <result property="name" column="name"/>
  11. <result property="list_pic_url" column="list_pic_url"/>
  12. <result property="goods_brief" column="goods_brief"/>
  13. <result property="retail_price" column="retail_price"/>
  14. <result property="referrer" column="referrer"/>
  15. <result property="nickname" column="nickname"/>
  16. <result property="avatar" column="avatar"/>
  17. <result property="storeId" column="storeId"/>
  18. </resultMap>
  19. <select id="queryObject" resultMap="footprintMap">
  20. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer from mall_footprint f where id = #{value}
  21. </select>
  22. <select id="queryList" resultMap="footprintMap">
  23. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer,
  24. g.name as name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief, psr.retail_price as
  25. retail_price,psr.store_id storeId
  26. from mall_footprint f
  27. <if test="maxFoot == true">
  28. left join mall_footprint max on f.goods_id = max.goods_id and f.user_id = max.user_id
  29. and max.add_time > f.add_time
  30. </if>
  31. left join mall_goods g on f.goods_id = g.id
  32. LEFT JOIN mall_product_store_rela psr ON psr.goods_id = g.id and g.merch_sn = psr.merch_sn
  33. <where>
  34. 1=1 and g.is_delete = 0 and g.is_on_sale = 1
  35. <if test="bizType == true">
  36. <if test="isStockShare == 1 and (checkCart != null and checkCart == '00')">
  37. and g.goods_number > 0
  38. </if>
  39. <if test="isStockShare == 0 and (checkCart != null and checkCart == '00')">
  40. and psr.stock_num > 0
  41. </if>
  42. <if test="checkCart != null and checkCart == '11'">
  43. and psr.stock_num > 0
  44. </if>
  45. </if>
  46. <if test="user_id != null">
  47. and f.user_id = #{user_id}
  48. </if>
  49. <if test="maxFoot == true">
  50. and max.id is null
  51. </if>
  52. <if test="bizType == true">
  53. <if test="checkCart != null and checkCart == '00'">
  54. and g.goods_biz_type = '00'
  55. </if>
  56. <if test="checkCart != null and checkCart == '11'">
  57. and g.goods_biz_type = '11'
  58. </if>
  59. <if test="checkCart != null and checkCart == '20'">
  60. and g.goods_biz_type not in ('02','10')
  61. </if>
  62. </if>
  63. <if test="store_id != null and store_id != ''">
  64. and psr.store_id = #{store_id}
  65. </if>
  66. </where>
  67. <choose>
  68. <when test="sidx != null and sidx.trim() != ''">
  69. order by ${sidx} ${order}
  70. </when>
  71. <otherwise>
  72. order by f.id desc
  73. </otherwise>
  74. </choose>
  75. <if test="offset != null and limit != null">
  76. limit #{offset}, #{limit}
  77. </if>
  78. </select>
  79. <select id="queryTotal" resultType="int">
  80. select count(*) from mall_footprint f
  81. <where>
  82. <if test="user_id != null">
  83. and f.user_id = #{user_id}
  84. </if>
  85. <if test="goods_id != null">
  86. and f.goods_id = #{goods_id}
  87. </if>
  88. <if test="referrer != null">
  89. and f.referrer = #{referrer}
  90. </if>
  91. </where>
  92. </select>
  93. <insert id="save" parameterType="com.kmall.api.entity.FootprintVo" useGeneratedKeys="true" keyProperty="id">
  94. insert into mall_footprint
  95. (
  96. `user_id`,
  97. `goods_id`,
  98. `add_time`,
  99. `referrer`
  100. )
  101. values
  102. (
  103. #{user_id},
  104. #{goods_id},
  105. #{add_time},
  106. #{referrer}
  107. )
  108. </insert>
  109. <update id="update" parameterType="com.kmall.api.entity.FootprintVo">
  110. update mall_footprint
  111. <set>
  112. <if test="user_id != null">`user_id` = #{user_id},</if>
  113. <if test="goods_id != null">`goods_id` = #{goods_id},</if>
  114. <if test="add_time != null">`add_time` = #{add_time}</if>
  115. <if test="referrer != null">`referrer` = #{referrer}</if>
  116. </set>
  117. where id = #{id}
  118. </update>
  119. <delete id="delete">
  120. delete from mall_footprint where id = #{value}
  121. </delete>
  122. <delete id="deleteByParam">
  123. delete from mall_footprint
  124. where 1 = 1
  125. <if test="userId != null">and `user_id` = #{userId},</if>
  126. <if test="goodsId != null">and `goods_id` = #{goodsId},</if>
  127. </delete>
  128. <delete id="deleteBatch">
  129. delete from mall_footprint where id in
  130. <foreach item="id" collection="array" open="(" separator="," close=")">
  131. #{id}
  132. </foreach>
  133. </delete>
  134. <select id="shareList" resultMap="footprintMap">
  135. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer,
  136. g.name as name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief,
  137. psr.retail_price as retail_price,
  138. u.nickname as nickname,u.avatar as avatar
  139. from mall_footprint f
  140. left join mall_goods g on f.goods_id = g.id
  141. left join mall_user u on u.id = f.user_id
  142. LEFT JOIN mall_product_store_rela psr ON psr.goods_id = g.id
  143. <where>
  144. u.id is not null
  145. <if test="user_id != null">
  146. and f.user_id = #{user_id}
  147. </if>
  148. <if test="referrer != null">
  149. and f.referrer = #{referrer}
  150. </if>
  151. <if test="store_id != null and store_id != ''">
  152. and psr.store_id = #{store_id}
  153. </if>
  154. </where>
  155. <choose>
  156. <when test="sidx != null and sidx.trim() != ''">
  157. order by ${sidx} ${order}
  158. </when>
  159. <otherwise>
  160. order by f.id desc
  161. </otherwise>
  162. </choose>
  163. <if test="offset != null and limit != null">
  164. limit #{offset}, #{limit}
  165. </if>
  166. </select>
  167. </mapper>