<?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.fuxi.ws.data.dao.WGiftcardvipMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WGiftcardvip">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    <id column="GiftCardNo" jdbcType="VARCHAR" property="giftcardno" />
    <result column="GiftCardID" jdbcType="INTEGER" property="giftcardid" />
    <result column="Vipid" jdbcType="VARCHAR" property="vipid" />
    <result column="EmployeeID" jdbcType="VARCHAR" property="employeeid" />
    <result column="RecomVipid" jdbcType="VARCHAR" property="recomvipid" />
    <result column="GainValue" jdbcType="DECIMAL" property="gainvalue" />
    <result column="ActivePWD" jdbcType="VARCHAR" property="activepwd" />
    <result column="BuyTime" jdbcType="TIMESTAMP" property="buytime" />
    <result column="ActiveTime" jdbcType="TIMESTAMP" property="activetime" />
    <result column="Status" jdbcType="TINYINT" property="status" />
    <result column="WXPayNo" jdbcType="VARCHAR" property="wxpayno" />
    <result column="PrePayVIP" jdbcType="VARCHAR" property="prepayvip" />
    <result column="PrePayEmployee" jdbcType="VARCHAR" property="prepayemployee" />
    <result column="PayType" jdbcType="TINYINT" property="paytype" />
    <result column="PrePayTime" jdbcType="TIMESTAMP" property="prepaytime" />
    <result column="GuidGain" jdbcType="INTEGER" property="guidgain" />
    <result column="HandOut" jdbcType="TINYINT" property="handout" />
    <result column="PayNo" jdbcType="VARCHAR" property="payno" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    GiftCardNo, GiftCardID, Vipid, EmployeeID, RecomVipid, GainValue, ActivePWD, BuyTime, 
    ActiveTime, Status, WXPayNo, PrePayVIP, PrePayEmployee, PayType, PrePayTime, GuidGain, 
    HandOut, PayNo
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WGiftcardvipExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_GiftCardVip
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_GiftCardVip
    where GiftCardNo = #{giftcardno,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    delete from W_GiftCardVip
    where GiftCardNo = #{giftcardno,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WGiftcardvip">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    insert into W_GiftCardVip (GiftCardNo, GiftCardID, Vipid, 
      EmployeeID, RecomVipid, GainValue, 
      ActivePWD, BuyTime, ActiveTime, 
      Status, WXPayNo, PrePayVIP, 
      PrePayEmployee, PayType, PrePayTime, 
      GuidGain, HandOut, PayNo
      )
    values (#{giftcardno,jdbcType=VARCHAR}, #{giftcardid,jdbcType=INTEGER}, #{vipid,jdbcType=VARCHAR}, 
      #{employeeid,jdbcType=VARCHAR}, #{recomvipid,jdbcType=VARCHAR}, #{gainvalue,jdbcType=DECIMAL}, 
      #{activepwd,jdbcType=VARCHAR}, #{buytime,jdbcType=TIMESTAMP}, #{activetime,jdbcType=TIMESTAMP}, 
      #{status,jdbcType=TINYINT}, #{wxpayno,jdbcType=VARCHAR}, #{prepayvip,jdbcType=VARCHAR}, 
      #{prepayemployee,jdbcType=VARCHAR}, #{paytype,jdbcType=TINYINT}, #{prepaytime,jdbcType=TIMESTAMP}, 
      #{guidgain,jdbcType=INTEGER}, #{handout,jdbcType=TINYINT}, #{payno,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WGiftcardvip">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    insert into W_GiftCardVip
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="giftcardno != null">
        GiftCardNo,
      </if>
      <if test="giftcardid != null">
        GiftCardID,
      </if>
      <if test="vipid != null">
        Vipid,
      </if>
      <if test="employeeid != null">
        EmployeeID,
      </if>
      <if test="recomvipid != null">
        RecomVipid,
      </if>
      <if test="gainvalue != null">
        GainValue,
      </if>
      <if test="activepwd != null">
        ActivePWD,
      </if>
      <if test="buytime != null">
        BuyTime,
      </if>
      <if test="activetime != null">
        ActiveTime,
      </if>
      <if test="status != null">
        Status,
      </if>
      <if test="wxpayno != null">
        WXPayNo,
      </if>
      <if test="prepayvip != null">
        PrePayVIP,
      </if>
      <if test="prepayemployee != null">
        PrePayEmployee,
      </if>
      <if test="paytype != null">
        PayType,
      </if>
      <if test="prepaytime != null">
        PrePayTime,
      </if>
      <if test="guidgain != null">
        GuidGain,
      </if>
      <if test="handout != null">
        HandOut,
      </if>
      <if test="payno != null">
        PayNo,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="giftcardno != null">
        #{giftcardno,jdbcType=VARCHAR},
      </if>
      <if test="giftcardid != null">
        #{giftcardid,jdbcType=INTEGER},
      </if>
      <if test="vipid != null">
        #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="employeeid != null">
        #{employeeid,jdbcType=VARCHAR},
      </if>
      <if test="recomvipid != null">
        #{recomvipid,jdbcType=VARCHAR},
      </if>
      <if test="gainvalue != null">
        #{gainvalue,jdbcType=DECIMAL},
      </if>
      <if test="activepwd != null">
        #{activepwd,jdbcType=VARCHAR},
      </if>
      <if test="buytime != null">
        #{buytime,jdbcType=TIMESTAMP},
      </if>
      <if test="activetime != null">
        #{activetime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="wxpayno != null">
        #{wxpayno,jdbcType=VARCHAR},
      </if>
      <if test="prepayvip != null">
        #{prepayvip,jdbcType=VARCHAR},
      </if>
      <if test="prepayemployee != null">
        #{prepayemployee,jdbcType=VARCHAR},
      </if>
      <if test="paytype != null">
        #{paytype,jdbcType=TINYINT},
      </if>
      <if test="prepaytime != null">
        #{prepaytime,jdbcType=TIMESTAMP},
      </if>
      <if test="guidgain != null">
        #{guidgain,jdbcType=INTEGER},
      </if>
      <if test="handout != null">
        #{handout,jdbcType=TINYINT},
      </if>
      <if test="payno != null">
        #{payno,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WGiftcardvipExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    select count(*) from W_GiftCardVip
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WGiftcardvip">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    update W_GiftCardVip
    <set>
      <if test="giftcardid != null">
        GiftCardID = #{giftcardid,jdbcType=INTEGER},
      </if>
      <if test="vipid != null">
        Vipid = #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="employeeid != null">
        EmployeeID = #{employeeid,jdbcType=VARCHAR},
      </if>
      <if test="recomvipid != null">
        RecomVipid = #{recomvipid,jdbcType=VARCHAR},
      </if>
      <if test="gainvalue != null">
        GainValue = #{gainvalue,jdbcType=DECIMAL},
      </if>
      <if test="activepwd != null">
        ActivePWD = #{activepwd,jdbcType=VARCHAR},
      </if>
      <if test="buytime != null">
        BuyTime = #{buytime,jdbcType=TIMESTAMP},
      </if>
      <if test="activetime != null">
        ActiveTime = #{activetime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        Status = #{status,jdbcType=TINYINT},
      </if>
      <if test="wxpayno != null">
        WXPayNo = #{wxpayno,jdbcType=VARCHAR},
      </if>
      <if test="prepayvip != null">
        PrePayVIP = #{prepayvip,jdbcType=VARCHAR},
      </if>
      <if test="prepayemployee != null">
        PrePayEmployee = #{prepayemployee,jdbcType=VARCHAR},
      </if>
      <if test="paytype != null">
        PayType = #{paytype,jdbcType=TINYINT},
      </if>
      <if test="prepaytime != null">
        PrePayTime = #{prepaytime,jdbcType=TIMESTAMP},
      </if>
      <if test="guidgain != null">
        GuidGain = #{guidgain,jdbcType=INTEGER},
      </if>
      <if test="handout != null">
        HandOut = #{handout,jdbcType=TINYINT},
      </if>
      <if test="payno != null">
        PayNo = #{payno,jdbcType=VARCHAR},
      </if>
    </set>
    where GiftCardNo = #{giftcardno,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGiftcardvip">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Nov 28 12:38:50 CST 2018.
    -->
    update W_GiftCardVip
    set GiftCardID = #{giftcardid,jdbcType=INTEGER},
      Vipid = #{vipid,jdbcType=VARCHAR},
      EmployeeID = #{employeeid,jdbcType=VARCHAR},
      RecomVipid = #{recomvipid,jdbcType=VARCHAR},
      GainValue = #{gainvalue,jdbcType=DECIMAL},
      ActivePWD = #{activepwd,jdbcType=VARCHAR},
      BuyTime = #{buytime,jdbcType=TIMESTAMP},
      ActiveTime = #{activetime,jdbcType=TIMESTAMP},
      Status = #{status,jdbcType=TINYINT},
      WXPayNo = #{wxpayno,jdbcType=VARCHAR},
      PrePayVIP = #{prepayvip,jdbcType=VARCHAR},
      PrePayEmployee = #{prepayemployee,jdbcType=VARCHAR},
      PayType = #{paytype,jdbcType=TINYINT},
      PrePayTime = #{prepaytime,jdbcType=TIMESTAMP},
      GuidGain = #{guidgain,jdbcType=INTEGER},
      HandOut = #{handout,jdbcType=TINYINT},
      PayNo = #{payno,jdbcType=VARCHAR}
    where GiftCardNo = #{giftcardno,jdbcType=VARCHAR}
  </update>
  
  <select id="selectEffectiveCard" parameterType="com.fuxi.ws.data.entity.WGiftcardvipExample" resultMap="BaseResultMap">
    select * from W_GiftCardVip WITH (NOLOCK) where GiftCardID = #{giftcardid,jdbcType=INTEGER} and Status = 0 and (PrePayTime is null or PrePayTime<![CDATA[<=]]>dateadd(minute,-5,GETDATE()))
  </select>
</mapper>