<?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.OrderGuTouDao">

    <resultMap id="ResultMap" type="com.zm.order.tool.server.model.OrderGuTou">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="pay_type" jdbcType="INTEGER" property="payType"/>
        <result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
        <result column="discount_amount" jdbcType="DECIMAL" property="discountAmount"/>
        <result column="actual_amount" jdbcType="DECIMAL" property="actualAmount"/>
        <result column="order_at" jdbcType="TIMESTAMP" property="orderAt"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="gift_amount" jdbcType="DECIMAL" property="giftAmount"/>
        <result column="source" jdbcType="INTEGER" property="source"/>
        <result column="item_amount" jdbcType="DECIMAL" property="itemAmount"/>
        <result column="order_type" jdbcType="INTEGER" property="orderType"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>

    </resultMap>

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

    <sql id="cols_all">
        id,
        mobile,
        order_no,
        pay_type,
        total_amount,
        discount_amount,
        actual_amount,
        order_at,
        remark,
        gift_amount,
        `source`,
        item_amount,
        order_type,
        user_id
    </sql>

    <select id="selectList" parameterType="map" resultMap="ResultMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="lastId != null">
             id > #{lastId}
            </if>
        </where>
        order by id asc limit #{size}
    </select>

    <select id="selectList5" parameterType="map" resultMap="ResultMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
             order_type = 5
            <if test="lastId != null">
                and id > #{lastId}
            </if>
        </where>
        order by id asc limit #{size}
    </select>

    <update id="updateOrderNo" parameterType="map">
        update
            <include refid="tb"/>
        set order_no = #{orderNo} where id = #{id}
    </update>
</mapper>