<?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.buy507.mall.mapper.DmsMemberWithdrawApplyMapper">
  <resultMap id="BaseResultMap" type="com.buy507.mall.model.DmsMemberWithdrawApply">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="value" jdbcType="DECIMAL" property="value" />
    <result column="poundage" jdbcType="DECIMAL" property="poundage" />
    <result column="actual_value" jdbcType="DECIMAL" property="actualValue" />
    <result column="account_name" jdbcType="VARCHAR" property="accountName" />
    <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
    <result column="bank_card_num" jdbcType="VARCHAR" property="bankCardNum" />
    <result column="open_bank_address" jdbcType="VARCHAR" property="openBankAddress" />
    <result column="real_name" jdbcType="VARCHAR" property="realName" />
    <result column="alipay_account" jdbcType="VARCHAR" property="alipayAccount" />
    <result column="wechat_account" jdbcType="VARCHAR" property="wechatAccount" />
    <result column="wechat_nickname" jdbcType="VARCHAR" property="wechatNickname" />
    <result column="withdraw_type" jdbcType="INTEGER" property="withdrawType" />
    <result column="payment_status" jdbcType="INTEGER" property="paymentStatus" />
    <result column="failed_reason" jdbcType="VARCHAR" property="failedReason" />
    <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  
  <select id="selectOneById" parameterType="java.lang.Long" resultMap="BaseResultMap">
    SELECT *
      FROM dms_member_withdraw_apply
     WHERE id = #{id}
  </select>
  
  <select id="selectAll" resultMap="BaseResultMap">
    SELECT *
      FROM dms_member_withdraw_apply
  </select>
  
  <insert id="insert" parameterType="com.buy507.mall.model.DmsMemberWithdrawApply">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into dms_member_withdraw_apply (member_id, value, poundage, actual_value, account_name, bank_name, bank_card_num, open_bank_address,
    										real_name, alipay_account, wechat_account, wechat_nickname, withdraw_type, payment_status, failed_reason, payment_time, create_time)
    values (#{memberId,jdbcType=BIGINT}, #{value,jdbcType=DECIMAL}, #{poundage,jdbcType=DECIMAL}, #{actualValue,jdbcType=DECIMAL},
    			#{accountName,jdbcType=VARCHAR}, #{bankName,jdbcType=VARCHAR}, #{bankCardNum,jdbcType=VARCHAR}, #{openBankAddress,jdbcType=VARCHAR},
    			#{realName,jdbcType=VARCHAR}, #{alipayAccount,jdbcType=VARCHAR}, #{wechatAccount,jdbcType=VARCHAR}, #{wechatNickname,jdbcType=VARCHAR},
    			#{withdrawType,jdbcType=INTEGER}, #{paymentStatus,jdbcType=INTEGER}, #{failedReason,jdbcType=VARCHAR}, #{paymentTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  
  <update id="updateById" parameterType="com.buy507.mall.model.DmsMemberWithdrawApply">
    update dms_member_withdraw_apply
       set member_id = #{memberId,jdbcType=BIGINT},
           value = #{value,jdbcType=DECIMAL},
           poundage = #{poundage,jdbcType=DECIMAL},
	       actual_value = #{actualValue,jdbcType=DECIMAL},
	       account_name = #{accountName,jdbcType=VARCHAR},
	       bank_name = #{bankName,jdbcType=VARCHAR},
	       bank_card_num = #{bankCardNum,jdbcType=VARCHAR},
	       open_bank_address = #{openBankAddress,jdbcType=VARCHAR},
	       real_name = #{realName,jdbcType=VARCHAR},
	       alipay_account = #{alipayAccount,jdbcType=VARCHAR},
	       wechat_account = #{wechatAccount,jdbcType=VARCHAR},
	       wechat_nickname = #{wechatNickname,jdbcType=VARCHAR},
	       withdraw_type = #{withdrawType,jdbcType=INTEGER},
	       payment_status = #{paymentStatus,jdbcType=INTEGER},
	       failed_reason = #{failedReason,jdbcType=VARCHAR},
	       payment_time = #{paymentTime,jdbcType=TIMESTAMP},
	       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
  </update>
  
</mapper>