|
@@ -30,7 +30,7 @@
|
|
|
when cu.status = 'unused' then 0
|
|
when cu.status = 'unused' then 0
|
|
|
end) as orderby
|
|
end) as orderby
|
|
|
from `coupon_user` cu
|
|
from `coupon_user` cu
|
|
|
- left join `coupon` cp on cp.id = cu.coupon_id
|
|
|
|
|
|
|
+ left join `coupon` cp on cp.id = cu.coupon_id and cp.deleted and cp.is_available
|
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
|
left join `coupon_sku` ck on ck.coupon_id = cp.id
|
|
left join `coupon_sku` ck on ck.coupon_id = cp.id
|
|
|
<if test="goodsId != null">
|
|
<if test="goodsId != null">
|
|
@@ -64,7 +64,7 @@
|
|
|
cp.reduce_condition,
|
|
cp.reduce_condition,
|
|
|
cp.type
|
|
cp.type
|
|
|
from `coupon_user` cu
|
|
from `coupon_user` cu
|
|
|
- left join `coupon` cp on cp.id = cu.coupon_id
|
|
|
|
|
|
|
+ left join `coupon` cp on cp.id = cu.coupon_id and cp.deleted and cp.is_available
|
|
|
left join `coupon_sku` ck on ck.coupon_id = cp.id
|
|
left join `coupon_sku` ck on ck.coupon_id = cp.id
|
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
|
where
|
|
where
|
|
@@ -125,7 +125,7 @@
|
|
|
if(c.is_valid_time is true and c.valid_end_time < now(), false, true) as flag
|
|
if(c.is_valid_time is true and c.valid_end_time < now(), false, true) as flag
|
|
|
from coupon_active ca
|
|
from coupon_active ca
|
|
|
left join coupon c
|
|
left join coupon c
|
|
|
- on c.id = ca.coupon_id
|
|
|
|
|
|
|
+ on c.id = ca.coupon_id and c.deleted and c.is_available
|
|
|
left join coupon_user cu on cu.coupon_id = c.id and cu.user_id = #{userId}
|
|
left join coupon_user cu on cu.coupon_id = c.id and cu.user_id = #{userId}
|
|
|
where ca.deleted is true
|
|
where ca.deleted is true
|
|
|
and c.deleted is true
|
|
and c.deleted is true
|
|
@@ -171,7 +171,7 @@
|
|
|
when cu.status = 'unused' then 0
|
|
when cu.status = 'unused' then 0
|
|
|
end) as orderby
|
|
end) as orderby
|
|
|
from `coupon_user` cu
|
|
from `coupon_user` cu
|
|
|
- left join `coupon` c on c.id = cu.coupon_id
|
|
|
|
|
|
|
+ left join `coupon` c on c.id = cu.coupon_id and c.deleted and c.is_available
|
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
|
where cu.user_id = #{userId}
|
|
where cu.user_id = #{userId}
|
|
|
<if test="couponId !=null">
|
|
<if test="couponId !=null">
|
|
@@ -333,4 +333,17 @@
|
|
|
and c.use_scope != 'renew'
|
|
and c.use_scope != 'renew'
|
|
|
order by couponMoney desc limit 1
|
|
order by couponMoney desc limit 1
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAvailableCoupons" resultType="java.lang.Integer">
|
|
|
|
|
+ select count(1)
|
|
|
|
|
+ from (select coupon_id
|
|
|
|
|
+ from coupon_user
|
|
|
|
|
+ where user_id = #{userId}
|
|
|
|
|
+ and status = #{status}
|
|
|
|
|
+ and valid_start_time < #{now}
|
|
|
|
|
+ and valid_end_time > #{now}) cu
|
|
|
|
|
+ inner join coupon c on c.id = cu.coupon_id
|
|
|
|
|
+ where c.deleted
|
|
|
|
|
+ and c.is_available
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|