GroupsMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.GroupsMapper">
  4. <select id="selectGPTDoubleVerifyTrips" resultType="com.cyksj.model.entity.AccountDoubleVerifyRecord">
  5. select gt.*
  6. from (select a.account, t.account_id, t.id as groups_id, t.sku_id, t.num
  7. from account a
  8. inner join groups_trips t on a.id = t.account_id
  9. where t.sku_id in (select id from goods_don_sku where goods_id = #{goodsId} and status is true)
  10. and t.num > 1
  11. and a.api_secret = '') gt
  12. where gt.num =
  13. (select count(*) from groups_relation gr where gr.groups_id = gt.groups_id and gr.`status` = 'validity')
  14. and not EXISTS(select account_id
  15. from account_double_verify_record
  16. where account_id = gt.account_id
  17. and deleted is true)
  18. and DATE_SUB(now(), INTERVAL 3 day) >= (select max(update_time)
  19. from groups_relation gr
  20. where gr.groups_id = gt.groups_id
  21. and gr.`status` = 'validity')
  22. </select>
  23. <select id="getExpiryAccountGroups" resultType="com.cyksj.model.entity.GroupsTrips">
  24. select gt.id,
  25. gt.status,
  26. a.expiry_time
  27. from `groups_trips` gt inner join account a on a.id = gt.account_id
  28. where gt.sku_id in
  29. <foreach collection="list" item="item" open="(" separator="," close=")">
  30. #{item}
  31. </foreach>
  32. and gt.num != available_num
  33. and a.expiry_time &lt; #{nextBeginDay}
  34. and gt.num > 1
  35. </select>
  36. <select id="selectSameSpecItemGroupsByTime" resultType="java.lang.Long">
  37. select gt.id
  38. from `groups_trips` gt
  39. inner join account a on a.id = gt.account_id
  40. where gt.id != #{groupsId}
  41. and gt.sku_id = #{skuId}
  42. and gt.status = 'validity'
  43. and a.expiry_time >= #{expiryTime}
  44. and a.expiry_time &lt;= #{betDay}
  45. and (select count(*) from groups_relation gr where gr.status ='outside' and gr.groups_id = gt.id and
  46. gr.user_id != 0) &lt; #{extraNum}
  47. order by gt.available_num asc limit 1
  48. </select>
  49. <select id="selectSameSpecEmptyGroups" resultType="java.lang.Long">
  50. select id
  51. from `groups_trips`
  52. where status = 'waiting'
  53. and available_num > 0
  54. and sku_id = #{skuId}
  55. order by available_num asc limit 1
  56. </select>
  57. <select id="selectMidJourneySameSpecItemGroups" resultType="java.lang.Long">
  58. select gt.id
  59. from `groups_trips` gt
  60. inner join account a on a.id = gt.account_id
  61. where gt.id != #{groupsId}
  62. and gt.sku_id = #{skuId}
  63. and gt.status = 'validity'
  64. and a.expiry_time >= #{expiryTime}
  65. and gt.available_num > 0
  66. order by gt.available_num asc limit 1
  67. </select>
  68. <select id="countExpiredNum" resultType="java.lang.Integer">
  69. select count(ur.id)
  70. from user_ticket_cleared_record ur
  71. where ur.account_id = #{accountId}
  72. and deleted is true
  73. and source = 'self'
  74. </select>
  75. <select id="selectTicketGroups" resultType="com.cyksj.model.entity.GroupsTrips">
  76. select *
  77. from groups_trips gt
  78. where gt.sku_id = #{skuId}
  79. and gt.status = #{status}
  80. and gt.available_num > 0
  81. <if test="ip != null">
  82. and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = gt.id
  83. and gnr.user_id != 0) gr inner join
  84. order_don o on o.user_id = gr.user_id and o.relation_id = gr.id
  85. inner join order_don_location_relate ocr on ocr.order_id = o.id where ocr.ip = #{ip} limit 1)
  86. </if>
  87. and (available_parking_num = 0 or available_parking_num > (select count(*)
  88. from groups_relation gr
  89. where gr.groups_id = gt.id
  90. and gr.user_id != 0 and gr.num &lt;= #{maxNum}))
  91. <if test="filterAccountTime!=null">
  92. and gt.created_time > #{filterAccountTime}
  93. </if>
  94. order by available_num asc
  95. limit 1
  96. </select>
  97. <select id="selectCollegeStudentUserGptTicket" resultType="com.cyksj.model.entity.GroupsTrips">
  98. select gt.id
  99. from `groups_trips` gt
  100. where gt.sku_id = #{skuId}
  101. and gt.status = 'validity'
  102. and gt.available_num > 0
  103. order by rand() limit 1
  104. </select>
  105. <select id="selectRandomGroupsTripsBySkuId" resultType="java.lang.Long">
  106. select gt.id
  107. from `groups_trips` gt
  108. inner join account a on a.id = gt.account_id
  109. where gt.id != #{groupId}
  110. and gt.sku_id = #{skuId}
  111. and gt.status = 'validity'
  112. and gt.available_num > 0
  113. order by a.expiry_time asc limit 1
  114. </select>
  115. </mapper>