<?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.zm.order.tool.server.tempdb.OrderT97Dao">

    <resultMap id="JuiceOrderMap" type="com.zm.order.tool.server.model.OrderT97">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="store_id" jdbcType="BIGINT" property="storeId"/>
        <result column="store_name" jdbcType="VARCHAR" property="storeName"/>
        <result column="order_type_txt" jdbcType="VARCHAR" property="orderTypeTxt"/>
        <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="refund_order_no" jdbcType="VARCHAR" property="refundOrderNo"/>
        <result column="stauts_txt" jdbcType="VARCHAR" property="stautsTxt"/>
        <result column="item_name" jdbcType="VARCHAR" property="itemName"/>
        <result column="item_sign" jdbcType="VARCHAR" property="itemSign"/>
        <result column="item_cate" jdbcType="VARCHAR" property="itemCate"/>
        <result column="item_price" jdbcType="DECIMAL" property="itemPrice"/>
        <result column="num" jdbcType="DECIMAL" property="num"/>
        <result column="discount_amount" jdbcType="DECIMAL" property="discountAmount"/>
        <result column="pay_type_txt" jdbcType="VARCHAR" property="payTypeTxt"/>
        <result column="payer_mobile" jdbcType="VARCHAR" property="payerMobile"/>
        <result column="pay_status_txt" jdbcType="VARCHAR" property="payStatusTxt"/>
        <result column="pay_amount" jdbcType="DECIMAL" property="payAmount"/>
        <result column="cash_amount" jdbcType="DECIMAL" property="cashAmount"/>
        <result column="wallet_amount" jdbcType="DECIMAL" property="walletAmount"/>
        <result column="third_amount" jdbcType="DECIMAL" property="thirdAmount"/>
        <result column="order_at" jdbcType="TIMESTAMP" property="orderAt"/>
        <result column="pay_at" jdbcType="TIMESTAMP" property="payAt"/>
        <result column="completed_at" jdbcType="TIMESTAMP" property="completedAt"/>
        <result column="order_type" jdbcType="INTEGER" property="orderType"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="pay_status" jdbcType="INTEGER" property="payStatus"/>
        <result column="pay_type" jdbcType="INTEGER" property="payType"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
        <result column="goods_id" jdbcType="BIGINT" property="goodsId"/>
        <result column="source" jdbcType="INTEGER" property="source"/>
        <result column="item_price_new" jdbcType="INTEGER" property="itemPriceNew"/>

    </resultMap>

    <sql id="tb">
        order_t97
    </sql>

    <sql id="cols_all">
        id,
        store_id,
        store_name,
        order_type_txt,
        mobile,
        order_no,
        refund_order_no,
        stauts_txt,
         item_name,
        item_sign,
        item_cate,
        item_price,
        num,
        discount_amount,
        pay_type_txt,
        payer_mobile,
        pay_status_txt,
        pay_amount,
        cash_amount,
        wallet_amount,
        third_amount,
        order_at,
        pay_at,
        completed_at,
        order_type,
        status,
        pay_status,
        pay_type,
        user_id,
        item_id,
        goods_id,
        source,
        item_price_new
    </sql>

    <select id="selectList" parameterType="map" resultMap="JuiceOrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="lastId != null">
                id > #{lastId}
            </if>
            <if test="refundFlag == 1">
                and refund_order_no != ""
            </if>
            <if test="refundFlag == 0">
                and refund_order_no = ""
            </if>
        </where>
            order by id asc limit #{size}
    </select>
</mapper>