<?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.iformall.mapper.PosOrderMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.PosOrder">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
		<result column="pos_order_no" jdbcType="VARCHAR" property="posOrderNo" />
		<result column="type" jdbcType="INTEGER" property="type" />
		<result column="order_status" jdbcType="INTEGER" property="orderStatus" />
		<result column="bu_user_id" jdbcType="BIGINT" property="buUserId" />
		<result column="payment_type" jdbcType="INTEGER" property="paymentType" />
		<result column="payment" jdbcType="INTEGER" property="payment" />
		<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
		<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
	</resultMap>
	
	<sql id="allColumns">
	    `id`,`tenant_id`,`pos_order_no`,`type`,`order_status`,`bu_user_id`,`create_date`,`update_date` 
	</sql>

	<sql id="dynamicWhereConditions">
	        where 1 = 1
		<if test=" null != id ">
		    and `id` = #{id}
		</if>    
		<if test=" null != tenantId ">
		    and `tenant_id`  like concat('%', #{tenantId},'%')
		</if>    
		<if test=" null != posOrderNo ">
		    and `pos_order_no`  like concat('%', #{posOrderNo},'%')
		</if>    
		<if test=" null != type ">
		    and `type` = #{type}
		</if>    
		<if test=" null != orderStatus ">
		    and `order_status` = #{orderStatus}
		</if>    
		<if test=" null != buUserId ">
		    and `bu_user_id` = #{buUserId}
		</if>
		<if test=" null != paymentType ">
			and `payment_type` = #{paymentType}
		</if>
		<if test=" null != payment ">
			and `payment` = #{payment}
		</if>
		<if test=" null != createDate ">
		    and `create_date` = #{createDate}
		</if>    
		<if test=" null != updateDate ">
		    and `update_date` = #{updateDate}
		</if>    
		<if test=" null != ids ">
		 	and id in  
			<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
			#{idItem}
			</foreach>
		</if>		
		<if test=" null != sortColumns"> order by ${sortColumns} </if>
	</sql>
	
	<select id="findList" parameterType="com.iformall.domain.po.PosOrder" resultMap="BaseResultMap">
		select <include refid="allColumns" /> from pos_order
		<include refid="dynamicWhereConditions" />
	</select>
	
	
	
	
	
	
</mapper>
