CmSvipHistoryMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.caimei.modules.supervip.dao.CmSvipHistoryDao">
  4. <sql id="cmSvipHistoryColumns">
  5. a.id AS "id",
  6. a.userId AS "userId",
  7. a.packageId AS "packageId",
  8. a.beginTime AS "beginTime",
  9. a.endTime AS "endTime",
  10. a.payWay AS "payWay",
  11. a.payType AS "payType",
  12. a.price AS "price",
  13. a.userBeans AS "userBeans",
  14. a.payTime AS "payTime"
  15. </sql>
  16. <sql id="cmSvipHistoryJoins">
  17. </sql>
  18. <select id="get" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  19. SELECT
  20. <include refid="cmSvipHistoryColumns"/>
  21. FROM cm_svip_history a
  22. <include refid="cmSvipHistoryJoins"/>
  23. WHERE a.id = #{id}
  24. </select>
  25. <select id="findList" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  26. SELECT
  27. <include refid="cmSvipHistoryColumns"/>
  28. FROM cm_svip_history a
  29. <include refid="cmSvipHistoryJoins"/>
  30. <where>
  31. <if test="userId != null and userId != ''">
  32. AND a.userId = #{userId}
  33. </if>
  34. <if test="packageId != null and packageId != ''">
  35. AND a.packageId = #{packageId}
  36. </if>
  37. <if test="beginTime != null and beginTime != ''">
  38. AND a.beginTime = #{beginTime}
  39. </if>
  40. <if test="endTime != null and endTime != ''">
  41. AND a.endTime = #{endTime}
  42. </if>
  43. <if test="payTime != null and payTime != ''">
  44. AND a.payTime = #{payTime}
  45. </if>
  46. </where>
  47. <choose>
  48. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  49. ORDER BY ${page.orderBy}
  50. </when>
  51. <otherwise>
  52. </otherwise>
  53. </choose>
  54. </select>
  55. <select id="findAllList" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  56. SELECT
  57. <include refid="cmSvipHistoryColumns"/>
  58. FROM cm_svip_history a
  59. <include refid="cmSvipHistoryJoins"/>
  60. <where>
  61. </where>
  62. <choose>
  63. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  64. ORDER BY ${page.orderBy}
  65. </when>
  66. <otherwise>
  67. </otherwise>
  68. </choose>
  69. </select>
  70. <select id="findHistory" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  71. select
  72. cs.userId,
  73. cs.packageId,
  74. u.name as clubName,
  75. u.userName as linkMan,
  76. u.bindMobile as mobile,
  77. cs.beginTime,
  78. cs.price,
  79. cs.payWay,
  80. cs.payType,
  81. cs.userBeans,
  82. cs.payTime,
  83. cs.endTime
  84. from cm_svip_history cs
  85. LEFT JOIN club cb ON cs.userId = cb.userId
  86. left join user u on cs.userId = u.userID
  87. where cs.userId = #{userId}
  88. <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
  89. and (payTime between #{startPayTime} and #{endPayTime})
  90. </if>
  91. <if test="startEndTime != null and startEndTime != '' and endEndTime != null and endEndTime != ''">
  92. and (endTime between #{startEndTime} and #{endEndTime})
  93. </if>
  94. <if test="packageId != null">
  95. and packageId = #{packageId}
  96. </if>
  97. <if test='status == "1"'>
  98. and endTime > NOW()
  99. </if>
  100. <if test='status == "2"'>
  101. and NOW() > endTime
  102. </if>
  103. <if test='status == "3"'>
  104. and beginTime > NOW()
  105. </if>
  106. </select>
  107. <select id="findEndTime" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  108. select beginTime, endTime, updateTime
  109. from cm_svip_user
  110. where userId = #{userId}
  111. and endTime > now()
  112. </select>
  113. <select id="superFind" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  114. SELECT cb.name as clubName, cb.linkMan1 as linkMan, cb.contractMobile1 as mobile,
  115. cs.userId,cs.beginTime,cs.endTime,cs.packageId
  116. FROM cm_svip_history cs
  117. LEFT JOIN club cb ON cs.userId = cb.userId
  118. LEFT JOIN cm_svip_user cu ON cs.userId = cu.userId
  119. left join user u on cs.userId = u.userID
  120. <where>
  121. <if test="clubName != null and clubName != ''">
  122. and u.name like concat('%',#{clubName},'%')
  123. </if>
  124. <if test="linkMan != null and linkMan != ''">
  125. and u.username like concat('%',#{linkMan},'%')
  126. </if>
  127. <if test="mobile != null and mobile != ''">
  128. and u.bindMobile LIKE concat('%',#{mobile},'%')
  129. </if>
  130. <if test="startPayTime !=null and startPayTime != '' and endPayTime !=null and endPayTime!=''">
  131. and (payTime between #{startPayTime} and #{endPayTime})
  132. </if>
  133. <if test="startEndTime !=null and startEndTime!='' and endEndTime!=null and endEndTime!=''">
  134. and (cu.endTime between #{startEndTime} and #{endEndTime})
  135. </if>
  136. <if test="packageId !=null and packageId!=''">
  137. and packageId=#{packageId}
  138. </if>
  139. <if test='status == "1"'>
  140. and cu.endTime > NOW()
  141. </if>
  142. <if test='status == "2"'>
  143. and now() > cu.endTime
  144. </if>
  145. </where>
  146. group by cs.userId
  147. </select>
  148. <select id="findOutEndTime" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
  149. select beginTime, endTime, updateTime
  150. from cm_svip_user
  151. where userId = #{userId}
  152. and beginTime > now()
  153. </select>
  154. <select id="findPackage" resultType="java.lang.Integer">
  155. select id
  156. from cm_svip_package
  157. where duration = #{pac}
  158. </select>
  159. </mapper>