|
|
@@ -4,24 +4,26 @@
|
|
|
<mapper namespace="com.cyksj.mapper.manage.coupon.CouponUserMapper">
|
|
|
|
|
|
<select id="getAvailableCouponList" resultType="com.cyksj.model.views.CouponUserView">
|
|
|
- select distinct cu.id,
|
|
|
- cp.id as coupon_id,
|
|
|
- cp.name,
|
|
|
- cp.goods_type,
|
|
|
- cp.type,
|
|
|
- cp.goods_sku_ids,
|
|
|
- cp.discount,
|
|
|
- cp.reduce_money,
|
|
|
- cp.is_valid_time,
|
|
|
- cu.valid_start_time,
|
|
|
- cu.valid_end_time,
|
|
|
- cp.valid_days,
|
|
|
- cu.created_time,
|
|
|
- cp.is_renew,
|
|
|
- cu.status as couponUserStatus,
|
|
|
- if(ck.id is null, 0, 1) as 'isAvailable'
|
|
|
+ select * from (select distinct cu.id,
|
|
|
+ cp.id as coupon_id,
|
|
|
+ cp.name,
|
|
|
+ cp.goods_type,
|
|
|
+ cp.type,
|
|
|
+ cp.goods_sku_ids,
|
|
|
+ cp.discount,
|
|
|
+ cp.reduce_money,
|
|
|
+ cp.is_valid_time,
|
|
|
+ cu.valid_start_time,
|
|
|
+ cu.valid_end_time,
|
|
|
+ cp.valid_days,
|
|
|
+ cu.created_time,
|
|
|
+ cp.is_renew,
|
|
|
+ cu.status as couponUserStatus,
|
|
|
+ if(ck.id is null, 0, 1) as 'isAvailable',
|
|
|
+ if(ca.id is not null and ca.status = 0,false,true) flag
|
|
|
from `coupon_user` cu
|
|
|
left join `coupon` cp on cp.id = cu.coupon_id
|
|
|
+ left join `coupon_active` ca on ca.id = cu.coupon_active_id
|
|
|
left join `coupon_sku` ck on ck.coupon_id = cp.id
|
|
|
<if test="goodsId != null">
|
|
|
and ck.goods_id = #{goodsId}
|
|
|
@@ -32,15 +34,15 @@
|
|
|
<if test="isRenew != null and isRenew">
|
|
|
and cp.is_renew = #{isRenew}
|
|
|
</if>
|
|
|
- and cu.status != 'used'
|
|
|
where cu.user_id = #{userId}
|
|
|
and cu.channel != 'exCode'
|
|
|
+ and cu.valid_end_time > now()
|
|
|
<if test="couponId == null">
|
|
|
order by isAvailable desc
|
|
|
</if>
|
|
|
<if test="couponId != null">
|
|
|
order by case when cp.id = #{couponId} then 2 else isAvailable end desc
|
|
|
- </if>
|
|
|
+ </if>)s where flag = 1 and couponUserStatus != 'used'
|
|
|
</select>
|
|
|
|
|
|
<select id="countAvailableCouponList" resultType="java.lang.Integer">
|