<?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.ruoyi.account.mapper.TAppCouponMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.TAppCoupon">
|
<id column="id" property="id" />
|
<result column="app_user_id" property="appUserId" />
|
<result column="coupon_id" property="couponId" />
|
<result column="end_time" property="endTime" />
|
<result column="ways_to_obtain" property="waysToObtain" />
|
<result column="redeem_points" property="redeemPoints" />
|
<result column="payment_amount" property="paymentAmount" />
|
<result column="payment_type" property="paymentType" />
|
<result column="serial_number" property="serialNumber" />
|
<result column="payment_time" property="paymentTime" />
|
<result column="status" property="status" />
|
<result column="create_time" property="createTime" />
|
<result column="del_flag" property="delFlag" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, app_user_id, coupon_id, end_time, ways_to_obtain, redeem_points, payment_amount, payment_type, serial_number, payment_time, status, create_time, del_flag
|
</sql>
|
<select id="pageList" resultType="com.ruoyi.account.api.vo.ExchangeRecordVO">
|
select t1.id,t1.app_user_id as appUserId, t1.coupon_id as couponId,
|
t1.end_time as endTime, t1.ways_to_obtain as waysToObtain,
|
t1.redeem_points as redeemPoints,
|
t1.payment_amount as paymentAmount,
|
t1.payment_type as paymentType,
|
t1.serial_number as serialNumber,
|
t1.payment_time as paymentTime,
|
t1.status,
|
t1.create_time AS createTime,
|
t1.del_flag AS delFlag,
|
t2.phone
|
from t_app_coupon t1
|
left join t_app_user t2 on t1.app_user_id = t2.id
|
<where>
|
and t1.coupon_id = #{req.couponId}
|
<if test="req.phone != null and req.phone != ''">
|
AND t2.phone LIKE concat('%',#{req.phone}, '%')
|
</if>
|
<if test="req.status != null and req.status = 1">
|
AND t1.status =1 and t1.end_time >= now()
|
</if>
|
<if test="req.status != null and req.status = 2">
|
AND t1.status =2
|
</if>
|
<if test="req.status != null and req.status = 3">
|
AND t1.status =1 and t1.end_time <= now() and t1.del_flag = 0
|
</if>
|
<if test="req.status != null and req.status = 4">
|
AND t1.del_flag = 0
|
</if>
|
</where>
|
ORDER BY t1.create_time DESC
|
</select>
|
<select id="couponList" resultType="com.ruoyi.other.api.vo.CouponListVOVO">
|
SELECT
|
t1.app_user_id AS appUserId,
|
t1.coupon_id AS couponId,
|
MAX(t1.end_time) AS endTime,
|
MAX(t1.create_time) AS createTime,
|
MAX(t1.status) AS status,
|
COUNT(*) AS couponCount
|
FROM
|
t_app_coupon t1
|
WHERE
|
t1.del_flag = 0
|
AND t1.app_user_id = #{userId}
|
AND t1.status = 1
|
and t1.end_time >= now()
|
GROUP BY
|
t1.app_user_id,
|
t1.coupon_id
|
</select>
|
|
</mapper>
|