<?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.stylefeng.guns.modular.system.dao.CouponMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Coupon">
|
<id column="id" property="id" />
|
<result column="couponName" property="couponName" />
|
<result column="timeType" property="timeType" />
|
<result column="grantType" property="grantType" />
|
<result column="startTime" property="startTime" />
|
<result column="endTime" property="endTime" />
|
<result column="afterDay" property="afterDay" />
|
<result column="needClockIn" property="needClockIn" />
|
<result column="buyCourseId" property="buyCourseId" />
|
<result column="money" property="money" />
|
<result column="reduction" property="reduction" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, couponName, timeType, grantType, startTime, endTime, afterDay, needClockIn, buyCourseId, money, reduction
|
</sql>
|
|
|
<select id="couponReceive" resultType="com.stylefeng.guns.modular.system.vo.CouponReceiveVO">
|
select t1.*,t2.name as userName,t2.phone
|
from t_coupon_receive t1
|
left join t_user t2 on t1.userId = t2.id
|
<where>
|
<if test="req.id !=null ">
|
AND t1.couponId = #{req.id}
|
</if>
|
<if test="req.userName !=null and req.userName !='' ">
|
AND t2.name LIKE concat('%',#{req.userName},'%')
|
</if>
|
<if test="req.phone !=null and req.phone !='' ">
|
AND t2.phone LIKE concat('%',#{req.phone},'%')
|
</if>
|
<if test="req.receiveType !=null and req.receiveType == 1">
|
and (t1.receiveType = 1 or t1.receiveType = 2)
|
</if>
|
<if test="req.receiveType !=null and req.receiveType == 2">
|
and t1.receiveType = 3
|
</if>
|
<if test="req.state !=null and req.state == 1">
|
and t1.state = 1
|
</if>
|
<if test="req.state !=null and req.state == 2">
|
and t1.state = 2
|
</if>
|
<if test="req.state !=null and req.state == 3">
|
and (t1.endTime <= now() and t1.state!=2)
|
</if>
|
</where>
|
</select>
|
|
<select id="couponList" resultType="com.stylefeng.guns.modular.system.model.Coupon">
|
select t1.* from t_coupon t1
|
<where>
|
<if test="name !=null and name!='' ">
|
AND t1.couponName LIKE concat('%',#{name},'%')
|
</if>
|
<if test="time !=null">
|
and t1.timeType = #{time}
|
</if>
|
<if test="grant !=null">
|
and t1.grantType = #{grant}
|
</if>
|
and t1.isDelete = 0
|
</where>
|
order by t1.id desc
|
</select>
|
|
</mapper>
|