<?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.jsowell.pile.mapper.WxpayCallbackRecordMapper">
  <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.WxpayCallbackRecord">
    <!--@mbg.generated-->
    <!--@Table wxpay_callback_record-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="pay_scenario" jdbcType="VARCHAR" property="payScenario" />
    <result column="member_id" jdbcType="VARCHAR" property="memberId" />
    <result column="order_code" jdbcType="VARCHAR" property="orderCode" />
    <result column="out_trade_no" jdbcType="VARCHAR" property="outTradeNo" />
    <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
    <result column="mch_id" jdbcType="VARCHAR" property="mchId" />
    <result column="app_id" jdbcType="VARCHAR" property="appId" />
    <result column="trade_type" jdbcType="VARCHAR" property="tradeType" />
    <result column="trade_state" jdbcType="VARCHAR" property="tradeState" />
    <result column="trade_state_desc" jdbcType="VARCHAR" property="tradeStateDesc" />
    <result column="bank_type" jdbcType="VARCHAR" property="bankType" />
    <result column="attach" jdbcType="VARCHAR" property="attach" />
    <result column="success_time" jdbcType="TIMESTAMP" property="successTime" />
    <result column="payer_open_id" jdbcType="VARCHAR" property="payerOpenId" />
    <result column="payer_total" jdbcType="VARCHAR" property="payerTotal" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, pay_scenario, member_id, order_code, out_trade_no, transaction_id, mch_id, app_id, trade_type,
    trade_state, trade_state_desc, bank_type, attach, success_time, payer_open_id, payer_total, 
    create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from wxpay_callback_record
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from wxpay_callback_record
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.WxpayCallbackRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into wxpay_callback_record (pay_scenario, member_id, order_code, out_trade_no,
      transaction_id, mch_id, app_id, 
      trade_type, trade_state, trade_state_desc, 
      bank_type, attach, success_time, 
      payer_open_id, payer_total, create_time
      )
    values (#{payScenario,jdbcType=VARCHAR}, #{memberId,jdbcType=VARCHAR}, #{orderCode,jdbcType=VARCHAR}, #{outTradeNo,jdbcType=VARCHAR},
      #{transactionId,jdbcType=VARCHAR}, #{mchId,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR},
      #{tradeType,jdbcType=VARCHAR}, #{tradeState,jdbcType=VARCHAR}, #{tradeStateDesc,jdbcType=VARCHAR}, 
      #{bankType,jdbcType=VARCHAR}, #{attach,jdbcType=VARCHAR}, #{successTime,jdbcType=TIMESTAMP}, 
      #{payerOpenId,jdbcType=VARCHAR}, #{payerTotal,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.WxpayCallbackRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into wxpay_callback_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="payScenario != null">
        pay_scenario,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="orderCode != null and orderCode != ''">
        order_code,
      </if>
      <if test="outTradeNo != null and outTradeNo != ''">
        out_trade_no,
      </if>
      <if test="transactionId != null">
        transaction_id,
      </if>
      <if test="mchId != null">
        mch_id,
      </if>
      <if test="appId != null">
        app_id,
      </if>
      <if test="tradeType != null and tradeType != ''">
        trade_type,
      </if>
      <if test="tradeState != null and tradeState != ''">
        trade_state,
      </if>
      <if test="tradeStateDesc != null and tradeStateDesc != ''">
        trade_state_desc,
      </if>
      <if test="bankType != null and bankType != ''">
        bank_type,
      </if>
      <if test="attach != null and attach != ''">
        attach,
      </if>
      <if test="successTime != null">
        success_time,
      </if>
      <if test="payerOpenId != null and payerOpenId != ''">
        payer_open_id,
      </if>
      <if test="payerTotal != null and payerTotal != ''">
        payer_total,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="payScenario != null">
        #{payScenario,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="orderCode != null and orderCode != ''">
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="outTradeNo != null and outTradeNo != ''">
        #{outTradeNo,jdbcType=VARCHAR},
      </if>
      <if test="transactionId != null">
        #{transactionId,jdbcType=VARCHAR},
      </if>
      <if test="mchId != null">
        #{mchId,jdbcType=VARCHAR},
      </if>
      <if test="appId != null">
        #{appId,jdbcType=VARCHAR},
      </if>
      <if test="tradeType != null and tradeType != ''">
        #{tradeType,jdbcType=VARCHAR},
      </if>
      <if test="tradeState != null and tradeState != ''">
        #{tradeState,jdbcType=VARCHAR},
      </if>
      <if test="tradeStateDesc != null and tradeStateDesc != ''">
        #{tradeStateDesc,jdbcType=VARCHAR},
      </if>
      <if test="bankType != null and bankType != ''">
        #{bankType,jdbcType=VARCHAR},
      </if>
      <if test="attach != null and attach != ''">
        #{attach,jdbcType=VARCHAR},
      </if>
      <if test="successTime != null">
        #{successTime,jdbcType=TIMESTAMP},
      </if>
      <if test="payerOpenId != null and payerOpenId != ''">
        #{payerOpenId,jdbcType=VARCHAR},
      </if>
      <if test="payerTotal != null and payerTotal != ''">
        #{payerTotal,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.WxpayCallbackRecord">
    <!--@mbg.generated-->
    update wxpay_callback_record
    <set>
      <if test="payScenario != null">
        pay_scenario = #{payScenario,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="orderCode != null and orderCode != ''">
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="outTradeNo != null and outTradeNo != ''">
        out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
      </if>
      <if test="transactionId != null">
        transaction_id = #{transactionId,jdbcType=VARCHAR},
      </if>
      <if test="mchId != null">
        mch_id = #{mchId,jdbcType=VARCHAR},
      </if>
      <if test="appId != null">
        app_id = #{appId,jdbcType=VARCHAR},
      </if>
      <if test="tradeType != null and tradeType != ''">
        trade_type = #{tradeType,jdbcType=VARCHAR},
      </if>
      <if test="tradeState != null and tradeState != ''">
        trade_state = #{tradeState,jdbcType=VARCHAR},
      </if>
      <if test="tradeStateDesc != null and tradeStateDesc != ''">
        trade_state_desc = #{tradeStateDesc,jdbcType=VARCHAR},
      </if>
      <if test="bankType != null and bankType != ''">
        bank_type = #{bankType,jdbcType=VARCHAR},
      </if>
      <if test="attach != null and attach != ''">
        attach = #{attach,jdbcType=VARCHAR},
      </if>
      <if test="successTime != null">
        success_time = #{successTime,jdbcType=TIMESTAMP},
      </if>
      <if test="payerOpenId != null and payerOpenId != ''">
        payer_open_id = #{payerOpenId,jdbcType=VARCHAR},
      </if>
      <if test="payerTotal != null and payerTotal != ''">
        payer_total = #{payerTotal,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.WxpayCallbackRecord">
    <!--@mbg.generated-->
    update wxpay_callback_record
    set
      pay_scenario = #{payScenario,jdbcType=VARCHAR},
      member_id = #{memberId,jdbcType=VARCHAR},
      order_code = #{orderCode,jdbcType=VARCHAR},
      out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
      transaction_id = #{transactionId,jdbcType=VARCHAR},
      mch_id = #{mchId,jdbcType=VARCHAR},
      app_id = #{appId,jdbcType=VARCHAR},
      trade_type = #{tradeType,jdbcType=VARCHAR},
      trade_state = #{tradeState,jdbcType=VARCHAR},
      trade_state_desc = #{tradeStateDesc,jdbcType=VARCHAR},
      bank_type = #{bankType,jdbcType=VARCHAR},
      attach = #{attach,jdbcType=VARCHAR},
      success_time = #{successTime,jdbcType=TIMESTAMP},
      payer_open_id = #{payerOpenId,jdbcType=VARCHAR},
      payer_total = #{payerTotal,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectByOrderCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from wxpay_callback_record
    where del_flag = '0' and order_code = #{orderCode,jdbcType=VARCHAR}
  </select>

  <select id="selectBalanceRechargeRecord" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from wxpay_callback_record
    where pay_scenario = 'balance'
    and member_id = #{memberId,jdbcType=VARCHAR}
    and success_time >= #{date,jdbcType=TIMESTAMP}
    order by success_time
  </select>

  <select id="selectByOutTradeNo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from wxpay_callback_record
    where out_trade_no = #{outTradeNo,jdbcType=VARCHAR}
  </select>
</mapper>