<?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.miaxis.applepay.mapper.ApplepayOrderMapper">

    <resultMap type="ApplepayOrder" id="ApplepayOrderResult">
        <result property="id"    column="id"    />
        <result property="transactionId"    column="transaction_id"    />
        <result property="originalTransactionId"    column="original_transaction_id"    />
        <result property="productId"    column="product_id"    />
        <result property="quantity"    column="quantity"    />
        <result property="purchaseDate"    column="purchase_date"    />
        <result property="originalPurchaseDate"    column="original_purchase_date"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectApplepayOrderVo">
        select * from applepay_order
    </sql>

    <select id="selectApplepayOrderList" parameterType="ApplepayOrder" resultMap="ApplepayOrderResult">
        <include refid="selectApplepayOrderVo"/>
        <where>
            <if test="transactionId != null "> and transaction_id = #{transactionId}</if>
            <if test="originalTransactionId != null "> and original_transaction_id = #{originalTransactionId}</if>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="quantity != null "> and quantity = #{quantity}</if>
            <if test="purchaseDate != null "> and purchase_date = #{purchaseDate}</if>
            <if test="originalPurchaseDate != null "> and original_purchase_date = #{originalPurchaseDate}</if>
        </where>
    </select>

    <select id="selectApplepayOrderCount" parameterType="ApplepayOrder" resultType="int">
        select count(1) from applepay_order
        <where>
            <if test="transactionId != null "> and transaction_id = #{transactionId}</if>
            <if test="originalTransactionId != null "> and original_transaction_id = #{originalTransactionId}</if>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="quantity != null "> and quantity = #{quantity}</if>
            <if test="purchaseDate != null "> and purchase_date = #{purchaseDate}</if>
            <if test="originalPurchaseDate != null "> and original_purchase_date = #{originalPurchaseDate}</if>
        </where>
    </select>



</mapper>
