<?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.izouma.weixin.dao.WxpayTempMapper">
    <resultMap id="BaseResultMap" type="com.izouma.weixin.model.WxpayTemp">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
        <result column="order_id" property="orderId" jdbcType="VARCHAR"/>
        <result column="user_id" property="userId" jdbcType="VARCHAR"/>
        <result column="total_amount" property="totalAmount" jdbcType="DECIMAL"/>
        <result column="out_trade_no" property="outTradeNo" jdbcType="VARCHAR"/>
        <result column="transaction_id" property="transactionId" jdbcType="VARCHAR"/>
        <result column="type_flag" property="typeFlag" jdbcType="INTEGER"/>
        <result column="out_refund_no" property="outRefundNo" jdbcType="VARCHAR"/>
        <result column="refund_amount" property="refundAmount" jdbcType="DECIMAL"/>
        <result column="coin" property="coin" jdbcType="DECIMAL"/>
        <result column="point" property="point" jdbcType="DECIMAL"/>
        <result column="cash" property="cash" jdbcType="DECIMAL"/>
        <result column="open_id" property="openId" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        <trim suffixOverrides=",">
            id,

            del_flag,

            update_time,

            update_user,

            create_time,

            create_user,

            order_id,

            user_id,

            total_amount,

            out_trade_no,

            transaction_id,

            type_flag,

            out_refund_no,

            refund_amount,

            coin,

            point,

            cash,

            open_id,

        </trim>
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from wxpay_temp
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from wxpay_temp
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.weixin.model.WxpayTemp" useGeneratedKeys="true"
            keyProperty="id">
        insert into wxpay_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
            <if test="updateUser!= null">
                update_user,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="createUser!= null">
                create_user,
            </if>
            <if test="orderId!= null">
                order_id,
            </if>
            <if test="userId!= null">
                user_id,
            </if>
            <if test="totalAmount!= null">
                total_amount,
            </if>
            <if test="outTradeNo!= null">
                out_trade_no,
            </if>
            <if test="transactionId!= null">
                transaction_id,
            </if>
            <if test="typeFlag!= null">
                type_flag,
            </if>
            <if test="outRefundNo!= null">
                out_refund_no,
            </if>
            <if test="refundAmount!= null">
                refund_amount,
            </if>
            <if test="coin!= null">
                coin,
            </if>
            <if test="point!= null">
                point,
            </if>
            <if test="cash!= null">
                cash,
            </if>
            <if test="openId!= null">
                open_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="orderId != null">
                #{orderId,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=VARCHAR},
            </if>
            <if test="totalAmount != null">
                #{totalAmount,jdbcType=DECIMAL},
            </if>
            <if test="outTradeNo != null">
                #{outTradeNo,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="typeFlag != null">
                #{typeFlag,jdbcType=INTEGER},
            </if>
            <if test="outRefundNo != null">
                #{outRefundNo,jdbcType=VARCHAR},
            </if>
            <if test="refundAmount != null">
                #{refundAmount,jdbcType=DECIMAL},
            </if>
            <if test="coin != null">
                #{coin,jdbcType=DECIMAL},
            </if>
            <if test="point != null">
                #{point,jdbcType=DECIMAL},
            </if>
            <if test="cash != null">
                #{cash,jdbcType=DECIMAL},
            </if>
            <if test="openId != null">
                #{openId,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.weixin.model.WxpayTemp">
        update wxpay_temp
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                update_user= #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                create_user= #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="orderId != null">
                order_id= #{orderId,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                user_id= #{userId,jdbcType=VARCHAR},
            </if>
            <if test="totalAmount != null">
                total_amount= #{totalAmount,jdbcType=DECIMAL},
            </if>
            <if test="outTradeNo != null">
                out_trade_no= #{outTradeNo,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                transaction_id= #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="typeFlag != null">
                type_flag= #{typeFlag,jdbcType=INTEGER},
            </if>
            <if test="outRefundNo != null">
                out_refund_no= #{outRefundNo,jdbcType=VARCHAR},
            </if>
            <if test="refundAmount != null">
                refund_amount= #{refundAmount,jdbcType=DECIMAL},
            </if>
            <if test="coin != null">
                coin= #{coin,jdbcType=DECIMAL},
            </if>
            <if test="point != null">
                point= #{point,jdbcType=DECIMAL},
            </if>
            <if test="cash != null">
                cash= #{cash,jdbcType=DECIMAL},
            </if>
            <if test="openId != null">
                open_id= #{openId,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryWxpayTempByPage" parameterType="java.util.Map" resultType="com.izouma.weixin.model.WxpayTemp">
        select
        <include refid="Base_Column_List"/>
        from wxpay_temp
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>
            <if test="record.updateUser != null and !&quot;&quot;.equals(record.updateUser)">
                and update_user = #{record.updateUser}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.createUser != null and !&quot;&quot;.equals(record.createUser)">
                and create_user = #{record.createUser}
            </if>
            <if test="record.orderId != null and !&quot;&quot;.equals(record.orderId)">
                and order_id = #{record.orderId}
            </if>
            <if test="record.userId != null and !&quot;&quot;.equals(record.userId)">
                and user_id = #{record.userId}
            </if>
            <if test="record.totalAmount != null and !&quot;&quot;.equals(record.totalAmount)">
                and total_amount = #{record.totalAmount}
            </if>
            <if test="record.outTradeNo != null and !&quot;&quot;.equals(record.outTradeNo)">
                and out_trade_no = #{record.outTradeNo}
            </if>
            <if test="record.transactionId != null and !&quot;&quot;.equals(record.transactionId)">
                and transaction_id = #{record.transactionId}
            </if>
            <if test="record.typeFlag != null and !&quot;&quot;.equals(record.typeFlag)">
                and type_flag = #{record.typeFlag}
            </if>
            <if test="record.outRefundNo != null and !&quot;&quot;.equals(record.outRefundNo)">
                and out_refund_no = #{record.outRefundNo}
            </if>
            <if test="record.refundAmount != null and !&quot;&quot;.equals(record.refundAmount)">
                and refund_amount = #{record.refundAmount}
            </if>
            <if test="record.coin != null and !&quot;&quot;.equals(record.coin)">
                and coin = #{record.coin}
            </if>
            <if test="record.point != null and !&quot;&quot;.equals(record.point)">
                and point = #{record.point}
            </if>
            <if test="record.cash != null and !&quot;&quot;.equals(record.cash)">
                and cash = #{record.cash}
            </if>
            <if test="record.openId != null and !&quot;&quot;.equals(record.openId)">
                and open_id = #{record.openId}
            </if>
            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR order_id LIKE concat('%',#{record.searchKey},'%')
                    OR user_id LIKE concat('%',#{record.searchKey},'%')
                    OR total_amount LIKE concat('%',#{record.searchKey},'%')
                    OR out_trade_no LIKE concat('%',#{record.searchKey},'%')
                    OR transaction_id LIKE concat('%',#{record.searchKey},'%')
                    OR type_flag LIKE concat('%',#{record.searchKey},'%')
                    OR out_refund_no LIKE concat('%',#{record.searchKey},'%')
                    OR refund_amount LIKE concat('%',#{record.searchKey},'%')
                    OR coin LIKE concat('%',#{record.searchKey},'%')
                    OR point LIKE concat('%',#{record.searchKey},'%')
                    OR cash LIKE concat('%',#{record.searchKey},'%')
                    OR open_id LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

            <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
                <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>

        </where>
        order by

        <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">


            <trim suffixOverrides=",">
                <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                        ${itemDetail}
                    </foreach>
                </foreach>
            </trim>
            ,
        </if>
        id desc
    </select>
    <select id="queryAllWxpayTemp" parameterType="java.util.Map" resultType="com.izouma.weixin.model.WxpayTemp">
        select
        <include refid="Base_Column_List"/>
        from wxpay_temp
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="updateUser != null and !&quot;&quot;.equals(updateUser)">
                and update_user = #{updateUser}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="createUser != null and !&quot;&quot;.equals(createUser)">
                and create_user = #{createUser}
            </if>
            <if test="orderId != null and !&quot;&quot;.equals(orderId)">
                and order_id = #{orderId}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="totalAmount != null and !&quot;&quot;.equals(totalAmount)">
                and total_amount = #{totalAmount}
            </if>
            <if test="outTradeNo != null and !&quot;&quot;.equals(outTradeNo)">
                and out_trade_no = #{outTradeNo}
            </if>
            <if test="transactionId != null and !&quot;&quot;.equals(transactionId)">
                and transaction_id = #{transactionId}
            </if>
            <if test="typeFlag != null and !&quot;&quot;.equals(typeFlag)">
                and type_flag = #{typeFlag}
            </if>
            <if test="outRefundNo != null and !&quot;&quot;.equals(outRefundNo)">
                and out_refund_no = #{outRefundNo}
            </if>
            <if test="refundAmount != null and !&quot;&quot;.equals(refundAmount)">
                and refund_amount = #{refundAmount}
            </if>
            <if test="coin != null and !&quot;&quot;.equals(coin)">
                and coin = #{coin}
            </if>
            <if test="point != null and !&quot;&quot;.equals(point)">
                and point = #{point}
            </if>
            <if test="cash != null and !&quot;&quot;.equals(cash)">
                and cash = #{cash}
            </if>
            <if test="openId != null and !&quot;&quot;.equals(openId)">
                and open_id = #{openId}
            </if>
            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR order_id LIKE concat('%',#{searchKey},'%')
                    OR user_id LIKE concat('%',#{searchKey},'%')
                    OR total_amount LIKE concat('%',#{searchKey},'%')
                    OR out_trade_no LIKE concat('%',#{searchKey},'%')
                    OR transaction_id LIKE concat('%',#{searchKey},'%')
                    OR type_flag LIKE concat('%',#{searchKey},'%')
                    OR out_refund_no LIKE concat('%',#{searchKey},'%')
                    OR refund_amount LIKE concat('%',#{searchKey},'%')
                    OR coin LIKE concat('%',#{searchKey},'%')
                    OR point LIKE concat('%',#{searchKey},'%')
                    OR cash LIKE concat('%',#{searchKey},'%')
                    OR open_id LIKE concat('%',#{searchKey},'%')
                </trim>
            </if>
            <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
                <foreach item="item" index="index" collection="advancedQuery.split('_;')">
                    <choose>
                        <when test="item.indexOf('like') != -1">
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    concat('%',#{itemDetail},'%')
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </when>
                        <otherwise>
                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                                <if test="detailIndex == 3">
                                    #{itemDetail}
                                </if>

                                <if test="detailIndex &lt; 3">
                                    ${itemDetail}
                                </if>

                            </foreach>
                        </otherwise>
                    </choose>


                </foreach>


            </if>
        </where>
        order by

        <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">


            <trim suffixOverrides=",">
                <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
                        ${itemDetail}
                    </foreach>
                </foreach>
            </trim>
            ,
        </if>

        id desc
    </select>
    <select id="queryWxpayTemp" parameterType="java.util.Map" resultType="com.izouma.weixin.model.WxpayTemp">
        select
        <include refid="Base_Column_List"/>
        from wxpay_temp
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="updateUser != null and !&quot;&quot;.equals(updateUser)">
                and update_user = #{updateUser}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="createUser != null and !&quot;&quot;.equals(createUser)">
                and create_user = #{createUser}
            </if>
            <if test="orderId != null and !&quot;&quot;.equals(orderId)">
                and order_id = #{orderId}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="totalAmount != null and !&quot;&quot;.equals(totalAmount)">
                and total_amount = #{totalAmount}
            </if>
            <if test="outTradeNo != null and !&quot;&quot;.equals(outTradeNo)">
                and out_trade_no = #{outTradeNo}
            </if>
            <if test="transactionId != null and !&quot;&quot;.equals(transactionId)">
                and transaction_id = #{transactionId}
            </if>
            <if test="typeFlag != null and !&quot;&quot;.equals(typeFlag)">
                and type_flag = #{typeFlag}
            </if>
            <if test="outRefundNo != null and !&quot;&quot;.equals(outRefundNo)">
                and out_refund_no = #{outRefundNo}
            </if>
            <if test="refundAmount != null and !&quot;&quot;.equals(refundAmount)">
                and refund_amount = #{refundAmount}
            </if>
            <if test="coin != null and !&quot;&quot;.equals(coin)">
                and coin = #{coin}
            </if>
            <if test="point != null and !&quot;&quot;.equals(point)">
                and point = #{point}
            </if>
            <if test="cash != null and !&quot;&quot;.equals(cash)">
                and cash = #{cash}
            </if>
            <if test="openId != null and !&quot;&quot;.equals(openId)">
                and open_id = #{openId}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE wxpay_temp SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.weixin.model.WxpayTemp">
        select
        <include refid="Base_Column_List"/>
        from wxpay_temp
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

