VipMapper.xml 7.4 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.mapper.VipMapper">
  4. <insert id="insertVipPackage">
  5. insert into auth_vip_package(originalPrice, price, duration, unit, addTime)
  6. VALUES (#{originalPrice}, #{price}, #{duration}, #{unit}, NOW());
  7. </insert>
  8. <insert id="insertVipService">
  9. insert into auth_vip_service(name)
  10. values (#{service})
  11. </insert>
  12. <insert id="insertVipHistory" keyColumn="id" keyProperty="id"
  13. parameterType="com.caimei.model.po.VipHistoryPo" useGeneratedKeys="true">
  14. insert into auth_vip_history (authUserId, packageId, duration, beginTime, endTime, payStatus, payWay, payType, price, services, payTime)
  15. values (#{authUserId}, #{packageId}, #{duration}, #{beginTime}, #{endTime}, #{payStatus}, #{payWay}, null, #{price}, #{services}, #{payTime})
  16. </insert>
  17. <insert id="insertAuthVipInfo">
  18. INSERT INTO auth_vip_user(authUserId, beginTime, endTime, delFlag, updateTime)
  19. VALUES (#{authUserId}, #{beginTime}, #{endTime}, #{delFlag}, #{updateTime})
  20. </insert>
  21. <update id="updateVipHistory">
  22. UPDATE auth_vip_history
  23. set payStatus=#{payStatus},
  24. payWay=#{payWay},
  25. payType=#{payType},
  26. duration=#{duration},
  27. beginTime=#{beginTime},
  28. endTime=#{endTime},
  29. price=#{price},
  30. services=#{services},
  31. payTime=#{payTime}
  32. WHERE id = #{id}
  33. </update>
  34. <update id="updateAuthVipInfo">
  35. UPDATE auth_vip_user set authUserId=#{authUserId}, beginTime=#{beginTime}, endTime=#{endTime}, delFlag=#{delFlag}, updateTime=#{updateTime}
  36. WHERE authUserId = #{authUserId}
  37. </update>
  38. <delete id="deleteVipPackages">
  39. delete from auth_vip_package;
  40. </delete>
  41. <delete id="deleteVipServices">
  42. delete from auth_vip_service;
  43. </delete>
  44. <select id="getVipPackageList" resultType="com.caimei.model.vo.VipPackageVo">
  45. select id, originalPrice, price, duration, unit from auth_vip_package;
  46. </select>
  47. <select id="getVipServiceList" resultType="com.caimei.model.vo.VipServiceVo">
  48. select id, name from auth_vip_service;
  49. </select>
  50. <select id="getVipEndTime" resultType="java.util.Date">
  51. select endTime from auth_vip_user where authUserId = #{authUserId} and endTime > now()
  52. </select>
  53. <select id="getVipPackageById" resultType="com.caimei.model.vo.VipPackageVo">
  54. select duration, unit, price
  55. from auth_vip_package
  56. where id = #{packageId}
  57. </select>
  58. <select id="getVipHistoryId" resultType="java.lang.Integer">
  59. SELECT id
  60. FROM auth_vip_history
  61. WHERE payStatus = 0
  62. AND authUserId = #{authUserId}
  63. AND packageId = #{packageId}
  64. ORDER BY id DESC
  65. LIMIT 1
  66. </select>
  67. <select id="getVipList" resultType="com.caimei.model.vo.VipListVo">
  68. select avu.id as vipUserId, avu.authUserId, u.name as shopName, u.shopType,
  69. u.loginAccount, u.mobile, u.linkMan, if(avu.endTime >NOW(),1,0) as vipStatus
  70. from auth_vip_user avu
  71. left join cm_brand_auth_user u on avu.authUserId = u.authUserId
  72. <where>
  73. <if test="shopName != null and shopName != ''">
  74. and u.name like concat('%',#{shopName},'%')
  75. </if>
  76. <if test="mobile != null and mobile != ''">
  77. and u.mobile like concat('%',#{mobile},'%')
  78. </if>
  79. <if test="linkMan != null and linkMan != ''">
  80. and u.linkMan like concat('%',#{linkMan},'%')
  81. </if>
  82. <if test="shopType != null">
  83. and u.shopType = #{shopType}
  84. </if>
  85. <if test="vipStatus != null">
  86. <if test="vipStatus == 0">
  87. and NOW() <![CDATA[>]]> avu.endTime
  88. </if>
  89. <if test="vipStatus == 1">
  90. and NOW() <![CDATA[<]]> avu.endTime and NOW() <![CDATA[>]]> avu.beginTime
  91. </if>
  92. </if>
  93. </where>
  94. order by avu.id desc
  95. </select>
  96. <select id="getVipHistoryList" resultType="com.caimei.model.vo.VipHistoryListVo">
  97. select id as historyId,duration,price,
  98. if(payWay=2,1,(case payType when 14 then 2
  99. when 13 or 15 then 3
  100. when 12 then 4
  101. when 17 then 5
  102. end )) as payWay,
  103. case when NOW() <![CDATA[>]]> endTime then 0
  104. when NOW() <![CDATA[<]]> beginTime then 2
  105. else 1 end
  106. as vipStatus,
  107. payTime,endTime,services
  108. from auth_vip_history
  109. where authUserId = #{authUserId}
  110. <if test="vipPackageId != null">
  111. and packageId = #{vipPackageId}
  112. </if>
  113. <if test="vipStatus != null">
  114. <if test="vipStatus == 0">
  115. and NOW() <![CDATA[>]]> endTime
  116. </if>
  117. <if test="vipStatus == 1">
  118. and NOW() <![CDATA[<]]> endTime and NOW() <![CDATA[>]]> beginTime
  119. </if>
  120. <if test="vipStatus == 2">
  121. and NOW() <![CDATA[<]]> beginTime
  122. </if>
  123. </if>
  124. <if test="payBeginTime != null and payBeginTime != ''">
  125. and payTime <![CDATA[>=]]> #{payBeginTime}
  126. </if>
  127. <if test="payEndTime != null and payEndTime != ''">
  128. and payTime <![CDATA[<=]]> #{payEndTime}
  129. </if>
  130. <if test="endBeginTime != null and endBeginTime != ''">
  131. and endTime <![CDATA[>=]]> #{endBeginTime}
  132. </if>
  133. <if test="endEndTime != null and endEndTime != ''">
  134. and endTime <![CDATA[<=]]> #{endEndTime}
  135. </if>
  136. order by payTime desc
  137. </select>
  138. <select id="getVipInfo" resultType="com.caimei.model.vo.VipInfoVo">
  139. select avu.id as vipUserId,
  140. u.authUserId,
  141. u.mobile,
  142. u.loginAccount,
  143. avu.endTime,
  144. if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus,
  145. 90 - timestampdiff(day, u.createTime, NOW()) as freeDayLeft,
  146. timestampdiff(day,NOW(),avu.endTime) as endDayLeft,
  147. date_add(u.createTime, interval 90 day) as freeEndTime
  148. from cm_brand_auth_user u
  149. left join auth_vip_user avu on u.authUserId = avu.authUserId
  150. where u.authUserId = #{authUserId}
  151. and u.userIdentity = 2
  152. and u.status = 1
  153. </select>
  154. <select id="getAuthVipInfo" resultType="com.caimei.model.po.AuthVipPo">
  155. SELECT id, authUserId as userId, beginTime, endTime, updateTime, delFlag
  156. FROM auth_vip_user
  157. WHERE authUserId = #{authUserId};
  158. </select>
  159. <select id="getBaseMenuList" resultType="com.caimei.model.po.SysMenu">
  160. select m.id, m.title,m.base_flag as baseFlag, m.move_flag as moveFlag, m.status
  161. from auth_menu m
  162. left join auth_role_menu arm on m.id = arm.menu_id
  163. where m.menu_type = 2
  164. and m.base_flag = 1
  165. and m.parent_id = 0
  166. </select>
  167. <select id="getUpMenuList" resultType="com.caimei.model.po.SysMenu">
  168. select m.id, m.title,m.base_flag as baseFlag, m.move_flag as moveFlag, m.status
  169. from auth_menu m
  170. where m.menu_type = 2
  171. and m.base_flag = 0
  172. and m.parent_id = 0
  173. </select>
  174. </mapper>