|  | @@ -86,7 +86,7 @@
 | 
	
		
			
				|  |  |                          and ci.end_time_ < #{query.expiredTime} and ci.use_state_  = 'USABLE'
 | 
	
		
			
				|  |  |                      </when>
 | 
	
		
			
				|  |  |                      <when test="query.useState.code == 'USABLE'">
 | 
	
		
			
				|  |  | -                        and ci.end_time_ >= #{query.expiredTime} and ci.use_state_ = 'USABLE'
 | 
	
		
			
				|  |  | +                        and ci.end_time_ >= #{query.expiredTime} and ci.start_time_ <= #{query.expiredTime} and ci.use_state_ = 'USABLE'
 | 
	
		
			
				|  |  |                      </when>
 | 
	
		
			
				|  |  |                      <otherwise>
 | 
	
		
			
				|  |  |                          and ci.use_state_ = #{query.useState}
 | 
	
	
		
			
				|  | @@ -139,10 +139,10 @@
 | 
	
		
			
				|  |  |              <if test="record.timestamp != null">
 | 
	
		
			
				|  |  |                  <choose>
 | 
	
		
			
				|  |  |                      <when test="record.userState.code == 'USABLE'">
 | 
	
		
			
				|  |  | -                        AND t1.start_time_ <= #{record.timestamp} AND #{record.timestamp} <= t1.end_time_ AND (t1.order_no_ IS NULL OR t1.order_no_ = '')
 | 
	
		
			
				|  |  | +                        AND t1.start_time_ <= #{record.timestamp} AND #{record.timestamp} <= t1.end_time_ AND t1.use_state_ = 'USABLE'
 | 
	
		
			
				|  |  |                      </when>
 | 
	
		
			
				|  |  |                      <when test="record.userState.code == 'EXPIRED'">
 | 
	
		
			
				|  |  | -                        AND #{record.timestamp} >= t1.end_time_
 | 
	
		
			
				|  |  | +                        AND #{record.timestamp} >= t1.end_time_ AND t1.use_state_ = 'USABLE'
 | 
	
		
			
				|  |  |                      </when>
 | 
	
		
			
				|  |  |                      <when test="record.userState.code == 'USED'">
 | 
	
		
			
				|  |  |                          AND t1.order_no_ != ''
 |