<?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.WGetcashMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WGetcash">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    <id column="GetCashID" jdbcType="BIGINT" property="getcashid" />
    <result column="GetCashNo" jdbcType="VARCHAR" property="getcashno" />
    <result column="VIPID" jdbcType="VARCHAR" property="vipid" />
    <result column="VIPName" jdbcType="NVARCHAR" property="vipname" />
    <result column="CashNum" jdbcType="DECIMAL" property="cashnum" />
    <result column="CashWay" jdbcType="TINYINT" property="cashway" />
    <result column="CashNo" jdbcType="VARCHAR" property="cashno" />
    <result column="CorpBank" jdbcType="NVARCHAR" property="corpbank" />
    <result column="CorpBankNo" jdbcType="VARCHAR" property="corpbankno" />
    <result column="VipBank" jdbcType="NVARCHAR" property="vipbank" />
    <result column="VipBankNo" jdbcType="VARCHAR" property="vipbankno" />
    <result column="HoldName" jdbcType="NVARCHAR" property="holdname" />
    <result column="Created" jdbcType="TIMESTAMP" property="created" />
    <result column="Confirmer" jdbcType="VARCHAR" property="confirmer" />
    <result column="Confirmed" jdbcType="TIMESTAMP" property="confirmed" />
    <result column="Status" jdbcType="TINYINT" property="status" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    <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 Thu May 07 15:36:20 CST 2015.
    -->
    GetCashID, GetCashNo, VIPID, VIPName, CashNum, CashWay, CashNo, CorpBank, CorpBankNo, 
    VipBank, VipBankNo, HoldName, Created, Confirmer, Confirmed, Status
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WGetcashExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_GetCash
    <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.Long" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_GetCash
    where GetCashID = #{getcashid,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    delete from W_GetCash
    where GetCashID = #{getcashid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WGetcash">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    insert into W_GetCash (GetCashID, GetCashNo, VIPID, 
      VIPName, CashNum, CashWay, 
      CashNo, CorpBank, CorpBankNo, 
      VipBank, VipBankNo, HoldName, 
      Created, Confirmer, Confirmed, 
      Status)
    values (#{getcashid,jdbcType=BIGINT}, #{getcashno,jdbcType=VARCHAR}, #{vipid,jdbcType=VARCHAR}, 
      #{vipname,jdbcType=NVARCHAR}, #{cashnum,jdbcType=DECIMAL}, #{cashway,jdbcType=TINYINT}, 
      #{cashno,jdbcType=VARCHAR}, #{corpbank,jdbcType=NVARCHAR}, #{corpbankno,jdbcType=VARCHAR}, 
      #{vipbank,jdbcType=NVARCHAR}, #{vipbankno,jdbcType=VARCHAR}, #{holdname,jdbcType=NVARCHAR}, 
      #{created,jdbcType=TIMESTAMP}, #{confirmer,jdbcType=VARCHAR}, #{confirmed,jdbcType=TIMESTAMP}, 
      #{status,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WGetcash">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    insert into W_GetCash
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="getcashid != null">
        GetCashID,
      </if>
      <if test="getcashno != null">
        GetCashNo,
      </if>
      <if test="vipid != null">
        VIPID,
      </if>
      <if test="vipname != null">
        VIPName,
      </if>
      <if test="cashnum != null">
        CashNum,
      </if>
      <if test="cashway != null">
        CashWay,
      </if>
      <if test="cashno != null">
        CashNo,
      </if>
      <if test="corpbank != null">
        CorpBank,
      </if>
      <if test="corpbankno != null">
        CorpBankNo,
      </if>
      <if test="vipbank != null">
        VipBank,
      </if>
      <if test="vipbankno != null">
        VipBankNo,
      </if>
      <if test="holdname != null">
        HoldName,
      </if>
      <if test="created != null">
        Created,
      </if>
      <if test="confirmer != null">
        Confirmer,
      </if>
      <if test="confirmed != null">
        Confirmed,
      </if>
      <if test="status != null">
        Status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="getcashid != null">
        #{getcashid,jdbcType=BIGINT},
      </if>
      <if test="getcashno != null">
        #{getcashno,jdbcType=VARCHAR},
      </if>
      <if test="vipid != null">
        #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="vipname != null">
        #{vipname,jdbcType=NVARCHAR},
      </if>
      <if test="cashnum != null">
        #{cashnum,jdbcType=DECIMAL},
      </if>
      <if test="cashway != null">
        #{cashway,jdbcType=TINYINT},
      </if>
      <if test="cashno != null">
        #{cashno,jdbcType=VARCHAR},
      </if>
      <if test="corpbank != null">
        #{corpbank,jdbcType=NVARCHAR},
      </if>
      <if test="corpbankno != null">
        #{corpbankno,jdbcType=VARCHAR},
      </if>
      <if test="vipbank != null">
        #{vipbank,jdbcType=NVARCHAR},
      </if>
      <if test="vipbankno != null">
        #{vipbankno,jdbcType=VARCHAR},
      </if>
      <if test="holdname != null">
        #{holdname,jdbcType=NVARCHAR},
      </if>
      <if test="created != null">
        #{created,jdbcType=TIMESTAMP},
      </if>
      <if test="confirmer != null">
        #{confirmer,jdbcType=VARCHAR},
      </if>
      <if test="confirmed != null">
        #{confirmed,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WGetcashExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    select count(*) from W_GetCash
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WGetcash">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    update W_GetCash
    <set>
      <if test="getcashno != null">
        GetCashNo = #{getcashno,jdbcType=VARCHAR},
      </if>
      <if test="vipid != null">
        VIPID = #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="vipname != null">
        VIPName = #{vipname,jdbcType=NVARCHAR},
      </if>
      <if test="cashnum != null">
        CashNum = #{cashnum,jdbcType=DECIMAL},
      </if>
      <if test="cashway != null">
        CashWay = #{cashway,jdbcType=TINYINT},
      </if>
      <if test="cashno != null">
        CashNo = #{cashno,jdbcType=VARCHAR},
      </if>
      <if test="corpbank != null">
        CorpBank = #{corpbank,jdbcType=NVARCHAR},
      </if>
      <if test="corpbankno != null">
        CorpBankNo = #{corpbankno,jdbcType=VARCHAR},
      </if>
      <if test="vipbank != null">
        VipBank = #{vipbank,jdbcType=NVARCHAR},
      </if>
      <if test="vipbankno != null">
        VipBankNo = #{vipbankno,jdbcType=VARCHAR},
      </if>
      <if test="holdname != null">
        HoldName = #{holdname,jdbcType=NVARCHAR},
      </if>
      <if test="created != null">
        Created = #{created,jdbcType=TIMESTAMP},
      </if>
      <if test="confirmer != null">
        Confirmer = #{confirmer,jdbcType=VARCHAR},
      </if>
      <if test="confirmed != null">
        Confirmed = #{confirmed,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        Status = #{status,jdbcType=TINYINT},
      </if>
    </set>
    where GetCashID = #{getcashid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGetcash">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu May 07 15:36:20 CST 2015.
    -->
    update W_GetCash
    set GetCashNo = #{getcashno,jdbcType=VARCHAR},
      VIPID = #{vipid,jdbcType=VARCHAR},
      VIPName = #{vipname,jdbcType=NVARCHAR},
      CashNum = #{cashnum,jdbcType=DECIMAL},
      CashWay = #{cashway,jdbcType=TINYINT},
      CashNo = #{cashno,jdbcType=VARCHAR},
      CorpBank = #{corpbank,jdbcType=NVARCHAR},
      CorpBankNo = #{corpbankno,jdbcType=VARCHAR},
      VipBank = #{vipbank,jdbcType=NVARCHAR},
      VipBankNo = #{vipbankno,jdbcType=VARCHAR},
      HoldName = #{holdname,jdbcType=NVARCHAR},
      Created = #{created,jdbcType=TIMESTAMP},
      Confirmer = #{confirmer,jdbcType=VARCHAR},
      Confirmed = #{confirmed,jdbcType=TIMESTAMP},
      Status = #{status,jdbcType=TINYINT}
    where GetCashID = #{getcashid,jdbcType=BIGINT}
  </update>

	<!-- 我的钱包:已申请 -->
	<select id="usableApply" resultType="java.lang.String">
		select SUM(CashNum)CashNum
		from
		W_GetCash
		where VIPID=#{vipid} and
		<!-- ( -->
		Status='0'
		<!-- or Status='1') -->
	</select>

	<!-- 我的钱包:状态不等于"已拒绝"和"已取消" -->
	<select id="noRefuseApply" resultType="java.lang.String">
		<![CDATA[
			select SUM(CashNum)CashNum from
			W_GetCash
			where VIPID=#{vipid} and Status<>'2' and Status<>'3'
		]]>
	</select>

	<!-- 我的钱包:异常的提现单据 -->
	<select id="exceptionApply" resultType="java.lang.Double">
		select SUM(CashNum)
		CashNum from W_GetCash where
		(Created between
		#{ receiveTime } and
		#{ nowTime } ) and Status='1' and VIPID=#{ vipid }
	</select>

	<!-- 分销商提现 -->
	<select id="selectGetCash" parameterType="java.util.HashMap" resultType="java.util.LinkedHashMap">
		SELECT a.GetCashID, b.PhotoUrl,b.LineNickname,b.wxid, 
		case when b.VIP is not null and b.VIP <![CDATA[<>]]>'' then b.VIP + '<![CDATA[<br/>]]>' else '' end + b.MobilePhone as NickName, 
		a.HoldName,a.VipBankNo,a.VipBank, a.CashNo, a.CashNum,
		case a.Status when 0 then '未处理'
		when 1 then '已处理' when 2 then '已拒绝' end as
		StatusName,a.Status,case when a.Created is null then '' else 
		convert(varchar(10),a.Created,121) + '<![CDATA[<br/>]]>'
		+ convert(varchar(8),a.Created,108) end as Created,
		case when a.Confirmed is null then ''  else 
		convert(varchar(10),a.Confirmed,121) + '<![CDATA[<br/>]]>'
		+ convert(varchar(8),a.Confirmed,108) end as Confirmed
		FROM
		W_GetCash AS a INNER JOIN
		VIP AS b ON a.VIPID = b.VIPID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		order by a.GetCashID desc
	</select>

	<!-- 分销商提现 -->
	<select id="selectGetCashByID" parameterType="java.lang.Long" resultType="java.util.LinkedHashMap">
		SELECT a.*, b.VIP, b.MobilePhone
		FROM W_GetCash AS
		a INNER JOIN
		VIP AS b ON a.VIPID = b.VIPID
		where a.GetCashID =
		#{getcashid,jdbcType=BIGINT}
	</select>
</mapper>