|
@@ -64,41 +64,46 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="couponCenterList" resultType="com.cyksj.model.views.CouponActiveView">
|
|
<select id="couponCenterList" resultType="com.cyksj.model.views.CouponActiveView">
|
|
|
- select ca.id,
|
|
|
|
|
- c.id as coupon_id,
|
|
|
|
|
- c.name,
|
|
|
|
|
- c.goods_type,
|
|
|
|
|
- c.type,
|
|
|
|
|
- c.reduce_money,
|
|
|
|
|
- c.discount,
|
|
|
|
|
- c.scope,
|
|
|
|
|
- c.goods_sku_ids,
|
|
|
|
|
- c.is_valid_time,
|
|
|
|
|
- c.valid_start_time,
|
|
|
|
|
- c.valid_end_time,
|
|
|
|
|
- c.valid_days,
|
|
|
|
|
- c.is_renew,
|
|
|
|
|
- ca.num,
|
|
|
|
|
- ca.`status`,
|
|
|
|
|
- ca.expiry_status,
|
|
|
|
|
- ca.remain_num,
|
|
|
|
|
- (case
|
|
|
|
|
- when ca.remain_num <= 0 then 'over'
|
|
|
|
|
- when cu.id is null then 'collecting'
|
|
|
|
|
- end) as couponStatus,
|
|
|
|
|
- (case
|
|
|
|
|
- when remain_num <= 0 then 2
|
|
|
|
|
- when cu.id is null then 0
|
|
|
|
|
- end) as `order`
|
|
|
|
|
- from coupon_active ca
|
|
|
|
|
- left join coupon c
|
|
|
|
|
- on c.id = ca.coupon_id
|
|
|
|
|
- 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 ca.expiry_status != 0
|
|
|
|
|
|
|
+ select *
|
|
|
|
|
+ from (select ca.id,
|
|
|
|
|
+ c.id as coupon_id,
|
|
|
|
|
+ c.name,
|
|
|
|
|
+ c.goods_type,
|
|
|
|
|
+ c.type,
|
|
|
|
|
+ c.reduce_money,
|
|
|
|
|
+ c.discount,
|
|
|
|
|
+ c.scope,
|
|
|
|
|
+ c.goods_sku_ids,
|
|
|
|
|
+ c.is_valid_time,
|
|
|
|
|
+ c.valid_start_time,
|
|
|
|
|
+ c.valid_end_time,
|
|
|
|
|
+ c.valid_days,
|
|
|
|
|
+ c.is_renew,
|
|
|
|
|
+ ca.num,
|
|
|
|
|
+ ca.`status`,
|
|
|
|
|
+ ca.expiry_status,
|
|
|
|
|
+ ca.remain_num,
|
|
|
|
|
+ (case
|
|
|
|
|
+ when ca.remain_num <= 0 then 'over'
|
|
|
|
|
+ when cu.id is null then 'collecting'
|
|
|
|
|
+ when cu.id is not null and cu.status != 'unused' then 'used'
|
|
|
|
|
+ when cu.id is not null and cu.status = 'unused' then 'received'
|
|
|
|
|
+ end) as couponStatus,
|
|
|
|
|
+ (case
|
|
|
|
|
+ when remain_num <= 0 then 2
|
|
|
|
|
+ when cu.id is null then 0
|
|
|
|
|
+ when cu.id is not null and cu.status = 'unused' then 1
|
|
|
|
|
+ end) as `order`
|
|
|
|
|
+ from coupon_active ca
|
|
|
|
|
+ left join coupon c
|
|
|
|
|
+ on c.id = ca.coupon_id
|
|
|
|
|
+ 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 ca.expiry_status != 0
|
|
|
and ca.`status` != 0
|
|
and ca.`status` != 0
|
|
|
- and cu.id is null
|
|
|
|
|
|
|
+ ) s
|
|
|
|
|
+ where couponStatus != 'used'
|
|
|
order by `order`
|
|
order by `order`
|
|
|
</select>
|
|
</select>
|
|
|
</mapper>
|
|
</mapper>
|