| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.cyksj.mapper.GroupsMapper">
- <select id="selectGPTDoubleVerifyTrips" resultType="com.cyksj.model.entity.AccountDoubleVerifyRecord">
- select gt.*
- from (select a.account, t.account_id, t.id as groups_id, t.sku_id, t.num
- from account a
- inner join groups_trips t on a.id = t.account_id
- where t.sku_id in (select id from goods_don_sku where goods_id = #{goodsId} and status is true)
- and t.num > 1
- and a.api_secret = '') gt
- where gt.num =
- (select count(*) from groups_relation gr where gr.groups_id = gt.groups_id and gr.`status` = 'validity')
- and not EXISTS(select account_id
- from account_double_verify_record
- where account_id = gt.account_id
- and deleted is true)
- and DATE_SUB(now(), INTERVAL 3 day) >= (select max(update_time)
- from groups_relation gr
- where gr.groups_id = gt.groups_id
- and gr.`status` = 'validity')
- </select>
- <select id="getExpiryAccountGroups" resultType="com.cyksj.model.entity.GroupsTrips">
- select gt.id,
- gt.status,
- a.expiry_time
- from `groups_trips` gt inner join account a on a.id = gt.account_id
- where gt.sku_id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and gt.num != available_num
- and a.expiry_time < #{nextBeginDay}
- and gt.num > 1
- </select>
- <select id="selectSameSpecItemGroupsByTime" resultType="java.lang.Long">
- select gt.id
- from `groups_trips` gt
- inner join account a on a.id = gt.account_id
- where gt.id != #{groupsId}
- and gt.sku_id = #{skuId}
- and gt.status = 'validity'
- and a.expiry_time >= #{expiryTime}
- and a.expiry_time <= #{betDay}
- and (select count(*) from groups_relation gr where gr.status ='outside' and gr.groups_id = gt.id and
- gr.user_id != 0) < #{extraNum}
- order by gt.available_num asc limit 1
- </select>
- <select id="selectSameSpecEmptyGroups" resultType="java.lang.Long">
- select id
- from `groups_trips`
- where status = 'waiting'
- and available_num > 0
- and sku_id = #{skuId}
- order by available_num asc limit 1
- </select>
- <select id="selectMidJourneySameSpecItemGroups" resultType="java.lang.Long">
- select gt.id
- from `groups_trips` gt
- inner join account a on a.id = gt.account_id
- where gt.id != #{groupsId}
- and gt.sku_id = #{skuId}
- and gt.status = 'validity'
- and a.expiry_time >= #{expiryTime}
- and gt.available_num > 0
- order by gt.available_num asc limit 1
- </select>
- <select id="countExpiredNum" resultType="java.lang.Integer">
- select count(ur.id)
- from user_ticket_cleared_record ur
- where ur.account_id = #{accountId}
- and deleted is true
- and source = 'self'
- </select>
- <select id="selectTicketGroups" resultType="com.cyksj.model.entity.GroupsTrips">
- select *
- from groups_trips gt
- where gt.sku_id = #{skuId}
- and gt.status = #{status}
- and gt.available_num > 0
- <if test="ip != null">
- and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = gt.id
- and gnr.user_id != 0) gr inner join
- order_don o on o.user_id = gr.user_id and o.relation_id = gr.id
- inner join order_don_location_relate ocr on ocr.order_id = o.id where ocr.ip = #{ip} limit 1)
- </if>
- and (available_parking_num = 0 or available_parking_num > (select count(*)
- from groups_relation gr
- where gr.groups_id = gt.id
- and gr.user_id != 0 and gr.num <= #{maxNum}))
- <if test="filterAccountTime!=null">
- and gt.created_time > #{filterAccountTime}
- </if>
- order by available_num asc
- limit 1
- </select>
- <select id="selectCollegeStudentUserGptTicket" resultType="com.cyksj.model.entity.GroupsTrips">
- select gt.id
- from `groups_trips` gt
- where gt.sku_id = #{skuId}
- and gt.status = 'validity'
- and gt.available_num > 0
- order by rand() limit 1
- </select>
- <select id="selectRandomGroupsTripsBySkuId" resultType="java.lang.Long">
- select gt.id
- from `groups_trips` gt
- inner join account a on a.id = gt.account_id
- where gt.id != #{groupId}
- and gt.sku_id = #{skuId}
- and gt.status = 'validity'
- and gt.available_num > 0
- order by a.expiry_time asc limit 1
- </select>
- </mapper>
|