|
@@ -245,28 +245,38 @@
|
|
|
and gt.`status` = 'validity'
|
|
and gt.`status` = 'validity'
|
|
|
and gt.sku_id = #{skuId}
|
|
and gt.sku_id = #{skuId}
|
|
|
inner join groups_relation gr on gr.groups_id = gt.id
|
|
inner join groups_relation gr on gr.groups_id = gt.id
|
|
|
- and gr.user_id = 0
|
|
|
|
|
- and gr.status = 'none'
|
|
|
|
|
|
|
+ and gr.status in ('none','locking')
|
|
|
|
|
+ and gr.num <= #{skuNum}
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectSpecialGroupsRelationAvailable" resultType="java.lang.Integer">
|
|
<select id="selectSpecialGroupsRelationAvailable" resultType="java.lang.Integer">
|
|
|
- select ifnull(sum(a1+(#{extractNum}-t1)),0) from
|
|
|
|
|
- (select gt.id,
|
|
|
|
|
- (select count(*)
|
|
|
|
|
- from groups_relation gr2
|
|
|
|
|
- where gr2.groups_id = gt.id
|
|
|
|
|
- and status = 'outside'
|
|
|
|
|
- and num <= #{maxNum}) t1,
|
|
|
|
|
- (select count(*)
|
|
|
|
|
- from groups_relation gr2
|
|
|
|
|
- where gr2.groups_id = gt.id
|
|
|
|
|
- and user_id = 0
|
|
|
|
|
- and status = 'outside'
|
|
|
|
|
- and num <= #{maxNum}) a1
|
|
|
|
|
- from account a
|
|
|
|
|
- inner join `groups_trips` gt on gt.account_id = a.id
|
|
|
|
|
- and gt.`status` = 'validity'
|
|
|
|
|
- and gt.sku_id = #{skuId}
|
|
|
|
|
- and a.expiry_time >= #{tenExpiry}) s where (t1=5 and a1=0) = 0
|
|
|
|
|
|
|
+ select ifnull(sum(a1 + (#{extractNum} - t1)), 0)
|
|
|
|
|
+ from (select gt.id,
|
|
|
|
|
+ (select count(*)
|
|
|
|
|
+ from groups_relation gr2
|
|
|
|
|
+ where gr2.groups_id = gt.id
|
|
|
|
|
+ and num > #{skuNum}
|
|
|
|
|
+ and num <= #{maxNum}) t1,
|
|
|
|
|
+ (select count(*)
|
|
|
|
|
+ from groups_relation gr2
|
|
|
|
|
+ where gr2.groups_id = gt.id
|
|
|
|
|
+ and num > #{skuNum}
|
|
|
|
|
+ and num <= #{maxNum}
|
|
|
|
|
+ and (gr2.user_id = 0 or gr2.status = 'locking')) a1
|
|
|
|
|
+ from account a
|
|
|
|
|
+ inner join `groups_trips` gt on gt.account_id = a.id
|
|
|
|
|
+ and gt.`status` = 'validity'
|
|
|
|
|
+ and gt.sku_id = #{skuId}
|
|
|
|
|
+ and a.expiry_time >= #{tenExpiry}) s
|
|
|
|
|
+ where (t1 = 5 and a1 = 0) = 0
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectNumWaitingGroups" resultType="java.lang.Integer">
|
|
|
|
|
+ select count(gr.id)
|
|
|
|
|
+ from `groups_trips` gt
|
|
|
|
|
+ inner join groups_relation gr on gr.groups_id = gt.id
|
|
|
|
|
+ and gt.`status` = 'waiting'
|
|
|
|
|
+ and gt.sku_id = #{skuId}
|
|
|
|
|
+ and gr.status = 'validity'
|
|
|
</select>
|
|
</select>
|
|
|
</mapper>
|
|
</mapper>
|