AccountMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.cyksj.mapper.AccountMapper">
  4. <select id="getExpiredAccountView" resultType="com.cyksj.model.views.ExpiredAccountDataView">
  5. select gr.id as relationId,
  6. gd.title as platform,
  7. a.account,
  8. a.password,
  9. a.us_account,
  10. a.cn_account,
  11. concat(gdk.spec_val,'¥',cast(gdk.price/100 as decimal(10,2))) as 'specVal',
  12. gr.user_id,
  13. gr.account as userAccount,
  14. u.headimgurl as img,
  15. u.nickname,
  16. gr.start_time as payTime,
  17. gr.start_time,
  18. gr.expiry_time,
  19. gr.renew_status,
  20. gr.is_handle,
  21. gr.customer_service,
  22. if(cu.id is null,false,true) as isCorpWx
  23. from `account` a left join `groups_trips` gt on gt.account_id = a.id
  24. left join `groups_relation` gr on gr.groups_id = gt.id
  25. left join `goods_don_sku` gdk on gdk.id = gt.sku_id
  26. left join `goods_don` gd on gd.id = a.goods_id
  27. left join `user` u on gr.user_id = u.id
  28. left join (select id,unionid from `corp_user` where unionid != '') cu on cu.unionid = u.unionid
  29. <where>
  30. <if test="isCorpWx != null and isCorpWx">
  31. cu.id is not null
  32. </if>
  33. <if test="isCorpWx != null and !isCorpWx">
  34. cu.id is null
  35. </if>
  36. <if test="customerService != null and customerService != '' and customerService != 'waiting'">
  37. and gr.customer_service = #{customerService}
  38. </if>
  39. <if test="customerService == 'waiting'">
  40. and gr.customer_service is null
  41. </if>
  42. <if test="goodsId != null">
  43. and a.goods_id = #{goodsId}
  44. </if>
  45. <if test="skuId != null">
  46. and gdk.id = #{skuId}
  47. </if>
  48. <if test="account != null and account != ''">
  49. and a.account like '%${account}%'
  50. </if>
  51. <if test="renewStatus != null">
  52. and gr.renew_status is ${renewStatus}
  53. </if>
  54. <if test="handleStatus != null">
  55. and gr.is_handle is ${handleStatus}
  56. </if>
  57. <if test="cnAccount != null and cnAccount != ''">
  58. and a.cn_account = #{cnAccount}
  59. </if>
  60. <if test="usAccount != null and usAccount != ''">
  61. and a.us_account = #{usAccount}
  62. </if>
  63. <if test="userId != null">
  64. and gr.user_id = #{userId}
  65. </if>
  66. <if test="startTime != null">
  67. and gr.expiry_time >= #{startTime}
  68. </if>
  69. <if test="endTime != null">
  70. and gr.expiry_time &lt; #{endTime}
  71. </if>
  72. and gr.expiry_time > #{now}
  73. order by expiry_time
  74. </where>
  75. </select>
  76. <select id="getNoAppleOneOrderDon" resultType="com.cyksj.model.entity.OrderDon">
  77. select distinct od.* from `order_don` od
  78. where od.sku_id in
  79. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  80. #{item}
  81. </foreach>
  82. and od.status not in
  83. <foreach collection="noOrderStatus" item="item" open="(" separator="," close=")">
  84. #{item}
  85. </foreach>
  86. and od.created_time between #{yesZeroDate} and #{thisZeroDate}
  87. </select>
  88. <select id="getExpiredAccountViewNoPage" resultType="com.cyksj.model.excel.ExcelAccountData">
  89. select gr.id as relationId,
  90. gd.title as platform,
  91. a.account,
  92. a.password,
  93. a.us_account,
  94. a.cn_account,
  95. concat(gdk.spec_val,'¥',cast(gdk.price/100 as decimal(10,2))) as 'type',
  96. gr.user_id,
  97. gr.account as userAccount,
  98. u.headimgurl as img,
  99. u.nickname,
  100. gr.start_time as payTime,
  101. gr.expiry_time,
  102. gr.renew_status,
  103. gr.is_handle,
  104. gr.customer_service,
  105. if(cu.id is null,'未加入','已加入') as isCorpWx
  106. from `account` a left join `groups_trips` gt on gt.account_id = a.id
  107. left join `groups_relation` gr on gr.groups_id = gt.id
  108. left join `goods_don_sku` gdk on gdk.id = gt.sku_id
  109. left join `goods_don` gd on gd.id = a.goods_id
  110. left join `user` u on gr.user_id = u.id
  111. left join (select id,unionid from `corp_user` where unionid != '') cu on cu.unionid = u.unionid
  112. <where>
  113. <if test="isCorpWx != null and isCorpWx">
  114. cu.id is not null
  115. </if>
  116. <if test="isCorpWx != null and !isCorpWx">
  117. cu.id is null
  118. </if>
  119. <if test="customerService != null and customerService != '' and customerService != 'waiting'">
  120. and gr.customer_service = #{customerService}
  121. </if>
  122. <if test="customerService == 'waiting'">
  123. and gr.customer_service is null
  124. </if>
  125. <if test="goodsId != null">
  126. and a.goods_id = #{goodsId}
  127. </if>
  128. <if test="skuId != null">
  129. and gdk.id = #{skuId}
  130. </if>
  131. <if test="account != null and account != ''">
  132. and a.account like '%${account}%'
  133. </if>
  134. <if test="renewStatus != null">
  135. and gr.renew_status is ${renewStatus}
  136. </if>
  137. <if test="handleStatus != null">
  138. and gr.is_handle is ${handleStatus}
  139. </if>
  140. <if test="cnAccount != null and cnAccount != ''">
  141. and a.cn_account = #{cnAccount}
  142. </if>
  143. <if test="usAccount != null and usAccount != ''">
  144. and a.us_account = #{usAccount}
  145. </if>
  146. <if test="userId != null">
  147. and gr.user_id = #{userId}
  148. </if>
  149. <if test="startTime != null">
  150. and gr.expiry_time >= #{startTime}
  151. </if>
  152. <if test="endTime != null">
  153. and gr.expiry_time &lt; #{endTime}
  154. </if>
  155. and gr.expiry_time > #{now}
  156. order by expiry_time
  157. </where>
  158. </select>
  159. <select id="getExpiredAllAccount" resultType="com.cyksj.model.manage.views.AccountView">
  160. select a.id,
  161. a.account,
  162. a.password,
  163. a.goods_id,
  164. a.bank_card,
  165. a.start_time,
  166. a.expiry_time,
  167. a.amount,
  168. a.remark,
  169. a.cn_account,
  170. a.us_account,
  171. us_account,
  172. a.created_time,
  173. a.update_time,
  174. g.title
  175. from (select s.account_id, count(*) num
  176. from (select ur.account_id, ur.relation_id
  177. from user_ticket_cleared_record ur
  178. where ur.deleted is true
  179. group by ur.account_id, ur.relation_id) s
  180. group by s.account_id) s
  181. inner join account a on a.id = s.account_id
  182. left join groups_trips gt on gt.account_id = s.account_id
  183. left join goods_don g on g.id = a.goods_id
  184. where s.num >= gt.num
  185. </select>
  186. <select id="selectNetflixTempAccount" resultType="com.cyksj.model.entity.Account">
  187. select a.*
  188. from account a
  189. where goods_id = 1
  190. and type = 3
  191. and (select count(1)
  192. from netflix_temp_account_user ntu
  193. inner join groups_relation gr on gr.id = ntu.relation_id and ntu.user_id = gr.user_id
  194. where ntu.account_id = a.id) &lt; 20
  195. </select>
  196. </mapper>