123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?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">
- <update id="unBindCar">
- update tb_business set card_no='',china_car_no='',business_car_id=null where id=#{id}
- </update>
- <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [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("owner") '>and owner like concat('%', #{owner} ,'%')</if>
- <if test=' this.has("no") '>and no like concat('%', #{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("goodsId") '>and goods_id = #{goodsId}</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("supplement") '>and supplement = #{supplement}</if>
- <if test=' this.has("error") '>and pay_time is null</if>
- <if test=' this.has("partTime") '>and part_time = #{partTime}</if>
- <if test=' this.has("createTime") '>and date_format(create_time,'%Y-%m-%d') = #{createTime}</if>
- <if test=' this.has("businessType") '>and business_type = #{businessType}</if>
- <if test=' this.has("businessCarId") '>and business_car_id = #{businessCarId}</if>
- <if test=' this.has("createByCustomerId") '>and create_by_customer_id = #{createByCustomerId}</if>
- <if test=' this.has("carNo") '>and (card_no like concat('%', #{carNo},'%') or china_car_no like concat('%', #{carNo},'%'))</if>
- <if test='adminConfirmInput !=null and adminConfirmInput>-1'>and admin_confirm_input = #{adminConfirmInput}</if>
- <if test='isCar==0'>
- and declare_no is not null
- </if>
- <if test='isCar==1'>
- and (declare_no is null or declare_no='')
- </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>
- <when test='sortType == 23'>supplement_time desc</when>
- <otherwise>id desc</otherwise>
- </choose>
- </select>
- <select id="getCarDisincleList" resultType="com.pj.project.tb_business.CarDisincle">
- SELECT
- a.id,
- b.id as businessCarId,
- a.`no`,a.operate_time,
- a.item_price,a.goods_name,a.admin_confirm_input,b.car_no,
- b.base_part_money,a.total_money,a.pay_money,a.create_time,
- b.real_in_time,b.real_out_time,b.car_no ,a.net_weight,a.card_size,a.pay_status,a.item_type_name
- from tb_business a,tb_business_car b
- WHERE a.business_car_id=b.id and (a.declare_no='' or a.declare_no is null)
- <if test="cardNo !='' and cardNo !=null">
- and b.car_no like concat('%',#{cardNo},'%')
- </if>
- <if test="no !='' and no !=null">
- and a.no like concat('%',#{no},'%')
- </if>
- <if test="adminConfirmInput !='-1'">
- and a.admin_confirm_input=#{adminConfirmInput}
- </if>
- <if test="customerId !=null and customerId !=''">
- and a.customer_id=#{customerId}
- </if>
- <if test="businessCarId !=null and businessCarId !=''">
- and a.business_car_id=#{businessCarId}
- </if>
- <if test="carNo !=null and carNo !=''">
- and b.car_no like concat ('%',#{carNo},'%')
- </if>
- ORDER BY a.create_time desc
- </select>
- <select id="checkCarBusinessType" resultType="java.lang.Integer">
- SELECT
- count(a.id)
- FROM
- tb_business_car a,
- relation_business_car b,
- tb_business c,
- tb_business_item d
- WHERE
- a.id = b.business_car_id
- and b.business_id=c.id
- and c.id=d.business_id
- AND a.car_no =#{carNo}
- and d.item_type_id=#{typeId}
- <if test="before==1">
- AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) < #{operateTime}
- </if>
- <if test="before==0">
- AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) > #{operateTime}
- </if>
- </select>
- <select id="checkCarBusinessTypeByTime" resultType="java.lang.Integer">
- SELECT
- count(b.id)
- FROM
- tb_business_car a,
- relation_business_car b,
- tb_business c,
- tb_business_item d
- WHERE
- a.id = b.business_car_id
- and b.business_id=c.id
- and c.id=d.business_id
- AND a.car_no =#{carNo}
- and d.item_type_id=#{typeId}
- AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) > #{timeStart}
- and DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) < #{timeEnd}
- <if test="businessId!=null and businessId !=''">
- and c.id !=#{businessId}
- </if>
- </select>
- <resultMap id="otherBusinessMap" type="com.pj.project.tb_business.TbBusiness">
- <result property="id" column="id"/>
- <result property="cardNo" column="card_no"/>
- <result property="chinaCarNo" column="china_car_no"/>
- <result property="no" column="no"/>
- <result property="createTime" column="create_time"/>
- <result property="customerName" column="customer_name"/>
- <result property="goodsName" column="goods_name"/>
- <result property="adminConfirmInput" column="admin_confirm_input"/>
- <result property="itemPrice" column="item_price"/>
- <result property="payMoney" column="pay_money"/>
- <result property="operateTime" column="operate_time"/>
- <collection property="items" ofType="com.pj.project.tb_item.TbItem" select="getItems" column="id"/>
- </resultMap>
- <select id="getOtherBusiness" resultType="com.pj.project.tb_business.TbBusiness">
- select * from tb_business
- <trim prefix="where" prefixOverrides="and||or">
- <if test="customerId !=null and customerId !=''">
- and customer_id=#{customerId}
- </if>
- <if test="carNo !=null and carNo !=''">
- and (card_no like concat('%',#{carNo},'%') or china_car_no like concat('%',#{carNo},'%'))
- </if>
- </trim>
- order by create_time desc
- </select>
- <select id="getItems" resultType="com.pj.project.tb_item.TbItem">
- select * from tb_item where business_id=#{id}
- </select>
- <select id="findOtherBusinessByCarId" resultType="com.pj.project.tb_business.TbBusiness">
- select distinct a.*
- from tb_business a,relation_business_car b
- where a.id=b.business_id
- and b.business_car_id=#{businessCarId}
- </select>
- </mapper>
|