方法1:
<sql id="select_where">
<if test="orderid != null">
and om.orderid = #{orderid}
</if>
<if test="paytype != null">
and om.paytype = #{paytype}
</if>
<if test="customerid != null">
and om.customerid = #{customerid}
</if>
<if test="status != null">
and om.status = #{status}
</if>
<if test="type != null">
and om.type = #{type}
</if>
<if test="proName != null">
and od.productname like
concat(concat('%',#{proName}),'%')
</if>
<if test="proCode != null">
and od.PRODUCT_NO like
concat(concat('%',#{proCode}),'%')
</if>
</sql>
<select id="orderTotalRows" resultType="java.lang.Integer"
parameterType="com.cloud.api.pojo.order.OrderSql">
select count(1)
from OMORDER om,orderdetail od
where om.orderid = od.orderid
<include refid="select_where" />
</select>
方法2
<sql id="select_where">
<if test="orderid != null">
and om.orderid = #{orderid}
</if>
<if test="paytype != null">
and om.paytype = #{paytype}
</if>
<if test="customerid != null">
and om.customerid = #{customerid}
</if>
<if test="status != null">
and om.status = #{status}
</if>
<if test="type != null">
and om.type = #{type}
</if>
<if test="proName != null">
and od.productname like ${bname}
</if>
<if test="proCode != null">
and od.PRODUCT_NO like
${bcode}
</if>
</sql>
<select id="orderList" resultMap="BaseResultMap"
parameterType="com.cloud.api.pojo.order.OrderSql">
<bind name="bname" value="'%'${proName}'%'"/>
<bind name="bcode" value="'%'${proCode}'%'"/>
select *
from (select t_order.*, rownum as odnum
from (
select
<include refid="Base_Column_List" />
from OMORDER om,orderdetail od
where om.orderid = od.orderid
<include refid="select_where" />
) t_order
<![CDATA[where rownum <=]]>
#{rowEnd} )
<![CDATA[where odnum >]]>
#{rowBegin}
</select>