<?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.kmall.admin.dao.OrderWXPayRecordDao">

    <resultMap type="com.kmall.admin.entity.OrderWXPayRecordEntity" id="OrderWXPayRecordMap">
        <result property="id" column="id"/>
        <result property="returnCode" column="return_code"/>
        <result property="returnMsg" column="return_msg"/>
        <result property="resultCode" column="result_code"/>
        <result property="errCode" column="err_code"/>
        <result property="errCodeDes" column="err_code_des"/>
        <result property="openid" column="openid"/>
        <result property="isSubscribe" column="is_subscribe"/>
        <result property="tradeType" column="trade_type"/>
		<result property="feeType" column="fee_type"/>
		<result property="totalFee" column="total_fee"/>
		<result property="transactionId" column="transaction_id"/>
		<result property="outTradeNo" column="out_trade_no"/>
		<result property="outTradeNoWX" column="out_trade_no_wx"/>
		<result property="attach" column="attach"/>
		<result property="timeEnd" column="time_end"/>
		<result property="tradeState" column="trade_state"/>
		<result property="createrSn" column="creater_sn"/>
		<result property="createTime" column="create_time"/>
		<result property="moderSn" column="moder_sn"/>
		<result property="modTime" column="mod_time"/>
		<result property="tstm" column="tstm"/>
    </resultMap>

	<select id="queryObject" resultMap="OrderWXPayRecordMap">
		select *
        from mall_order_wxpay_record
        where id = #{id}
	</select>

	<select id="getRecordByOutTradeNo" resultMap="OrderWXPayRecordMap">
        select *
        from mall_order_wxpay_record
        where out_trade_no = #{outTradeNo}
    </select>

 	<select id="countByOutTradeNo" resultType="int">
		select count(id) from mall_order_wxpay_record where out_trade_no = #{outTradeNo}
	</select>
	 
	<insert id="save" parameterType="com.kmall.admin.entity.OrderWXPayRecordEntity" useGeneratedKeys="true" keyProperty="id">
		insert into mall_order_wxpay_record(
			`return_code`,
			`return_msg`,
			`result_code`,
			`err_code`,
			`err_code_des`,
			`openid`,
			`is_subscribe`,
			`trade_type`,
			`fee_type`,
			`total_fee`,
			`transaction_id`,
			`out_trade_no`,
			`out_trade_no_wx`,
			`attach`,
			`time_end`,
			`trade_state`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`)
		values(
			#{returnCode},
			#{returnMsg},
			#{resultCode},
			#{errCode},
			#{errCodeDes},
			#{openid},
			#{isSubscribe},
			#{tradeType},
			#{feeType},
			#{totalFee},
			#{transactionId},
			#{outTradeNo},
			#{outTradeNoWX},
			#{attach},
			#{timeEnd},
			#{tradeState},
			#{createrSn},
			#{createTime},
			#{moderSn},
			#{modTime})
	</insert>
	 
	<update id="update" parameterType="com.kmall.admin.entity.OrderWXPayRecordEntity">
		update mall_order_wxpay_record
		<set>
			<if test="returnCode != null">`return_code` = #{returnCode}, </if>
			<if test="returnMsg != null">`return_msg` = #{returnMsg}, </if>
			<if test="resultCode != null">`result_code` = #{resultCode}, </if>
			<if test="errCode != null">`err_code` = #{errCode}, </if>
			<if test="errCodeDes != null">`err_code_des` = #{errCodeDes}, </if>
			<if test="openid != null">`openid` = #{openid}, </if>
			<if test="isSubscribe != null">`is_subscribe` = #{isSubscribe}, </if>
			<if test="tradeType != null">`trade_type` = #{tradeType}, </if>
			<if test="feeType != null">`fee_type` = #{feeType}, </if>
			<if test="totalFee != null">`total_fee` = #{totalFee}, </if>
			<if test="transactionId != null">`transaction_id` = #{transactionId}, </if>
			<if test="outTradeNo != null">`out_trade_no` = #{outTradeNo}, </if>
			<if test="outTradeNoWX != null">`out_trade_no_wx` = #{outTradeNoWX}, </if>
			<if test="attach != null">`attach` = #{attach}, </if>
			<if test="timeEnd != null">`time_end` = #{timeEnd}, </if>
			<if test="tradeState != null">`trade_state` = #{tradeState}, </if>
			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
			<if test="modTime != null">`mod_time` = #{modTime}</if>
		</set>
		where id = #{id}
	</update>
</mapper>