<?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="cn.com.ty.lift.ud.payment.mapper.UserWithdrawMapper" >
  <resultMap id="BaseResultMap" type="cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="VARCHAR" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="acount" property="acount" jdbcType="VARCHAR" />
    <result column="mome" property="mome" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="orders" property="orders" jdbcType="VARCHAR" />
    <result column="tradNo" property="trad_no" jdbcType="VARCHAR" />
    <result column="statuz" property="statuz" jdbcType="INTEGER" />
    <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, amount, type, acount, name, statuz, create_by, create_time, update_by, 
    update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from user_withdraw
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from user_withdraw
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insertSelective" parameterType="cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity" >
    insert into user_withdraw
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="acount != null" >
        acount,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="statuz != null" >
        statuz,
      </if>
      <if test="createBy != null" >
        create_by,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateBy != null" >
        update_by,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
      <if test="orders != null" >
        orders,
      </if>
      <if test="tradNo != null" >
        trad_no,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="type != null" >
        #{type,jdbcType=INTEGER},
      </if>
      <if test="acount != null" >
        #{acount,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="statuz != null" >
        #{statuz,jdbcType=INTEGER},
      </if>
      <if test="createBy != null" >
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="orders != null" >
        #{orders,jdbcType=VARCHAR},
      </if>
      <if test="tradNo != null" >
        #{tradNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity" >
    update user_withdraw
    <set >
      <if test="userId != null" >
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="acount != null" >
        acount = #{acount,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="statuz != null" >
        statuz = #{statuz,jdbcType=INTEGER},
      </if>
      <if test="createBy != null" >
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="mome != null" >
        mome = #{mome,jdbcType=VARCHAR},
      </if>
      <if test="orders != null" >
        orders = #{orders,jdbcType=VARCHAR},
      </if>
      <if test="tradNo != null" >
        trad_no = #{tradNo,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity" >
    update user_withdraw
    set user_id = #{userId,jdbcType=INTEGER},
      amount = #{amount,jdbcType=DECIMAL},
      type = #{type,jdbcType=INTEGER},
      acount = #{acount,jdbcType=VARCHAR},
      name = #{name,jdbcType=VARCHAR},
      mome = #{mome,jdbcType=VARCHAR},
      statuz = #{statuz,jdbcType=INTEGER},
      trad_no = #{tradNo,jdbcType=VARCHAR},
      orders = #{orders,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
   
  <select id="selectByQuery" resultType="cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity" >
   select t.*,users.name as userName,users.avatar_url as avatarUrl,users.mobile,acc.expert_flag as expertFlag  from user_withdraw as t left join user_info as users on t.user_id = users.user_id LEFT JOIN user_account as acc on acc.user_id = t.user_id
    <where>
        ${ew.sqlSegment}
    </where>
     limit #{page.pageIndex},#{page.pageSize}
  </select>
  
  <select id="countByQuery" resultType="java.lang.Integer">
     select count(0)  from user_withdraw as t left join user_info as users on t.user_id = users.user_id LEFT JOIN user_account as acc on acc.user_id = t.user_id
    <where>
        ${ew.sqlSegment}
    </where>
  </select>
  
    <update id="deleteUpdate" >
    delete from user_withdraw where id in 
   <foreach collection="req.ids" item="item" index="index" open="(" close=")" separator=",">
        #{item}
    </foreach>
  </update>
</mapper>