|
|
@@ -12,7 +12,6 @@
|
|
|
user_id = #{entity.userId},
|
|
|
account = null,
|
|
|
customer_service = null,
|
|
|
- verify_code = null,
|
|
|
password = null,
|
|
|
recharge_status = null,
|
|
|
send_time = null,
|
|
|
@@ -49,17 +48,24 @@
|
|
|
<select id="selectSimilarExpiredRelation" resultType="java.lang.Long">
|
|
|
select s.id
|
|
|
from (select gt.id, min(gr.expiry_time) minExpiryTime
|
|
|
- from `groups_trips` gt
|
|
|
- left join `groups_relation` gr on gr.groups_id = gt.id
|
|
|
- where gt.sku_id = #{skuId}
|
|
|
- and (gt.available_parking_num = 0 or (select count(*) from groups_relation gr where gr.groups_id = gt.id and gr.user_id != 0 and gr.num <= #{maxNum}) < gt.available_parking_num)
|
|
|
- and gt.available_num > 0
|
|
|
- and gt.status = 'validity'
|
|
|
- and gr.status = 'validity'
|
|
|
- and gr.user_id != 0
|
|
|
- and gr.expiry_time is not null
|
|
|
- group by gr.groups_id) s
|
|
|
+ from `groups_trips` gt
|
|
|
+ left join `groups_relation` gr on gr.groups_id = gt.id
|
|
|
+ where gt.sku_id = #{skuId}
|
|
|
+ and (gt.available_parking_num = 0 or (select count(*)
|
|
|
+ from groups_relation gr
|
|
|
+ where gr.groups_id = gt.id and gr.user_id != 0 and gr.num <=
|
|
|
+ #{maxNum}) < gt.available_parking_num) and gt.available_num > 0
|
|
|
+ and gt.status = 'validity'
|
|
|
+ and gr.status = 'validity'
|
|
|
+ and gr.user_id != 0
|
|
|
+ and gr.expiry_time is not null
|
|
|
+ group by gr.groups_id) s
|
|
|
where s.minExpiryTime >= #{minExpiryTime}
|
|
|
+ <if test="ip != null">
|
|
|
+ and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = s.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>
|
|
|
order by minExpiryTime desc limit 1
|
|
|
</select>
|
|
|
|
|
|
@@ -108,6 +114,11 @@
|
|
|
where groups_id = #{groupsId}
|
|
|
and user_id = 0
|
|
|
and status = 'none'
|
|
|
+ <if test="ip != null">
|
|
|
+ and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = groups_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>
|
|
|
order by rand() limit 1
|
|
|
</select>
|
|
|
|