1
0

ApiFootprintMapper.xml 6.3 KB

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