ApiFootprintMapper.xml 6.2 KB

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