VipQuanyiMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.VipQuanyiMapper">
  6. <resultMap type="VipQuanyi" id="VipQuanyiResult">
  7. <result property="id" column="id" />
  8. <result property="vip" column="vip" />
  9. <result property="yhfangs" column="yhfangs" />
  10. <result property="yhnum" column="yhnum" />
  11. <result property="name" column="name" />
  12. <result property="shuoming" column="shuoming" />
  13. <result property="tiaojian" column="tiaojian" />
  14. <result property="num" column="num" />
  15. <result property="total" column="total" />
  16. <result property="validity" column="validity" />
  17. <result property="lqxz" column="lqxz" />
  18. <result property="state" column="state" />
  19. <result property="shId" column="sh_id" />
  20. <result property="spId" column="sp_id" />
  21. <result property="claimedCount" column="claimed_count" />
  22. <result property="createTime" column="create_time" />
  23. <result property="updateTime" column="update_time" />
  24. <result property="deleted" column="deleted" />
  25. <result property="language" column="language" />
  26. <result property="poster" column="poster" />
  27. <result property="type" column="type"/>
  28. <result property="merchantId" column="merchant_id"/>
  29. </resultMap>
  30. <sql id="selectVipQuanyiVo">
  31. select id, vip, yhfangs, yhnum, name, shuoming, tiaojian, num,
  32. total, validity, lqxz, state, sh_id, sp_id, claimed_count, create_time, update_time, deleted, language, poster,type,merchant_id
  33. from vip_quanyi
  34. </sql>
  35. <select id="userUnclaimedList" resultMap="VipQuanyiResult">
  36. select * from vip_quanyi v LEFT JOIN (SELECT
  37. user_id,
  38. quanyi_id,
  39. COUNT(*) AS receive_count
  40. FROM vip_user_quanyi
  41. WHERE deleted = '0' and user_id=#{userId}
  42. GROUP BY user_id, quanyi_id) u on v.id=u.quanyi_id where v.state='0' and v.deleted='0' and v.total> v.claimed_count and v.language=#{language} and (u.receive_count IS NULL OR v.lqxz > u.receive_count)
  43. <if test="mdId != null and mdId != ''">
  44. and (v.sh_id = #{mdId} or v.sh_id is null)
  45. </if>
  46. ORDER BY create_time
  47. </select>
  48. <select id="selectVipQuanyiList" parameterType="VipQuanyi" resultMap="VipQuanyiResult">
  49. <include refid="selectVipQuanyiVo"/>
  50. <where>
  51. deleted != '1'
  52. <if test="vip != null "> and vip = #{vip}</if>
  53. <if test="yhfangs != null "> and yhfangs = #{yhfangs}</if>
  54. <if test="yhnum != null "> and yhnum = #{yhnum}</if>
  55. <if test="name != null and name != ''"> and BINARY name like concat('%', #{name}, '%')</if>
  56. <if test="shuoming != null and shuoming != ''"> and shuoming = #{shuoming}</if>
  57. <if test="tiaojian != null "> and tiaojian = #{tiaojian}</if>
  58. <if test="num != null "> and num = #{num}</if>
  59. <if test="total != null and total!=''"> and total = #{total}</if>
  60. <if test="validity != null and validity!='' "> and validity = #{validity}</if>
  61. <if test="lqxz != null and lqxz !='' "> and lqxz = #{lqxz}</if>
  62. <if test="state != null and state != ''"> and state = #{state}</if>
  63. <if test="shId != null"> and sh_id = #{shId}</if>
  64. <if test="spId != null"> and sp_id = #{spId}</if>
  65. <if test="claimedCount != null and claimedCount !='' "> and claimed_count = #{claimedCount}</if>
  66. <if test="createTime != null and createTime !='' "> and create_time = #{createTime}</if>
  67. <if test="updateTime != null and updateTime != '' "> and update_time = #{updateTime}</if>
  68. <if test="deleted != null and deleted!=''"> and deleted = #{deleted}</if>
  69. <if test="language != null and language != ''"> and language = #{language}</if>
  70. <if test="poster != null and poster != ''"> and poster = #{poster}</if>
  71. <if test="type != null and type != ''"> and type = #{type}</if>
  72. <if test="merchantId != null and merchantId != ''"> and merchant_id = #{merchantId}</if>
  73. </where>
  74. order by id desc
  75. </select>
  76. <select id="selectVipQuanyiById" parameterType="Long" resultMap="VipQuanyiResult">
  77. <include refid="selectVipQuanyiVo"/>
  78. where id = #{id}
  79. </select>
  80. <insert id="insertVipQuanyi" parameterType="VipQuanyi" useGeneratedKeys="true" keyProperty="id">
  81. insert into vip_quanyi
  82. <trim prefix="(" suffix=")" suffixOverrides=",">
  83. <if test="vip != null">vip,</if>
  84. <if test="yhfangs != null">yhfangs,</if>
  85. <if test="yhnum != null">yhnum,</if>
  86. <if test="name != null and name != ''">name,</if>
  87. <if test="shuoming != null">shuoming,</if>
  88. <if test="tiaojian != null">tiaojian,</if>
  89. <if test="num != null">num,</if>
  90. <if test="total != null">total,</if>
  91. <if test="validity != null">validity,</if>
  92. <if test="lqxz != null">lqxz,</if>
  93. <if test="state != null">state,</if>
  94. <if test="shId != null">sh_id,</if>
  95. <if test="spId != null">sp_id,</if>
  96. <if test="claimedCount != null">claimed_count,</if>
  97. <if test="createTime != null">create_time,</if>
  98. <if test="updateTime != null">update_time,</if>
  99. <if test="deleted != null">deleted,</if>
  100. <if test="language != null and language != ''">language,</if>
  101. <if test="poster != null and poster != ''">poster,</if>
  102. <if test="type != null and type != ''">type,</if>
  103. <if test="merchantId != null and merchantId != ''">merchant_id,</if>
  104. </trim>
  105. <trim prefix="values (" suffix=")" suffixOverrides=",">
  106. <if test="vip != null">#{vip},</if>
  107. <if test="yhfangs != null">#{yhfangs},</if>
  108. <if test="yhnum != null">#{yhnum},</if>
  109. <if test="name != null and name != ''">#{name},</if>
  110. <if test="shuoming != null">#{shuoming},</if>
  111. <if test="tiaojian != null">#{tiaojian},</if>
  112. <if test="num != null">#{num},</if>
  113. <if test="total != null">#{total},</if>
  114. <if test="validity != null">#{validity},</if>
  115. <if test="lqxz != null">#{lqxz},</if>
  116. <if test="state != null">#{state},</if>
  117. <if test="shId != null">#{shId},</if>
  118. <if test="spId != null">#{spId},</if>
  119. <if test="claimedCount != null">#{claimedCount},</if>
  120. <if test="createTime != null">#{createTime},</if>
  121. <if test="updateTime != null">#{updateTime},</if>
  122. <if test="deleted != null">#{deleted},</if>
  123. <if test="language != null and language != ''">#{language},</if>
  124. <if test="poster != null and poster != ''">#{poster},</if>
  125. <if test="type != null and type != ''">#{type},</if>
  126. <if test="merchantId != null and merchantId != ''">#{merchantId},</if>
  127. </trim>
  128. </insert>
  129. <update id="updateVipQuanyi" parameterType="VipQuanyi">
  130. update vip_quanyi
  131. <trim prefix="SET" suffixOverrides=",">
  132. <if test="vip != null">vip = #{vip},</if>
  133. <if test="yhfangs != null">yhfangs = #{yhfangs},</if>
  134. <if test="yhnum != null">yhnum = #{yhnum},</if>
  135. <if test="name != null and name != ''">name = #{name},</if>
  136. <if test="shuoming != null">shuoming = #{shuoming},</if>
  137. <if test="tiaojian != null">tiaojian = #{tiaojian},</if>
  138. <if test="num != null">num = #{num},</if>
  139. <if test="total != null">total = #{total},</if>
  140. <if test="validity != null">validity = #{validity},</if>
  141. <if test="lqxz != null">lqxz = #{lqxz},</if>
  142. <if test="state != null">state = #{state},</if>
  143. <if test="shId != null">sh_id = #{shId},</if>
  144. <if test="spId != null">sp_id = #{spId},</if>
  145. <if test="claimedCount != null">claimed_count = #{claimedCount},</if>
  146. <if test="createTime != null">create_time = #{createTime},</if>
  147. <if test="updateTime != null">update_time = #{updateTime},</if>
  148. <if test="deleted != null">deleted = #{deleted},</if>
  149. <if test="language != null and language != ''">language = #{language},</if>
  150. <if test="poster != null and poster != ''">poster = #{poster},</if>
  151. <if test="type != null and type != ''">type = #{type},</if>
  152. <if test="merchantId != null and merchantId != ''">merchant_id = #{merchantId},</if>
  153. </trim>
  154. where id = #{id}
  155. </update>
  156. <update id="deleteVipQuanyiById" parameterType="Long">
  157. update vip_quanyi set deleted = '1' where id = #{id}
  158. </update>
  159. <update id="deleteVipQuanyiByIds" parameterType="String">
  160. update vip_quanyi set deleted = '1' where id in
  161. <foreach item="id" collection="array" open="(" separator="," close=")">
  162. #{id}
  163. </foreach>
  164. </update>
  165. </mapper>