<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.xiaopeng.account.mapper.XpAppUserCouponMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, full_money, money, expiration_time, status, coupon_type, app_user_id, coupon_id, activity_id, activity_type, is_deleted, create_time, update_time, create_by, update_by
|
</sql>
|
|
|
|
<select id="userCouponList" resultType="com.xiaopeng.account.model.vo.XpAppUserCouponListVo">
|
select t.*,t.status from (
|
SELECT id as couponId,
|
coupon_name as title,
|
money as discountAmount,
|
use_time as useTime,
|
create_time as createTime,
|
expiration_time as expireTime,
|
case
|
when status = 1 and now() >= expiration_time then 3 -- 包含等于的情况
|
when status = 1 and expiration_time > now() then 1
|
else status
|
end as `status`
|
FROM xp_app_user_coupon
|
WHERE phone = #{phone}
|
) as t
|
where 1=1
|
<if test="query.status != null">
|
and t.status = #{query.status}
|
</if>
|
|
<if test="query.status != null and query.status == 1">
|
order by t.expireTime ,t.discountAmount desc,t.createTime desc
|
</if>
|
<if test="query.status != null and query.status == 2">
|
order by t.useTime desc
|
</if>
|
<if test="query.status != null and query.status == 3">
|
order by t.expireTime desc
|
</if>
|
|
</select>
|
|
</mapper>
|