<?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.pj.project.tb_business.TbBusinessMapper">

	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [G] -->
	<select id="getList" resultType="com.pj.project.tb_business.TbBusiness">
		select * from tb_business
		<where>
			<if test=' this.has("id") '> and id = #{id} </if>
			<if test=' this.has("customerId") '> and customer_id = #{customerId} </if>
			<if test=' this.has("customerName") '> and customer_name like concat('%', #{customerName} ,'%')</if>
			<if test=' this.has("no") '> and no = #{no} </if>
			<if test=' this.has("cardNo") '> and card_no  like concat('%', #{cardNo} ,'%')</if>
			<if test=' this.has("cardSize") '> and card_size = #{cardSize} </if>
			<if test=' this.has("netWeight") '> and net_weight = #{netWeight} </if>
			<if test=' this.has("goodsName") '> and goods_name = #{goodsName} </if>
			<if test=' this.has("goodsCode") '> and goods_code = #{goodsCode} </if>
			<if test=' this.has("driverName") '> and driver_name  like concat('%', #{driverName} ,'%')</if>
			<if test=' this.has("driverId") '> and driver_id = #{driverId} </if>
			<if test=' this.has("driverPhone") '> and driver_phone = #{driverPhone} </if>
			<if test=' this.has("driverIdCard") '> and driver_id_card  like concat('%', #{driverIdCard} ,'%')</if>
			<if test=' this.has("expectInDay") '> and expect_in_day = #{expectInDay} </if>
			<if test=' this.has("realInDay") '> and real_in_day = #{realInDay} </if>
			<if test=' this.has("realInTime") '> and real_in_time = #{realInTime} </if>
			<if test=' this.has("payStatus") '> and pay_status = #{payStatus} </if>
			<if test=' this.has("payTime") '> and pay_time = #{payTime} </if>
			<if test=' this.has("payType") '> and pay_type = #{payType} </if>
			<if test=' this.has("outDayTime") '> and out_day_time = #{outDayTime} </if>
			<if test=' this.has("partMoney") '> and part_money = #{partMoney} </if>
			<if test=' this.has("partTime") '> and part_time = #{partTime} </if>
            <if test=' this.has("current") '>
                <if test=' current == 3 '>and real_in_time is not null and out_day_time is not null</if>
                <if test=' current == 2 '>and real_in_time is not null and out_day_time is null</if>
                <if test=' current == 1 '>and real_in_time is null and out_day_time is null</if>
            </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> customer_id desc </when>
			<when test='sortType == 3'> customer_name desc </when>
			<when test='sortType == 4'> no desc </when>
			<when test='sortType == 5'> card_no desc </when>
			<when test='sortType == 6'> card_size desc </when>
			<when test='sortType == 7'> net_weight desc </when>
			<when test='sortType == 8'> goods_name desc </when>
			<when test='sortType == 9'> goods_code desc </when>
			<when test='sortType == 10'> driver_name desc </when>
			<when test='sortType == 11'> driver_id desc </when>
			<when test='sortType == 12'> driver_phone desc </when>
			<when test='sortType == 13'> driver_id_card desc </when>
			<when test='sortType == 14'> expect_in_day desc </when>
			<when test='sortType == 15'> real_in_day desc </when>
			<when test='sortType == 16'> real_in_time desc </when>
			<when test='sortType == 17'> pay_status desc </when>
			<when test='sortType == 18'> pay_time desc </when>
			<when test='sortType == 19'> pay_type desc </when>
			<when test='sortType == 20'> out_day_time desc </when>
			<when test='sortType == 21'> part_money desc </when>
			<when test='sortType == 22'> part_time desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
