<?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, money2, money3 , 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="pageList" resultType="com.xiaopeng.account.model.vo.XpAppUserCouponListVo">
|
select a.*
|
from xp_app_user_coupon as a
|
where a.is_deleted = 0 and a.app_user_id = #{query.appUserId}
|
<if test="query.createTimeStart != null ">
|
a.create_time >= #{query.createTimeStart}
|
</if>
|
<if test="query.createTimeEnd != null ">
|
a.create_time <= #{query.createTimeEnd}
|
</if>
|
<if test="query.status != null">
|
and a.status = #{query.status}
|
</if>
|
<if test="query.couponType != null">
|
and a.coupon_type = #{query.couponType}
|
</if>
|
<if test="query.acticityIds != null">
|
and a.activity_id in
|
<foreach item="item" collection="query.acticityIds" separator="," open="(" close=")" index="">
|
#{item}
|
</foreach>
|
</if>
|
order by a.create_time desc
|
</select>
|
|
<select id="userCouponList" resultType="com.xiaopeng.account.model.vo.XpAppUserCouponListVo">
|
select t.*,t.status from (
|
SELECT id as couponId,
|
coupon_id as operationCouponId,
|
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 app_user_id = #{uid}
|
) 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>
|
|
|
<select id="getCouponReceiptRecord" resultType="com.xiaopeng.api.model.account.XpAppUserCoupon">
|
select * from xp_app_user_coupon
|
where activity_id = #{query.activityId}
|
<if test="null != query.startTime and '' != query.startTime and null != query.endTime and '' != query.endTime">
|
and create_time between #{query.startTime} and #{query.endTime}
|
</if>
|
<if test="null != query.appUserIds and query.appUserIds.size() > 0">
|
and app_user_id in
|
<foreach collection="query.appUserIds" item="item" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != query.status">
|
and status = #{query.status}
|
</if>
|
order by create_time desc
|
</select>
|
</mapper>
|