<select id="selectByPrimaryKeySelective" parameterType="com.mjs.mojisishop.entity.OrderInfo"
resultMap="orderInfoMap">
select
e1.id,e1.orderNo,e1.payType,e1.orderPrice,e1.orderStatus,e1.contacts,e1.phoneNum,e1.address,e1.expressName,e1.expressCode,
e1.creatUser,e1.note,e1.creatTime,e1.lastTime,
e2.id as oid,e2.orderNo as
oorderNo,e2.discountCode,e2.itemId,e2.goodsName,e2.unitPrice,e2.amount,e2.totalPrice,e2.detailStatus,
e2.creatUser as ocreatUser,e2.creatTime as ocreatTime,e2.lastTime as olastTime
from `order` e1,order_detail e2
where 1=1 and e1.orderNo=e2.orderNo
<if test="orderno!=null and orderno!=''">
and e1.orderNo like concat('%',#{orderno},'%')
</if>
<if test="orderstatus != null and orderstatus != ''">
and orderStatus = #{orderstatus,jdbcType=INTEGER}
</if>
<if test="title != null and title != '' ">
and title like concat('%',#{title},'%')
</if>
<if test="creattime != null or lasttime != null ">
and e1.creatTime
between #{creattime,jdbcType=TIMESTAMP} and
#{lasttime,jdbcType=TIMESTAMP}
</if>
<!--查询可用优惠券时传creatTime,来比较validtime,>=大于等于,<=小于等于
-->
<if test="creatTime != null ">
<!--<![CDATA[and validTime >= #{creatTime}]]>-->
and validTime >= #{creatTime}
</if>
<if test="validTime != null ">
and validTime < #{validTime}
</if>
</select>
注意if条件末尾不能有逗号