|
|
@@ -49,6 +49,7 @@
|
|
|
</choose>
|
|
|
where cu.user_id = #{userId}
|
|
|
and cu.channel != 'exCode'
|
|
|
+ and cp.deleted and cp.status
|
|
|
and cu.valid_end_time > now()
|
|
|
<if test="couponId == null">
|
|
|
order by isAvailable desc,orderby,couponMoney desc,cu.valid_end_time asc
|
|
|
@@ -75,6 +76,7 @@
|
|
|
ck.sku_id = #{skuId}
|
|
|
</if>
|
|
|
and cu.user_id = #{userId}
|
|
|
+ and cp.deleted and cp.status
|
|
|
and cu.status = 'unused'
|
|
|
and cu.channel != 'exCode'
|
|
|
and cu.valid_start_time < now()
|
|
|
@@ -129,6 +131,7 @@
|
|
|
left join coupon_user cu on cu.coupon_id = c.id and cu.user_id = #{userId}
|
|
|
where ca.deleted is true
|
|
|
and c.deleted is true
|
|
|
+ and c.status
|
|
|
and cu.id is null
|
|
|
and ca.expiry_status != 0
|
|
|
and ca.`status` != 0
|
|
|
@@ -174,6 +177,7 @@
|
|
|
left join `coupon` c on c.id = cu.coupon_id
|
|
|
left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
|
where cu.user_id = #{userId}
|
|
|
+ and c.deleted and c.status
|
|
|
<if test="couponId !=null">
|
|
|
and cu.coupon_id = #{couponId}
|
|
|
</if>
|
|
|
@@ -333,4 +337,17 @@
|
|
|
and c.use_scope != 'renew'
|
|
|
order by couponMoney desc limit 1
|
|
|
</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.status
|
|
|
+ </select>
|
|
|
</mapper>
|