<?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.DmsOfflinePaymentRecordMapper">
  <resultMap id="BaseResultMap" type="com.buy507.mall.model.DmsOfflinePaymentRecord">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="seller_bank_account_id" jdbcType="INTEGER" property="sellerBankAccountId" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="order_sn" jdbcType="VARCHAR" property="orderSn" />
    <result column="pay_amount" jdbcType="DECIMAL" property="payAmount" />
    <result column="payment_account_name" jdbcType="VARCHAR" property="paymentAccountName" />
    <result column="payment_bank_name" jdbcType="VARCHAR" property="paymentBankName" />
    <result column="payment_bank_card_num" jdbcType="VARCHAR" property="paymentBankCardNum" />
    <result column="confirm_status" jdbcType="INTEGER" property="confirmStatus" />
    <result column="confirm_time" jdbcType="TIMESTAMP" property="confirmTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  
  <select id="selectOneByOrderId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    SELECT *
      FROM dms_offline_payment_record
     WHERE order_id = #{orderId}
  </select>
  
  <insert id="insert" parameterType="com.buy507.mall.model.DmsOfflinePaymentRecord">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into dms_offline_payment_record (seller_bank_account_id, member_id, order_id, order_sn, pay_amount, payment_account_name, payment_bank_name, 
    										payment_bank_card_num, confirm_status, confirm_time, create_time)
    values (#{sellerBankAccountId,jdbcType=INTEGER}, #{memberId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{orderSn,jdbcType=VARCHAR}, #{payAmount,jdbcType=DECIMAL},
    			#{paymentAccountName,jdbcType=VARCHAR}, #{paymentBankName,jdbcType=VARCHAR}, #{paymentBankCardNum,jdbcType=VARCHAR}, 
    			#{confirmStatus,jdbcType=INTEGER}, #{confirmTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  
  <update id="updateById" parameterType="com.buy507.mall.model.DmsOfflinePaymentRecord">
    update dms_offline_payment_record
       set seller_bank_account_id = #{sellerBankAccountId,jdbcType=INTEGER},
           member_id = #{memberId,jdbcType=BIGINT},
           order_id = #{orderId,jdbcType=BIGINT},
           order_sn = #{orderSn,jdbcType=VARCHAR},
	       pay_amount = #{payAmount,jdbcType=DECIMAL},
	       payment_account_name = #{paymentAccountName,jdbcType=VARCHAR},
	       payment_bank_name = #{paymentBankName,jdbcType=VARCHAR},
	       payment_bank_card_num = #{paymentBankCardNum,jdbcType=VARCHAR},
	       confirm_status = #{confirmStatus,jdbcType=INTEGER},
	       confirm_time = #{confirmTime,jdbcType=TIMESTAMP},
	       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
  </update>
  
</mapper>